SourceForge.net Logo
Public Member Functions

PythonQtValueStorage< T, chunkEntries > Class Template Reference

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

#include <PythonQtMisc.h>

List of all members.

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

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.

                         {
    _chunkIdx  = 0;
    _chunkOffset = 0;
    _currentChunk = new T[chunkEntries];
    _chunks.append(_currentChunk);
  };


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.

               {
    T* chunk;
    foreach(chunk, _chunks) {
      delete[]chunk;
    }
    _chunks.clear();
  }

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 100 of file PythonQtMisc.h.

                                                  {
    pos.chunkIdx = _chunkIdx;
    pos.chunkOffset = _chunkOffset;
  }

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 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;
  };

template<typename T, int chunkEntries>
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);
  }

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 106 of file PythonQtMisc.h.

                                                       {
    _chunkOffset = pos.chunkOffset;
    if (_chunkIdx != pos.chunkIdx) {
      _chunkIdx = pos.chunkIdx;
      _currentChunk = _chunks.at(_chunkIdx);
    }
  }


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