23 #ifndef _GEMA_VALUE_SET_DATA_H_ 24 #define _GEMA_VALUE_SET_DATA_H_ 30 #include <QVarLengthArray> 83 virtual bool init(
int numValues) = 0;
86 virtual int numValues()
const = 0;
91 virtual bool addValues(
int numAddedValues) = 0;
94 virtual void restoreSize(
int oldNumValues) = 0;
97 virtual void removeValues(
int index,
int numValues) = 0;
100 virtual void clear() = 0;
107 QString desiredUnit,
bool atomic =
false) = 0;
114 virtual size_t usedMemory()
const = 0;
116 #if defined ENABLE_TESTS || defined ENABLE_VALUESETDATA_TESTS 117 virtual void validateInternalStructure() = 0;
136 virtual bool isDefValue(
int index)
const = 0;
139 virtual StoredValueType storedValueType(
int index)
const = 0;
149 virtual const double* value(
int index)
const = 0;
156 virtual bool setValue(
int index,
const double* values) = 0;
163 virtual void* functionValue(
int index)
const = 0;
173 virtual bool setFunctionValue(
int index, StoredValueType type,
void* functionObj) = 0;
216 virtual bool addValues (
int numAddedValues);
225 QString desiredUnit,
bool atomic =
false);
230 #if defined ENABLE_TESTS || defined ENABLE_VALUESETDATA_TESTS 231 virtual void validateInternalStructure();
249 virtual const double*
value(
int index)
const;
250 virtual bool setValue(
int index,
const double* values);
253 virtual void*
functionValue(
int index)
const { Q_UNUSED(index); assert(0);
return NULL; }
258 Q_UNUSED(index); Q_UNUSED(type); Q_UNUSED(functionObj);
303 QString desiredUnit,
bool atomic =
false);
318 virtual const double*
value (
int index)
const;
319 virtual bool setValue(
int index,
const double* values);
367 virtual bool addValues(
int numAddedValues) { _numValues += numAddedValues;
return true; }
370 virtual void restoreSize(
int oldNumValues) { _numValues = oldNumValues; }
376 assert(index >= 0 && index + numValues <= _numValues);
381 virtual void clear() { _numValues = 0; }
384 QString desiredUnit,
bool atomic =
false);
389 static void cleanupDetachedData();
391 #if defined ENABLE_TESTS || defined ENABLE_VALUESETDATA_TESTS 392 virtual void validateInternalStructure();
397 virtual bool isDefValue(
int index)
const { Q_UNUSED(index);
return true; }
403 virtual const double*
value(
int index)
const { Q_UNUSED(index); assert(_defType == GM_SVT_NUMBER);
return (
double*)_defValue; }
405 virtual bool setValue(
int index,
const double* values);
408 virtual void*
functionValue(
int index)
const { Q_UNUSED(index); assert(_defType != GM_SVT_NUMBER);
return _defValue; }
410 virtual bool setFunctionValue(
int index, StoredValueType type,
void* functionObj);
virtual StoredValueType storedValueType(int index) const
Returns the type (number, function definition/evaluator) of the stored value for the given index.
Definition: gmValueSetData.h:400
virtual StoredValueType storedValueType(int index) const
Returns the type (number, function definition/evaluator) of the stored value for the given index.
Definition: gmValueSetData.cpp:388
virtual void removeValues(int index, int numValues)
Removes numValues from the set, starting from (and including) index.
Definition: gmValueSetData.cpp:171
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition: gmValueInfo.h:126
int _dim
Value dimension. Equal to _info->size();.
Definition: gmValueSetData.h:270
virtual const double * value(int index) const
Returns the numeric value stored at the given index (converted to a double if needed) Must be called ...
Definition: gmValueSetData.cpp:396
int capacity() const const
virtual int numValues() const
Returns the number of values stored in this value set.
Definition: gmValueSetData.h:214
virtual const double * value(int index) const
Returns the numeric value stored at the given index (converted to a double if needed) Must be called ...
Definition: gmValueSetData.cpp:239
virtual size_t usedMemory() const
Returns an estimative of the memory used by the data set in bytes.
Definition: gmValueSetData.h:387
Basic class used to store sets of values, bound to a common definition, on behalf of another object (...
Definition: gmValueSet.h:53
StoredValueType _defType
The type of the default value.
Definition: gmValueSetData.h:415
An accessor implementation that can work with any kind of GmValueSetData, with or without functions,...
Definition: gmValueSetDataAccessor.h:195
virtual bool setValue(int index, const double *values)
Updates the value stored at the given index with a numeric value (converted to the correct type if ne...
Definition: gmValueSetData.cpp:404
virtual bool init(int numValues)
Initilizes the value set allocating space.
Definition: gmValueSetData.h:361
A class similar to GmTLS that creates a buffer for each possible thread in the GmThreadManager,...
Definition: gmValueSetData.h:43
A number.
Definition: gmValueSetData.h:71
virtual void initVector(int start, int n)
Initializes the data array from the given start position, with n copies of the default value.
Definition: gmValueSetData.cpp:349
Declaration of usefull configuration definitions for the Core library.
virtual void restoreSize(int oldNumValues)
Restores the size of the set to the previous size before addValues.
Definition: gmValueSetData.cpp:157
GmValueSet * _vs
The value set that owns us.
Definition: gmValueSetData.h:414
Declaration of the GmValueInfo class.
virtual GmTrackedValueAccessor * accessor(const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit, bool atomic=false)=0
Returns an accessor for the stored data. The atomic flag can be used by the caller to request that a ...
A support class for saving data to a HDF5 file. Hdf5 files are self-describing but do not have a fixe...
Definition: gmHdf5.h:65
virtual bool setValue(int index, const double *values)=0
Updates the value stored at the given index with a numeric value (converted to the correct type if ne...
void * _defValue
The default value. Will be a double* or a pointer to one of the function object types depending on _d...
Definition: gmValueSetData.h:416
virtual int numValues() const =0
Returns the number of values stored in this value set.
An accessor implementation that can work with any kind of GmValueSetData, without support for functio...
Definition: gmValueSetDataAccessor.h:136
A GmMemoryDumpItem implementation loading / storing values from the GmValueSetData object associated ...
Definition: gmStateDumpItem.h:286
virtual size_t usedMemory() const
Returns an estimative of the memory used by the data set in bytes.
Definition: gmValueSetData.h:228
GmVectorValueSetData(GmValueInfo *info)
Constructor. The object will NOT take ownership of the given info object.
Definition: gmValueSetData.cpp:87
A GmValueSetData implementation that stores no data and returns the default value,...
Definition: gmValueSetData.h:350
virtual StoredValueType storedValueType(int index) const
Returns the type (number, function definition/evaluator) of the stored value for the given index.
Definition: gmValueSetData.h:247
virtual GmTrackedValueAccessor * accessor(const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit, bool atomic=false)
Returns an accessor for the stored data. The atomic flag can be used by the caller to request that a ...
Definition: gmValueSetData.cpp:221
A GmValueSetData implementation that adds support for storing functions to GmVectorValueSetData.
Definition: gmValueSetData.h:297
virtual bool setFunctionValue(int index, StoredValueType type, void *functionObj)
Overload of setValue() storing a user function definition.
Definition: gmValueSetData.h:256
virtual void * functionValue(int index) const
Returns a pointer to the stored function object. Return will be either a GmUserFunction* or a GmUserF...
Definition: gmValueSetData.cpp:421
QMutex _setMutex
The mutex protecting setXxxx() operations.
Definition: gmValueSetData.h:417
bool _detached
Flag marking that this object should be no longer in use.
Definition: gmValueSetData.h:418
virtual void clear()
Clears the value set, restoring its size to 0.
Definition: gmValueSetData.h:381
virtual void clear()
Clears the value set, restoring its size to 0.
Definition: gmValueSetData.h:222
static QVector< GmValueSetData * > _detachedList
A global list with the set of detached GmDefValueValueSetData marked for delayed deletion by cleanupD...
Definition: gmValueSetData.h:426
virtual bool addValues(int numAddedValues)
Adds numAddedValues to the set, initializing them to the default value. Returns true on success,...
Definition: gmValueSetData.cpp:137
virtual void removeValues(int index, int numValues)
Removes numValues from the set, starting from (and including) index.
Definition: gmValueSetData.h:373
int _numValues
The number of entries in this data set.
Definition: gmValueSetData.h:412
QVarLengthArray< T, 1 > _data
The vector storing the data. Its size is equal to _dim * _numValues.
Definition: gmValueSetData.h:272
GmTLBuffer< double, true > * _convBuffer
The buffer used to store data returned by value() when T is not double.
Definition: gmValueSetData.h:273
virtual bool addValues(int numAddedValues)
Adds numAddedValues to the set, initializing them to the default value. Returns true on success,...
Definition: gmValueSetData.h:367
virtual void initVector(int start, int n)
Initializes the data array from the given start position, with n copies of the default value.
Definition: gmValueSetData.cpp:183
A GmValueSetData implementation that supports efficient storing for numeric values,...
Definition: gmValueSetData.h:202
A wrapper class around QtNanBoxedValue providing specific constructors to store user functions / user...
Definition: gmNanBoxedValue.h:40
virtual void restoreSize(int oldNumValues)
Restores the size of the set to the previous size before addValues.
Definition: gmValueSetData.h:370
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
virtual bool isDefValue(int index) const
Returns true if the indexed value is the default value for the set.
Definition: gmValueSetData.cpp:368
const double * defValue() const
Returns the default value used for initializing/sparse values. If the default is a function,...
Definition: gmValueInfo.h:183
Auxiliary class responisble for allowing a value accessor to track changes to the referenced value se...
Definition: gmTrackedValueAccessor.h:37
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base cl...
Definition: gmValueSetData.h:65
Auxiliar class used to store the needed information to translate an user function id / user function ...
Definition: gmValueSetEvalContext.h:45
StoredValueType
Enumeration to detect the type of stored data for an index.
Definition: gmValueSetData.h:69
virtual bool isDefValue(int index) const
Returns true if the indexed value is the default value for the set.
Definition: gmValueSetData.h:397
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
const T * iptr(int index) const
Returns a pointer to the index data inside _data.
Definition: gmValueSetData.h:236
A template class to add unit conversion support to the given base class.
Definition: gmValueSetDataAccessor.h:240
virtual char * dumpBuffer()
Returns the internal buffer that can be used for a direct data dumping/loading by the GmStateDump cla...
Definition: gmValueSetData.h:264
virtual const double * value(int index) const
Returns the numeric value stored at the given index (converted to a double if needed) Must be called ...
Definition: gmValueSetData.h:403
int _numValues
The number of values stored in _data. Equal to _data.size() / _dim.
Definition: gmValueSetData.h:271
Common code for both GmNoFunctionValueSetDataAccessor and GmValueSetDataAccessor.
Definition: gmValueSetDataAccessor.h:40
virtual GmValueInfo * info() const
Returns a pointer to the associated value info object.
Definition: gmValueSetData.h:358
virtual int dumpBufferSize() const
Returns the size in bytes of the internal buffer returned by dumpBuffer. Returns 0 if there is no suc...
Definition: gmValueSetData.h:267
GmValueInfo * _info
The info object describing this set contents.
Definition: gmValueSetData.h:269
virtual int numValues() const
Returns the number of values stored in this value set.
Definition: gmValueSetData.h:364
virtual bool setValue(int index, const double *values)
Updates the value stored at the given index with a numeric value (converted to the correct type if ne...
Definition: gmValueSetData.cpp:258
virtual void * functionValue(int index) const
Returns a pointer to the stored function object. Return will be either a GmUserFunction* or a GmUserF...
Definition: gmValueSetData.h:253
virtual int dumpBufferSize() const
Returns the size in bytes of the internal buffer returned by dumpBuffer. Returns 0 if there is no suc...
Definition: gmValueSetData.h:184
virtual ~GmValueSetData()
Virtual destructor.
Definition: gmValueSetData.h:77
const GmNanBoxedValue * nanBoxPtr(int index) const
Returns a pointer to the index data inside _data converted to a Nan Box.
Definition: gmValueSetData.h:307
virtual bool init(int numValues)
Initilizes the value set allocating space.
Definition: gmValueSetData.cpp:128
GmUserFunction * _defFunction
The default user function if the default value is a function, NULL otherwise.
Definition: gmValueSetData.h:324
Class used to store the definition of a user function and its parameters.
Definition: gmUserFunction.h:78
A pointer to a user function definition.
Definition: gmValueSetData.h:72
virtual char * dumpBuffer()
Returns the internal buffer that can be used for a direct data dumping/loading by the GmStateDump cla...
Definition: gmValueSetData.h:179
virtual bool setFunctionValue(int index, StoredValueType type, void *functionObj)=0
Overload of setValue() storing a user function definition.
virtual void * functionValue(int index) const
Returns a pointer to the stored function object. Return will be either a GmUserFunction* or a GmUserF...
Definition: gmValueSetData.h:408
virtual bool isDefValue(int index) const
Returns true if the indexed value is the default value for the set.
Definition: gmValueSetData.h:244
virtual bool setFunctionValue(int index, StoredValueType type, void *functionObj)
Overload of setValue() storing a user function definition.
Definition: gmValueSetData.cpp:429
GmValueSetData * _bc
The base container that we should initialize and revert to when a value is written to the data set.
Definition: gmValueSetData.h:413
GmFVectorValueSetData(GmValueInfo *info, GmValueSetEvalContext *evalContext)
Constructor. Needs a function evaluator as parameter when the default value is a function.
Definition: gmValueSetData.cpp:316
GmNanBoxedValue * nanBoxPtr(int index)
Non-const overload to return a pointer to the index data inside _data converted to a Nan Box.
Definition: gmValueSetData.h:310
A pointer to an evaluator for a user function definition.
Definition: gmValueSetData.h:73
virtual GmTrackedValueAccessor * accessor(const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit, bool atomic=false)
Returns an accessor for the stored data. The atomic flag can be used by the caller to request that a ...
Definition: gmValueSetData.cpp:332
T * iptr(int index)
Non-const overload to return a pointer to the index data inside _data.
Definition: gmValueSetData.h:239
virtual GmValueInfo * info() const
Returns a pointer to the associated value info object.
Definition: gmValueSetData.h:209
virtual ~GmVectorValueSetData()
Destructor for the common case.
Definition: gmValueSetData.cpp:121