![]() |
GemaCoreLib
The GeMA Core library
|
A GmValueSetData implementation that supports efficient storing for numeric values, either scalar or multi-dimensional, in a vector storage. More...
#include <gmValueSetData.h>
Public Member Functions | |
GmVectorValueSetData (GmValueInfo *info) | |
Constructor. The object will NOT take ownership of the given info object. | |
virtual | ~GmVectorValueSetData () |
Destructor for the common case. | |
virtual GmValueInfo * | info () const |
Returns a pointer to the associated value info object. | |
virtual bool | init (int numValues) |
Initilizes the value set allocating space. | |
virtual int | numValues () const |
Returns the number of values stored in this value set. | |
virtual bool | addValues (int numAddedValues) |
Adds numAddedValues to the set, initializing them to the default value. Returns true on success, false on error. On errors previous values are kept. | |
virtual void | restoreSize (int oldNumValues) |
Restores the size of the set to the previous size before addValues. | |
virtual void | removeValues (int index, int numValues) |
Removes numValues from the set, starting from (and including) index. | |
virtual void | clear () |
Clears the value set, restoring its size to 0. | |
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 protected version of the accessor is needed for multi-threaded cases. | |
virtual size_t | usedMemory () const |
Returns an estimative of the memory used by the data set in bytes. More... | |
![]() | |
virtual | ~GmValueSetData () |
Virtual destructor. | |
Protected Member Functions | |
const T * | iptr (int index) const |
Returns a pointer to the index data inside _data. | |
T * | iptr (int index) |
Non-const overload to return a pointer to the index data inside _data. | |
virtual void | initVector (int start, int n) |
Initializes the data array from the given start position, with n copies of the default value. | |
virtual bool | isDefValue (int index) const |
Returns true if the indexed value is the default value for the set. | |
virtual StoredValueType | storedValueType (int index) const |
Returns the type (number, function definition/evaluator) of the stored value for the given index. | |
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 only for indices storing numeric data. Does NOT evaluate functions. More... | |
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 needed) More... | |
virtual void * | functionValue (int index) const |
Returns a pointer to the stored function object. Return will be either a GmUserFunction* or a GmUserFunctionEvaluator* depending on the type returned by storedValueType(index). Must be called only for indices storing data of those types. | |
virtual bool | setFunctionValue (int index, StoredValueType type, void *functionObj) |
Overload of setValue() storing a user function definition. More... | |
virtual char * | dumpBuffer () |
Returns the internal buffer that can be used for a direct data dumping/loading by the GmStateDump classes. Returns NULL if there is no such buffer and that is NOT supported. | |
virtual int | dumpBufferSize () const |
Returns the size in bytes of the internal buffer returned by dumpBuffer. Returns 0 if there is no such buffer and that is NOT supported. | |
Protected Attributes | |
GmValueInfo * | _info |
The info object describing this set contents. | |
int | _dim |
Value dimension. Equal to _info->size();. | |
int | _numValues |
The number of values stored in _data. Equal to _data.size() / _dim. | |
QVarLengthArray< T, 1 > | _data |
The vector storing the data. Its size is equal to _dim * _numValues. | |
GmTLBuffer< double, true > * | _convBuffer |
The buffer used to store data returned by value() when T is not double. | |
Private Member Functions | |
Q_DISABLE_COPY (GmVectorValueSetData) | |
Additional Inherited Members | |
![]() | |
enum | StoredValueType { GM_SVT_NUMBER, GM_SVT_FUNCTION, GM_SVT_FUNCTION_EVAL } |
Enumeration to detect the type of stored data for an index. More... | |
A GmValueSetData implementation that supports efficient storing for numeric values, either scalar or multi-dimensional, in a vector storage.
This class does not support function values or sparse formats, having little overhead compared to just storing data in a vector. Its template parameter T defines the type of the data stored on the vector.
Since the interface communicates values as doubles, the stored data might need to be copied to an internal double buffer by calls to value(). A template specialization when T = double prevents this overhead in that case.
|
inlineprotectedvirtual |
Overload of setValue() storing a user function definition.
Receives as parameters the value index, its type (function definition/evaluator) and a pointer to the stored function object (should be either a GmUserFunction or a GmUserFunctionEvaluator object).
Returns false if the data could not be set.
Implements GmValueSetData.
Reimplemented in GmFVectorValueSetData.
|
protectedvirtual |
Updates the value stored at the given index with a numeric value (converted to the correct type if needed)
Returns false if the data could not be set.
Implements GmValueSetData.
Reimplemented in GmFVectorValueSetData.
|
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 GmValueSetData.
|
protectedvirtual |
Returns the numeric value stored at the given index (converted to a double if needed) Must be called only for indices storing numeric data. Does NOT evaluate functions.
VERY IMPORTANT: Since data conversion might be necessary (when the stored data is not in double format), the contents of the pointer returned by value is VALID only until the next call. This behaviour is COMPATIBLE with the general accessor behaviour.
Implements GmValueSetData.
Reimplemented in GmFVectorValueSetData.