23#ifndef _GEMA_PACKED_BUFFER_H_
24#define _GEMA_PACKED_BUFFER_H_
42 int id()
const {
return _id; }
48 bool ready()
const {
return _waitingSets.isEmpty(); }
50 void removeValueSet(
int index);
54 int numSets()
const {
return _sets.size(); }
66 int offset(
int index)
const {
return _offset[index]; }
69 int size(
int index)
const {
return _offset[index + 1] - _offset[index]; }
72 int stride()
const {
return _stride; }
74 void notifyLayoutUpdates();
79#if defined ENABLE_TESTS || defined ENABLE_VALUESET_TESTS
80 void validateInternalStructure();
84 void updateControlFromPos(
int pos);
130 virtual bool isDual()
const = 0;
135 bool removeValueSet(
int index);
139 int numSets()
const {
return _layout.numSets(); }
148 int vsDataSize(
int index)
const {
return _layout.size(index); }
151 int vsDataOffset(
int index)
const { assert(_layout.ready());
return _layout.offset(index); }
154 int stride()
const { assert(_layout.ready());
return _layout.stride(); }
156 virtual int numValues()
const = 0;
157 virtual bool addValues(
int numAddedValues) = 0;
158 virtual void restoreSize(
int oldNumValues) = 0;
159 virtual void removeValues(
int lineIndex,
int numValues) = 0;
161 virtual void clear() = 0;
163 virtual size_t usedMemory()
const = 0;
164 virtual int numDumpBuffers()
const = 0;
165 virtual char* dumpBuffer(
int i)
const = 0;
166 virtual size_t dumpBufferSize(
int i)
const = 0;
168#if defined ENABLE_TESTS || defined ENABLE_VALUESET_TESTS
169 virtual void validateInternalStructure() = 0;
186template <
template <
class>
class Vector>
196 virtual bool isDual()
const {
return _data->isDual(); }
201 virtual bool addValues (
int numAddedValues);
202 virtual void restoreSize (
int oldNumValues);
203 virtual void removeValues(
int lineIndex,
int numValues);
206 char*
iptr(
int vsIndex,
int lineIndex)
208 assert(vsIndex >= 0 && vsIndex < numSets());
209 assert(lineIndex >= 0 && lineIndex < _numValues);
210 return _data->iptr((
size_t)lineIndex * _layout.stride() + _layout.offset(vsIndex));
214 const char*
iptr(
int vsIndex,
int lineIndex)
const
216 assert(vsIndex >= 0 && vsIndex < numSets());
217 assert(lineIndex >= 0 && lineIndex < _numValues);
218 return _data->iptr((
size_t)lineIndex * _layout.stride() + _layout.offset(vsIndex));
222 virtual void clear() { _data->clear(); _numValues = 0; }
229 virtual size_t usedMemory()
const {
return _data->usedMemory(); }
235 virtual char*
dumpBuffer(
int i)
const {
return _data->dumpBuffer(i); }
240#if defined ENABLE_TESTS || defined ENABLE_VALUESET_TESTS
241 virtual void validateInternalStructure();
The basic interface for a shared buffer storing interleaved data for a group of value sets.
Definition gmPackedBuffer.h:119
int stride() const
Returns the pack size (the sum of each value set data size + padding if needed)
Definition gmPackedBuffer.h:154
GmPackedBufferInfo _layout
The buffer layout for the added value sets.
Definition gmPackedBuffer.h:178
int numSets() const
Returns the number of value sets in the pack.
Definition gmPackedBuffer.h:139
int vsDataSize(int index) const
Returns the data size for the given value set object.
Definition gmPackedBuffer.h:148
int vsIndex(QString id) const
Returns the value set index inside the pack or -1 if not found.
Definition gmPackedBuffer.h:142
GmPackedBuffer(int id)
Basic constructor. Gets as parameter the pack id.
Definition gmPackedBuffer.h:122
GmValueSet * vs(int index) const
Returns the value set object at the given index.
Definition gmPackedBuffer.h:145
int vsDataOffset(int index) const
Returns the pack offset for the given value set object.
Definition gmPackedBuffer.h:151
const GmPackedBufferInfo * layout() const
Returns the internal layout object.
Definition gmPackedBuffer.h:128
virtual ~GmPackedBuffer()
Virtual destructor.
Definition gmPackedBuffer.h:125
The concrete implementation for GmPackedBuffer. The template parameter defines the kind of vector use...
Definition gmPackedBuffer.h:188
int _numValues
The number of values stored in _data. Equal to _data.size() / _layout.stride()
Definition gmPackedBuffer.h:258
GmPackedBufferImpl(int id)
Basic constructor. Gets as parameter the pack id.
Definition gmPackedBuffer.h:191
virtual size_t dumpBufferSize(int i) const
Returns the size in bytes of the i'th internal buffer returned by dumpBuffer(i)
Definition gmPackedBuffer.h:238
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 ov...
Definition gmPackedBuffer.h:206
virtual int numDumpBuffers() const
Returns the number of internal buffers used by this implementation.
Definition gmPackedBuffer.h:232
virtual void clear()
Clears the value sets, restoring their size to 0.
Definition gmPackedBuffer.h:222
virtual bool isDual() const
Returns true if the underlying data storage is a dual vector, false if not.
Definition gmPackedBuffer.h:196
Vector< char > * _data
The shared buffer for the value sets data. Must be a pointer due to possible layout changes.
Definition gmPackedBuffer.h:257
virtual size_t usedMemory() const
Returns an estimative of the memory used by the data set in bytes.
Definition gmPackedBuffer.h:229
virtual char * dumpBuffer(int i) const
Returns the i'th internal buffer, i from 0 to numDumpBuffers()-1.
Definition gmPackedBuffer.h:235
virtual int numValues() const
Returns the number of values stored in the value sets.
Definition gmPackedBuffer.h:199
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....
Definition gmPackedBuffer.h:214
A class used for storing and managing the order of the value sets inside a pack.
Definition gmPackedBuffer.h:36
int sizeofVsStorageType(const GmValueSet *vs) const
Returns the storage size for a value set taking into account funstion storage possibility.
Definition gmPackedBuffer.h:87
GmValueSet * vs(int index) const
Returns the value set object at the given index.
Definition gmPackedBuffer.h:60
int _id
The pack buffer id. Used for consistency check of the added value sets.
Definition gmPackedBuffer.h:93
QVector< GmValueSet * > _waitingSets
The set of value sets that where not yet added to _map, _sets and _offset.
Definition gmPackedBuffer.h:100
QVector< int > _offset
The offset of each value set in the pack. Its size is equal to _sets.size() + 1. The last entry store...
Definition gmPackedBuffer.h:96
int offset(int index) const
Returns the data offset(in bytes) for the begining of the data from the value set at the given index....
Definition gmPackedBuffer.h:66
int id() const
Returns the pack id.
Definition gmPackedBuffer.h:42
QVector< GmValueSet * > _sets
The ordered list of value sets for this pack.
Definition gmPackedBuffer.h:95
int _stride
The sum of the set sizes + padding.
Definition gmPackedBuffer.h:98
int numSets() const
Returns the number of value sets in the pack.
Definition gmPackedBuffer.h:54
int stride() const
Returns the buffer stride (sum of each value set size + padding)
Definition gmPackedBuffer.h:72
int size(int index) const
The size in bytes used by the value set at the given index (accounts for multiple states and multi-di...
Definition gmPackedBuffer.h:69
int _padding
The padding to ensure proper alignment when working with heterogeneous data types.
Definition gmPackedBuffer.h:97
int vsIndex(QString id) const
Returns the value set index inside the pack or -1 if not found.
Definition gmPackedBuffer.h:57
QMap< QString, int > _map
A map from value set Id to its position inside _sets.
Definition gmPackedBuffer.h:94
GmPackedBufferInfo(int id)
Basic constructor. Gets as parameter the pack id.
Definition gmPackedBuffer.h:39
void clearWaitingList()
Clears the set of added value sets after the object creation / last call to update()
Definition gmPackedBuffer.h:77
bool ready() const
Returns true if there are no pending calls to update()
Definition gmPackedBuffer.h:48
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
int sizeofStorageType() const
Returns the size in bytes of an entry of the current storage type. Not affected by the data dimension...
Definition gmValueInfo.cpp:235
bool canStoreFunctions() const
Returns true if values associated to this definition can be expressed as functions....
Definition gmValueInfo.h:205
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition gmValueSet.h:54
GmValueInfo * info() const
Returns the metadata associated with this value set.
Definition gmValueSet.h:72
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Implementation of the GmDualVector and GmDualVectorR template classes.
GmPackedBufferImpl< GmDualVectorR > GmDualPackedBuffer
The GmPackedBuffer class using a dual vector.
Definition gmPackedBuffer.h:266
GmPackedBufferImpl< GmSingleVector > GmSinglePackedBuffer
The GmPackedBuffer class using a single vector.
Definition gmPackedBuffer.h:263
Implementation of the GmSingleVector template class.
Declaration of the GmValueSet class.