![]() |
GemaCoreLib
The GeMA Core library
|
The concrete implementation for GmPackedBuffer. The template parameter defines the kind of vector used for storing the data. Can be instanced with Vector equal to GmSingleVector or GmDualVectorR (dual vector with support for remove values). More...
#include <gmPackedBuffer.h>


Public Member Functions | |
| GmPackedBufferImpl (int id) | |
| Basic constructor. Gets as parameter the pack id. | |
| virtual | ~GmPackedBufferImpl () |
| Destructor. | |
| virtual bool | isDual () const |
| Returns true if the underlying data storage is a dual vector, false if not. | |
| virtual int | numValues () const |
| Returns the number of values stored in the value sets. | |
| virtual bool | addValues (int numAddedValues) |
| Adds the given number of values to the sets, initializing them to the default value. Returns false on errors. On errors, previous values are kept. Keep in mind that either all sets are resized or none are. | |
| virtual void | restoreSize (int oldNumValues) |
| Restores the size of the buffer to the previous size before addValues. Can be called with the current size if addValues was not called. | |
| virtual void | removeValues (int lineIndex, int numValues) |
| Removes numValues from the set, starting from (and including) index. | |
| char * | iptr (int vsIndex, int lineIndex) |
| Returns the data pointer for the index'th value from the given value set. NOT virtual to avoid the overhead. | |
| const char * | iptr (int vsIndex, int lineIndex) const |
| Const overload for returning the data pointer for the index'th value from the given value set. NOT virtual to avoid the overhead. | |
| virtual void | clear () |
| Clears the value sets, restoring their size to 0. | |
| virtual size_t | usedMemory () const |
| Returns an estimative of the memory used by the data set in bytes. | |
| virtual int | numDumpBuffers () const |
| Returns the number of internal buffers used by this implementation. | |
| virtual char * | dumpBuffer (int i) const |
| Returns the i'th internal buffer, i from 0 to numDumpBuffers()-1. | |
| virtual size_t | dumpBufferSize (int i) const |
| Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i) | |
Public Member Functions inherited from GmPackedBuffer | |
| GmPackedBuffer (int id) | |
| Basic constructor. Gets as parameter the pack id. | |
| virtual | ~GmPackedBuffer () |
| Virtual destructor. | |
| const GmPackedBufferInfo * | layout () const |
| Returns the internal layout object. | |
| void | addValueSet (GmValueSet *vs) |
| Adds a new value set to the pack. It will be effectivelly added on the next call to update(). | |
| bool | update () |
| Updates the pack with the set of added value sets. If the pack already has data, a new buffer will be allocated with the new layout and the old data will be copied to the correct place. | |
| bool | removeValueSet (int index) |
| Imediately removes the given value set from the pack, identified by its current index in the pack. Returns false if not found. If the pack already has data, a new buffer will be allocated with the new layout and the old data will be copied to the correct place. The Value set is NOT deleted. | |
| bool | removeValueSet (GmValueSet *vs) |
| Removes a value set from the pack. Returns false if it couldn't be found neither in the layout nor in the waiting list. Also returns false if there was an error removing the value set from the layout. | |
| int | numSets () const |
| Returns the number of value sets in the pack. | |
| int | vsIndex (QString id) const |
| Returns the value set index inside the pack or -1 if not found. | |
| GmValueSet * | vs (int index) const |
| Returns the value set object at the given index. | |
| int | vsDataSize (int index) const |
| Returns the data size for the given value set object. | |
| int | vsDataOffset (int index) const |
| Returns the pack offset for the given value set object. | |
| int | stride () const |
| Returns the pack size (the sum of each value set data size + padding if needed) | |
Protected Member Functions | |
| virtual bool | updateData (const GmPackedBufferInfo &oldLayout, const QVector< int > *newSetIndices) |
| Given that _data contains values in the given old layout, updates the data to the new layout given by _layout. If newSetIndices is not NULL, value sets where added to the pack and their indices in _layout are given by that vector. | |
Protected Member Functions inherited from GmPackedBuffer | |
Private Member Functions | |
| void | copyBuffer (const GmPackedBufferInfo *oldInfo, const char *oldBuffer, const GmPackedBufferInfo *newInfo, char *newBuffer, size_t numValues, const QVector< const char * > *init=NULL) const |
| Given an old buffer layout information + buffer data with numValues "lines" of data, copies the information that should be moved to the new buffer with the new layout. Can cope with value set inserts and deletes, but assumes that any value set in both buffers have exactly the same size. If new value sets where added, their values are left uninitialized, unless 'init' is different from NULL. In that case, it should be a vector with the same number of entries as the new value sets added to the current layout, filled with the initial value for each new value set. This vector must be ordered in the same order as the new value sets appear in the layout. Vector entry 'i' should be a char buffer with size equal to size(index), where index is the index of the i'th new value set. That means that it should account for multi-dimensional values and for multiple states. | |
| void | fillInitBuffer (QVector< char > &buf, QVector< const char * > &index, const QVector< int > *newSetIndices) const |
| Fills buf with the default values for the value sets in _layout, taking into account value set data type, dimension, number of states and function support. Fills index with pointers to the start of each value set default value in buf. If newSetIndices is not NULL, it contains the indices in _layout of the value sets to be added to the buffer. When newSetIndices is NULL, also includes in the buffer the padding byte initialized to PACK_FILL8. Dummy values due to multidimension function default values are also initialized with PACK_FILL64. | |
Additional Inherited Members | |
Protected Attributes inherited from GmPackedBuffer | |
| GmPackedBufferInfo | _layout |
| The buffer layout for the added value sets. | |
The concrete implementation for GmPackedBuffer. The template parameter defines the kind of vector used for storing the data. Can be instanced with Vector equal to GmSingleVector or GmDualVectorR (dual vector with support for remove values).
|
virtual |
Adds the given number of values to the sets, initializing them to the default value. Returns false on errors. On errors, previous values are kept. Keep in mind that either all sets are resized or none are.
Implements GmPackedBuffer.
|
inlinevirtual |
Clears the value sets, restoring their size to 0.
Implements GmPackedBuffer.
|
private |
Given an old buffer layout information + buffer data with numValues "lines" of data, copies the information that should be moved to the new buffer with the new layout. Can cope with value set inserts and deletes, but assumes that any value set in both buffers have exactly the same size. If new value sets where added, their values are left uninitialized, unless 'init' is different from NULL. In that case, it should be a vector with the same number of entries as the new value sets added to the current layout, filled with the initial value for each new value set. This vector must be ordered in the same order as the new value sets appear in the layout. Vector entry 'i' should be a char buffer with size equal to size(index), where index is the index of the i'th new value set. That means that it should account for multi-dimensional values and for multiple states.
IMPORTANT: oldBuffer and newBuffer MUST NOT OVERLAP. Padding bytes are filled with the PACK_FILL8 pattern.
|
inlinevirtual |
Returns the i'th internal buffer, i from 0 to numDumpBuffers()-1.
Implements GmPackedBuffer.
|
inlinevirtual |
Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i)
Implements GmPackedBuffer.
|
inlinevirtual |
Returns true if the underlying data storage is a dual vector, false if not.
Implements GmPackedBuffer.
|
inlinevirtual |
Returns the number of internal buffers used by this implementation.
Implements GmPackedBuffer.
|
inlinevirtual |
Returns the number of values stored in the value sets.
Implements GmPackedBuffer.
|
virtual |
Removes numValues from the set, starting from (and including) index.
Implements GmPackedBuffer.
|
virtual |
Restores the size of the buffer to the previous size before addValues. Can be called with the current size if addValues was not called.
Implements GmPackedBuffer.
|
protectedvirtual |
Given that _data contains values in the given old layout, updates the data to the new layout given by _layout. If newSetIndices is not NULL, value sets where added to the pack and their indices in _layout are given by that vector.
Implements GmPackedBuffer.
|
inlinevirtual |
Returns an estimative of the memory used by the data set in bytes.
It returns in general the variable memory that depends on the number of set entries but does not include constant overheads used by the class for control
Implements GmPackedBuffer.