GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
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:

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 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 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.
 

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.
 

Friends

template<class T >
class GmValueSetDataAccessorBase
 
template<class T >
class GmValueSetDataAccessor
 
template<class T >
class GmNoFunctionValueSetDataAccessor
 
template<class T >
class GmUnitConversionDataAccessor
 
class GmDefValueValueSetStoredData
 
class GmStateDumpValueSetDataItem
 
class GmHdf5ModelWriter
 

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

◆ accessor()

virtual GmTrackedValueAccessor * GmValueSetData::accessor ( const GmLogCategory & logger,
UnitConverter * conv,
QString desiredUnit,
bool atomic = false )
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 >.

◆ allValuesAreDef()

bool GmValueSetData::allValuesAreDef ( ) const
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.

◆ functionValue()

virtual void * GmValueSetData::functionValue ( int index) const
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 >.

◆ info()

virtual GmValueInfo * GmValueSetData::info ( ) const
pure virtual

◆ isDefValue()

virtual bool GmValueSetData::isDefValue ( int index) const
protectedpure virtual

◆ isDual()

virtual bool GmValueSetData::isDual ( ) const
pure virtual

◆ numValues()

virtual int GmValueSetData::numValues ( ) const
pure virtual

◆ 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 GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.

◆ 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 GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.

◆ storedItemSize()

virtual int GmValueSetData::storedItemSize ( ) const
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 >.

◆ storedValueType()

virtual StoredValueType GmValueSetData::storedValueType ( int index) const
protectedpure virtual

◆ 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 GmDefValueValueSetStoredData, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.

◆ 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 GmDefValueValueSetStoredData, GmFValueSetPackedData< Vector >, GmFVectorValueSetStoredData< Vector >, GmNoFValueSetPackedData< T, Vector >, GmNoFValueSetPackedData< double, Vector >, GmVectorValueSetStoredData< T, Vector >, and GmVectorValueSetStoredData< double, Vector >.


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