The basic interface for a shared buffer storing interleaved data for a group of value sets.
More...
|
|
| GmPackedBuffer (int id) |
| | Basic constructor. Gets as parameter the pack id.
|
| |
|
virtual | ~GmPackedBuffer () |
| | Virtual destructor.
|
| |
|
const GmPackedBufferInfo * | layout () const |
| | Returns the internal layout object.
|
| |
| virtual bool | isDual () const =0 |
| |
|
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)
|
| |
| virtual int | numValues () const =0 |
| |
| virtual bool | addValues (int numAddedValues)=0 |
| |
| virtual void | restoreSize (int oldNumValues)=0 |
| |
| virtual void | removeValues (int lineIndex, int numValues)=0 |
| |
| virtual void | clear ()=0 |
| |
| virtual size_t | usedMemory () const =0 |
| |
| virtual int | numDumpBuffers () const =0 |
| |
| virtual char * | dumpBuffer (int i) const =0 |
| |
| virtual size_t | dumpBufferSize (int i) const =0 |
| |
The basic interface for a shared buffer storing interleaved data for a group of value sets.
Implements the methods that do not depend on the actual storage vector (GmSingleVector or GmDualVectorR) and defines virtual functions for those who do. The concrete class and those functions are implemented by the GmPackedBufferImpl template class. This split allows for other classes to reference a packed buffer without its template parameter.
The "iptr()" method is not marked as a virtual function to avoid the virtual pointer overhead for such a high frequency called function. Since that is primarily only needed by GmValueSetPackedData, that class can operate on templated instances of the real packed buffer implementation given by GmPackedBufferImpl<Vector>
Since we can work with dual vectors, we must make sure that each buffer inside the vector is a multiple of the layout stride. This is necessary to allow for the existance of removeValues(). To guarantee this, and also to make the implementation easier, whenever the layout changes, even when removing data sets, a new buffer is fully allocated.
To make padding and dummy values easier to see on the debugger, padding bytes at the end of each data "line" are filled with the 0xCC pattern. Also, when initializing the buffer with default values, if a multi-dimensional value set has a default value function, only the first dimension value is filled with the function pointer. Additional dimensions are dummy values, also filled with the 0xCC pattern.
| bool GmPackedBuffer::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.
New data will be initialized with the value set default value. IMPORTANT: This function assumes that function default values are stored as a NAN box, consistently with whath is done in GmValueSetData.
If we could NOT update the buffer, the pending layout changes will be DISCARDED and the buffer reverts to the state of the ast successfull update, before the last calls to addValueSet().