SourceForge.net Logo
PythonQt
Public Member Functions | Protected Attributes | List of all members
PythonQtValueStorage< T, chunkEntries > Class Template Reference

a helper class that stores basic C++ value types in chunks More...

#include <PythonQtMisc.h>

Inheritance diagram for PythonQtValueStorage< T, chunkEntries >:
PythonQtValueStorageWithCleanup< T, chunkEntries >

Public Member Functions

 PythonQtValueStorage ()
 
void clear ()
 clear all memory More...
 
void getPos (PythonQtValueStoragePosition &pos)
 get the current position to be restored with setPos More...
 
void setPos (const PythonQtValueStoragePosition &pos)
 set the current position (without freeing memory, thus caching old entries for reuse) More...
 
T * nextValuePtr ()
 add one default constructed value and return the pointer to it More...
 

Protected Attributes

QList< T * > _chunks
 
int _chunkIdx
 
int _chunkOffset
 
T * _currentChunk
 

Detailed Description

template<typename T, int chunkEntries>
class PythonQtValueStorage< T, chunkEntries >

a helper class that stores basic C++ value types in chunks

Definition at line 73 of file PythonQtMisc.h.

Constructor & Destructor Documentation

template<typename T, int chunkEntries>
PythonQtValueStorage< T, chunkEntries >::PythonQtValueStorage ( )
inline

Definition at line 76 of file PythonQtMisc.h.

76  {
77  _chunkIdx = 0;
78  _chunkOffset = 0;
79  _currentChunk = new T[chunkEntries];
80  _chunks.append(_currentChunk);
81  };
QList< T * > _chunks
Definition: PythonQtMisc.h:123

Member Function Documentation

template<typename T, int chunkEntries>
void PythonQtValueStorage< T, chunkEntries >::clear ( )
inline

clear all memory

Definition at line 84 of file PythonQtMisc.h.

84  {
85  T* chunk;
86  Q_FOREACH(chunk, _chunks) {
87  delete[]chunk;
88  }
89  _chunks.clear();
90  }
QList< T * > _chunks
Definition: PythonQtMisc.h:123
template<typename T, int chunkEntries>
void PythonQtValueStorage< T, chunkEntries >::getPos ( PythonQtValueStoragePosition pos)
inline

get the current position to be restored with setPos

Definition at line 93 of file PythonQtMisc.h.

template<typename T, int chunkEntries>
T* PythonQtValueStorage< T, chunkEntries >::nextValuePtr ( )
inline

add one default constructed value and return the pointer to it

Definition at line 108 of file PythonQtMisc.h.

108  {
109  if (_chunkOffset>=chunkEntries) {
110  _chunkIdx++;
111  if (_chunkIdx >= _chunks.size()) {
112  T* newChunk = new T[chunkEntries];
113  _chunks.append(newChunk);
114  _currentChunk = newChunk;
115  } else {
117  }
118  _chunkOffset = 0;
119  }
120  T* newEntry = _currentChunk + _chunkOffset;
121  _chunkOffset++;
122  return newEntry;
123  };
QList< T * > _chunks
Definition: PythonQtMisc.h:123
template<typename T, int chunkEntries>
void PythonQtValueStorage< T, chunkEntries >::setPos ( const PythonQtValueStoragePosition pos)
inline

set the current position (without freeing memory, thus caching old entries for reuse)

Definition at line 99 of file PythonQtMisc.h.

Referenced by PythonQtValueStorageWithCleanup< QVariant, 128 >::setPos().

Member Data Documentation

template<typename T, int chunkEntries>
int PythonQtValueStorage< T, chunkEntries >::_chunkIdx
protected
template<typename T, int chunkEntries>
int PythonQtValueStorage< T, chunkEntries >::_chunkOffset
protected
template<typename T, int chunkEntries>
QList<T*> PythonQtValueStorage< T, chunkEntries >::_chunks
protected
template<typename T, int chunkEntries>
T* PythonQtValueStorage< T, chunkEntries >::_currentChunk
protected

The documentation for this class was generated from the following file: