![]() |
GemaCoreLib
The GeMA Core library
|
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base class that can be used without concerns about the effective layout of the stored data. More...
#include <gmValueSetData.h>

Public Types | |
| enum | StoredValueType { GM_SVT_NUMBER , GM_SVT_FUNCTION , GM_SVT_FUNCTION_EVAL } |
| Enumeration to detect the type of stored data for an index. More... | |
Public Member Functions | |
| virtual | ~GmValueSetData () |
| Virtual destructor. | |
| virtual GmValueInfo * | info () const =0 |
| Returns a pointer to the associated value info object. | |
| virtual bool | isDual () const =0 |
| Returns true if the underlying data storage is a dual vector, false if not. | |
| virtual int | numValues () const =0 |
| Returns the number of values stored in this value set. | |
| virtual int | storedItemSize () const =0 |
| Returns the size in bytes of a value set item. It is usually equal to the data dimension (info()->size()) times the size of the data type (info()->sizeofStorageType()), but can be different if the underlying vector type is different from the requested storage type (when function support is requested, for example, all data is stored as double). | |
| 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 protected version of the accessor is needed for multi-threaded cases. | |
| virtual size_t | usedMemory () const =0 |
| Returns an estimative of the memory used by the data set in bytes. | |
Protected Member Functions | |
| virtual bool | isDefValue (int index) const =0 |
| Returns true if the indexed value is the default value for the set. | |
| virtual bool | allValuesAreDef () const |
| Checks that all stored values are equal to the default. | |
| virtual StoredValueType | storedValueType (int index) const =0 |
| Returns the type (number, function definition/evaluator) of the stored value for the given index. | |
| virtual const double * | value (int index) const =0 |
| 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. | |
| 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 needed) | |
| virtual void * | functionValue (int index) const =0 |
| 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)=0 |
| Overload of setValue() storing a user function definition. | |
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base class that can be used without concerns about the effective layout of the stored data.
This class is designed to work together with the GmValueSetDataAccessor family of classes.
Concrete classes inheriting from GmValueSetData can choose which capabilities to support (such as support for functions or sparse data), the data layout in memory and even the stored data type.
Although value sets can store data with other formats than double, keeping memory usage low, the data interface is ALWAYS done through double values. Please remember that a double can store exactly any integer value up to 2^52
|
pure virtual |
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.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
protectedvirtual |
Checks that all stored values are equal to the default.
This default implementation traverses the whole set until it finds a value that is not equal to the default. Since this is a very specific function with very limited use, it doesn't seems worthy to do any other optimization (other than the specialization for the GmDefValueValueSetStoredData class that can always return true!)
Reimplemented in GmDefValueValueSetStoredData.
|
protectedpure virtual |
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.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
pure virtual |
Returns a pointer to the associated value info object.
Implemented in GmDefValueValueSetStoredData, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
protectedpure virtual |
Returns true if the indexed value is the default value for the set.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
pure virtual |
Returns true if the underlying data storage is a dual vector, false if not.
Implemented in GmDefValueValueSetStoredData, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
pure virtual |
Returns the number of values stored in this value set.
Implemented in GmDefValueValueSetStoredData, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
protectedpure virtual |
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.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
protectedpure virtual |
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.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
pure virtual |
Returns the size in bytes of a value set item. It is usually equal to the data dimension (info()->size()) times the size of the data type (info()->sizeofStorageType()), but can be different if the underlying vector type is different from the requested storage type (when function support is requested, for example, all data is stored as double).
Implemented in GmDefValueValueSetStoredData, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
protectedpure virtual |
Returns the type (number, function definition/evaluator) of the stored value for the given index.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
pure virtual |
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
Implemented in GmDefValueValueSetStoredData, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.
|
protectedpure virtual |
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.
Implemented in GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.