GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmValueSetData.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4** All rights reserved.
5**
6** This file is part of the "GeMA" software. It's use should respect
7** the terms in the license agreement that can be found together
8** with this source code.
9** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11** A PARTICULAR PURPOSE.
12**
13************************************************************************/
14
23#ifndef _GEMA_VALUE_SET_DATA_H_
24#define _GEMA_VALUE_SET_DATA_H_
25
26#include "gmCoreConfig.h"
27#include "gmValueInfo.h"
28
30class UnitConverter;
31class GmLogCategory;
32
33
34// Enable the define below to force validation of internal structures after value set initialization or growth
35// #define ENABLE_VALUESETDATA_TESTS
36
38#define GM_VALUESET_ALIGNED_BUFFERS true
39
40//----------------------------------------------------------------------
41// GmValueSetData - Basic interface
42//----------------------------------------------------------------------
43
58{
59public:
67
69 virtual ~GmValueSetData() {};
70
72 virtual GmValueInfo* info() const = 0;
73
75 virtual bool isDual() const = 0;
76
78 virtual int numValues() const = 0;
79
86 virtual int storedItemSize() const = 0;
87
93 QString desiredUnit, bool atomic = false) = 0;
94
100 virtual size_t usedMemory() const = 0;
101
102#if defined ENABLE_TESTS || defined ENABLE_VALUESETDATA_TESTS
103 virtual void validateInternalStructure() = 0;
104#endif
105
106protected:
107 // Functions below are part of the cooperative interface between a ValueSetData and the
108 // ValueSetDataAccessor familly of classes. They are marked protected since they are not
109 // intended for being used by users of ValueSetData, who should always access and store
110 // values through accessors. Some of them are also necessary by the state dump and HDF5 classes.
111 template <class T> friend class GmValueSetDataAccessorBase;
112 template <class T> friend class GmValueSetDataAccessor;
113 template <class T> friend class GmNoFunctionValueSetDataAccessor;
114 template <class T> friend class GmUnitConversionDataAccessor; // The unit conversion versions of the above classes
115 friend class GmDefValueValueSetStoredData;
116 friend class GmStateDumpValueSetDataItem;
117 friend class GmHdf5ModelWriter;
118
120 virtual bool isDefValue(int index) const = 0;
121
122 virtual bool allValuesAreDef() const;
123
125 virtual StoredValueType storedValueType(int index) const = 0;
126
135 virtual const double* value(int index) const = 0;
136
142 virtual bool setValue(int index, const double* values) = 0;
143
149 virtual void* functionValue(int index) const = 0;
150
159 virtual bool setFunctionValue(int index, StoredValueType type, void* functionObj) = 0;
160};
161
162
163#endif
164
165
A GmValueSetStiredData implementation that stores no data and returns the default value,...
Definition gmValueSetStoredData.h:269
A class used to export parts of a GeMA model to an HDF5 file. Its API includes both GeMA centric func...
Definition gmHdf5ModelWriter.h:58
Class representing a category with multiple logging levels.
Definition gmLog.h:58
An accessor implementation that can work with any kind of GmValueSetData, without support for functio...
Definition gmValueSetDataAccessor.h:137
A GmMemoryDumpItem implementation loading / storing values from the GmValueSetData object associated ...
Definition gmStateDumpItem.h:312
Auxiliary class responisble for allowing a value accessor to track changes to the referenced value se...
Definition gmTrackedValueAccessor.h:38
A template class to add unit conversion support to the given base class.
Definition gmValueSetDataAccessor.h:241
Auxiliar class used to store the definition of a value. It can be used to store informations about st...
Definition gmValueInfo.h:132
Common code for both GmNoFunctionValueSetDataAccessor and GmValueSetDataAccessor.
Definition gmValueSetDataAccessor.h:41
An accessor implementation that can work with any kind of GmValueSetData, with or without functions,...
Definition gmValueSetDataAccessor.h:196
The generic interface implemented by every GmValueSetData object. Its purpose is to provide a base cl...
Definition gmValueSetData.h:58
virtual bool isDual() const =0
Returns true if the underlying data storage is a dual vector, false if not.
virtual size_t usedMemory() const =0
Returns an estimative of the memory used by the data set in bytes.
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 ...
virtual void * functionValue(int index) const =0
Returns a pointer to the stored function object. Return will be either a GmUserFunction* or a GmUserF...
virtual int storedItemSize() const =0
Returns the size in bytes of a value set item. It is usually equal to the data dimension (info()->siz...
virtual int numValues() const =0
Returns the number of values stored in this value set.
StoredValueType
Enumeration to detect the type of stored data for an index.
Definition gmValueSetData.h:62
@ GM_SVT_NUMBER
A number.
Definition gmValueSetData.h:63
@ GM_SVT_FUNCTION
A pointer to a user function definition
Definition gmValueSetData.h:64
@ GM_SVT_FUNCTION_EVAL
A pointer to an evaluator for a user function definition.
Definition gmValueSetData.h:65
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 ...
virtual GmValueInfo * info() const =0
Returns a pointer to the associated value info object.
virtual bool setFunctionValue(int index, StoredValueType type, void *functionObj)=0
Overload of setValue() storing a user function definition.
virtual ~GmValueSetData()
Virtual destructor.
Definition gmValueSetData.h:69
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...
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.
Declaration of useful configuration definitions for the Core library.
#define GMC_API_EXPORT
Macro for controlling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_L...
Definition gmCoreConfig.h:35
Declaration of the GmValueInfo class.