GemaCoreLib
The GeMA Core library
Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
GmValueSetData Class Referenceabstract

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>

Inheritance diagram for GmValueSetData:
Inheritance graph
[legend]

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 GmValueInfoinfo () const =0
 Returns a pointer to the associated value info object.
 
virtual bool init (int numValues)=0
 Initilizes the value set allocating space.
 
virtual int numValues () const =0
 Returns the number of values stored in this value set.
 
virtual bool addValues (int numAddedValues)=0
 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)=0
 Restores the size of the set to the previous size before addValues.
 
virtual void removeValues (int index, int numValues)=0
 Removes numValues from the set, starting from (and including) index.
 
virtual void clear ()=0
 Clears the value set, restoring its size to 0.
 
virtual GmTrackedValueAccessoraccessor (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. More...
 

Protected Member Functions

virtual bool isDefValue (int index) const =0
 Returns true if the indexed value is the default value for the set.
 
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. More...
 
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) More...
 
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. 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.
 

Friends

template<class T >
class GmValueSetDataAccessorBase
 
template<class T >
class GmValueSetDataAccessor
 
template<class T >
class GmNoFunctionValueSetDataAccessor
 
template<class T >
class GmUnitConversionDataAccessor
 
class GmDefValueValueSetData
 
class GmStateDumpValueSetDataItem
 
class GmHdf5
 

Detailed Description

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

Member Enumeration Documentation

◆ StoredValueType

Enumeration to detect the type of stored data for an index.

Enumerator
GM_SVT_NUMBER 

A number.

GM_SVT_FUNCTION 

A pointer to a user function definition.

GM_SVT_FUNCTION_EVAL 

A pointer to an evaluator for a user function definition.

Member Function Documentation

◆ setFunctionValue()

virtual bool GmValueSetData::setFunctionValue ( int  index,
StoredValueType  type,
void *  functionObj 
)
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 GmDefValueValueSetData, GmFVectorValueSetData, GmVectorValueSetData< T >, and GmVectorValueSetData< double >.

◆ setValue()

virtual bool GmValueSetData::setValue ( int  index,
const double *  values 
)
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 GmDefValueValueSetData, GmFVectorValueSetData, GmVectorValueSetData< T >, and GmVectorValueSetData< double >.

◆ usedMemory()

virtual size_t GmValueSetData::usedMemory ( ) const
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 GmDefValueValueSetData, GmVectorValueSetData< T >, and GmVectorValueSetData< double >.

◆ value()

virtual const double* GmValueSetData::value ( int  index) const
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 GmDefValueValueSetData, GmFVectorValueSetData, GmVectorValueSetData< T >, and GmVectorValueSetData< double >.


The documentation for this class was generated from the following file: