a helper class that stores basic C++ value types in chunks More...
#include <PythonQtMisc.h>
Public Member Functions | |
| PythonQtValueStorage () | |
| void | clear () |
| clear all memory | |
| void | reset () |
| reset the storage to 0 (without freeing memory, thus caching old entries for reuse) | |
| void | getPos (PythonQtValueStoragePosition &pos) |
| get the current position to be restored with setPos | |
| void | setPos (const PythonQtValueStoragePosition &pos) |
| set the current position (without freeing memory, thus caching old entries for reuse) | |
| T * | nextValuePtr () |
| add one default constructed value and return the pointer to it | |
a helper class that stores basic C++ value types in chunks
Definition at line 73 of file PythonQtMisc.h.
| PythonQtValueStorage< T, chunkEntries >::PythonQtValueStorage | ( | ) | [inline] |
Definition at line 76 of file PythonQtMisc.h.
{
_chunkIdx = 0;
_chunkOffset = 0;
_currentChunk = new T[chunkEntries];
_chunks.append(_currentChunk);
};
| void PythonQtValueStorage< T, chunkEntries >::clear | ( | ) | [inline] |
clear all memory
Definition at line 84 of file PythonQtMisc.h.
{
T* chunk;
foreach(chunk, _chunks) {
delete[]chunk;
}
_chunks.clear();
}
| void PythonQtValueStorage< T, chunkEntries >::getPos | ( | PythonQtValueStoragePosition & | pos | ) | [inline] |
get the current position to be restored with setPos
Definition at line 100 of file PythonQtMisc.h.
{
pos.chunkIdx = _chunkIdx;
pos.chunkOffset = _chunkOffset;
}
| T* PythonQtValueStorage< T, chunkEntries >::nextValuePtr | ( | ) | [inline] |
add one default constructed value and return the pointer to it
Definition at line 115 of file PythonQtMisc.h.
{
if (_chunkOffset>=chunkEntries) {
_chunkIdx++;
if (_chunkIdx >= _chunks.size()) {
T* newChunk = new T[chunkEntries];
_chunks.append(newChunk);
_currentChunk = newChunk;
} else {
_currentChunk = _chunks.at(_chunkIdx);
}
_chunkOffset = 0;
}
T* newEntry = _currentChunk + _chunkOffset;
_chunkOffset++;
return newEntry;
};
| void PythonQtValueStorage< T, chunkEntries >::reset | ( | ) | [inline] |
reset the storage to 0 (without freeing memory, thus caching old entries for reuse)
Definition at line 93 of file PythonQtMisc.h.
{
_chunkIdx = 0;
_chunkOffset = 0;
_currentChunk = _chunks.at(0);
}
| 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 106 of file PythonQtMisc.h.
{
_chunkOffset = pos.chunkOffset;
if (_chunkIdx != pos.chunkIdx) {
_chunkIdx = pos.chunkIdx;
_currentChunk = _chunks.at(_chunkIdx);
}
}
1.7.1