GemaCoreLib
The GeMA Core library
Public Member Functions | Protected Member Functions | List of all members
GmValueSetDataAccessor< T > Class Template Reference

An accessor implementation that can work with any kind of GmValueSetData, with or without functions, but without unit conversion support. More...

#include <gmValueSetDataAccessor.h>

Inheritance diagram for GmValueSetDataAccessor< T >:
Inheritance graph
[legend]
Collaboration diagram for GmValueSetDataAccessor< T >:
Collaboration graph
[legend]

Public Member Functions

 GmValueSetDataAccessor (GmValueSetData *vs, const GmLogCategory &logger, QString desiredUnit)
 Constructor. More...
 
virtual const double * valueAt (int index, const GmVector *coord) const
 Returns the value associated with the "index" position of the data set, evaluated at the requested position (when necessary). More...
 
virtual double scalarValueAt (int index, const GmVector *coord) const
 Similar to valueAt() but returning a single double. Must be used for scalar data sets only.
 
virtual bool setValueAsDef (int index)
 Similar to setValue(), filling the index entry with the default value.
 
virtual bool setFunctionValue (int index, GmUserFunction *functionDef)
 Overload of setValue() storing a user function definition. More...
 
virtual bool setFunctionValue (int index, GmUserFunctionEvaluator *functionEval)
 Overload of setValue() storing a user function evaluation context. More...
 
virtual bool isFunction (int index) const
 Returns true if the data in index is a reference to a function (in C or Lua). Used by valueStr() to mark function results.
 
virtual QString functionId (int index) const
 Returns a function id name for a function reference at the index or an empty string for non function indices. Used by valueStr().
 
- Public Member Functions inherited from GmValueSetDataAccessorBase< T >
virtual ~GmValueSetDataAccessorBase ()
 Virtual destructor.
 
virtual GmValueSetDatavalueSetData ()
 Returns the value set data that this accessor is tied to.
 
virtual void updateValueSetData (GmValueSetData *vsd)
 Updates the value set data that this accessor is tied to. The new accessor shares the same info object as the last one (and so the structure of the underlying data is the same)
 
virtual int size () const
 Returns the number of values in the set refered to by the accessor, meaning that valid indices will fall in the range [0..size()-1].
 
virtual bool isDefValue (int index) const
 Returns true if the value at the specified index is equal to the default value defined by info()->defValue()
 
virtual bool setValue (int index, const double *value)
 Allows for altering the value associated with entry "index" in the value set. This version of the function works for scalar, vector or matrix values. Values are copied to the data set. Matrix values should be organized in COLUMN MAJOR ORDER. More...
 
virtual bool setScalarValue (int index, double value)
 Similar to setValue() but passing a single double. Must be used for scalar data sets only.
 
template<>
void updateValueSetData (GmValueSetData *vsd)
 Updates the value set data that this accessor is tied to. The new accessor shares the same info object as the last one (and so the structure of the underlying data is the same)
 
template<>
void updateValueSetData (GmValueSetData *vsd)
 Updates the value set data that this accessor is tied to. The new accessor shares the same info object as the last one (and so the structure of the underlying data is the same)
 
- Public Member Functions inherited from GmTrackedValueAccessor
 GmTrackedValueAccessor (GmValueInfo *info, const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit)
 Constructor. More...
 
virtual ~GmTrackedValueAccessor ()
 Virtual destructor.
 
void setTrackIndex (int sindex, bool locked)
 Provides the tracked accessor with the index/state information that it needs to update its ValueSetData in the event of a change. More...
 
int trackIndex () const
 Returns the current track index as defined by the last call to setTrackIndex()
 
bool trackIndexLocked () const
 Returns if the track index is locked or not.
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
virtual void * qt_metacast (const char *)
 
virtual int qt_metacall (QMetaObject::Call, int, void **)
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectList & children () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
- Public Member Functions inherited from GmValueAccessorBase
 GmValueAccessorBase (GmValueInfo *info, const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit)
 Constructor. Reveives infromation about the returned values and basic parameters needed for unit conversion, initializing the basic fields _info, _conv, _rconv and _convData that will be used by derived classes. Takes ownership of the converter.
 
virtual ~GmValueAccessorBase ()
 Destructor.
 
virtual GmValueInfoinfo () const
 Returns the information object describing the values returned by this accessor.
 
virtual Unit unit () const
 Returns the unit in which data returned/received by the accessor is expressed. More...
 
virtual bool hasUnitConversion () const
 Returns true if this accessor perfroms unit conversions, false if not.
 
virtual QString valueStr (int index, bool evalFunctions, bool printDefAsNil, int fieldWidth=0, char format='g', int precision=-1, const GmVector *coord=NULL) const
 Auxiliary function to return the value of an accessor converted to a string. Works for scalars, vectors and matrices. More...
 
virtual bool setFunctionFromName (int index, QString userFunctionId, QString &err)
 Sets a function value from the function name. More...
 
virtual bool setValueFromVariant (int index, const QVariant &v, bool acceptMissingDimension, QString &err)
 Sets a value with data read from a QVariant. See parameter descriptions in GmValueAccessor::setValueFromVariant() More...
 
virtual void setEvalContext (GmValueSetEvalContext *context, bool ownsContext)
 Sets the EvalContext object that will be used to translate function names / objects into function evaluators to allow for evaluating user functions. More...
 
virtual GmValueSetEvalContextevalContext () const
 Returns the internal evaluation context. Needed by GmCellAccessorProxy, GmBcAccessorProxy & state dump functions.
 
- Public Member Functions inherited from GmValueAccessor
virtual ~GmValueAccessor ()
 Virtual destructor.
 
bool isScalar () const
 Returns true if the accessor returns scalar values (can be false even if valueSize() == 1 – think about a 1x1 matrix)
 
virtual const double * defValue () const
 Returns the default value for the data converted to the accessor unit. The returned array contents is valid only UNTIL a new call to the accessor is done. Meaningfull only when the default value is NOT a function.
 
int valueSize () const
 Returns the size of the array returned by value(), i.e. 1 for scalar values and nlin * ncol for vector or matrix values.
 
virtual int adjustLinearIndex (int index, const GmMesh *m)
 Translates a linear index (from 0 to mesh->totalNumNodes()-1) into a valid index for this accessor or into -1 if the given index is out of range. More...
 
virtual int adjustLinearIndex (int index, int firstGhostIndex)
 Simmilar to adjustLinearIndex(int, const GmMesh*), this function overload gets as second parameter the index of the first ghost node in the mesh (equal to mesh->numNodes()).
 
const double * value (int index) const
 Similar to valueAt(), passing NULL as coordinates.
 
double scalarValue (int index) const
 Similar to scalarValueAt(), passing NULL as coordinates.
 
void matrixValueAt (int index, const GmVector *coord, GmCRMatrix &mat) const
 Similar to valueAt(), but returning the result as a CONST matrix. Bear in mind that the resulting matrix is valid only UNTIL the next call to the accessor.
 
void matrixValue (int index, GmCRMatrix &mat) const
 Similar to matrixValueAt(), passing NULL as coordinates.
 
void vectorValueAt (int index, const GmVector *coord, GmCRVector &vec) const
 Similar to valueAt(), but returning the result as a CONST vector. Bear in mind that the resulting vector is valid only UNTIL the next call to the accessor.
 
void vectorValue (int index, GmCRVector &vec) const
 Similar to vectorValueAt(), passing NULL as coordinates.
 
virtual bool setScalarValueAtDim (int index, int dim, double val)
 Similar to setValue() but changing only the value at the given dimension. Can be used over scalar, vector and matrix sets. For matrices, dim refers to the position in the linearized vector data in COLUMN MAJOR FORMAT. Should be used only if the current value is NOT a function.
 
bool setMatrixValue (int index, const GmMatrix &mat)
 Similar to setValue() but receiving the data as a matrix.
 
bool setVectorValue (int index, const GmVector &vec)
 Similar to setValue() but receiving the data as a vector.
 
bool addScalarToValue (int index, double value)
 Convenience function equivalent to calling setScalarValue(index, scalarValue(index) + value)
 
bool addToValue (int index, const double *val)
 Convenience function logically equivalent to calling setValue(index, value(index) + val) operating over the full vector. Should be used only if the current value is NOT a function.
 

Protected Member Functions

 GmValueSetDataAccessor (GmValueSetData *vs, const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit)
 Overload of the basic class constructor, receiving a unit converter as an extra parameter. Should be used only by derived classes adding conversion to this implementation. More...
 
const double * eval (const GmValueSetData *vsd, GmValueSetData::StoredValueType type, int index, const GmVector *coord) const
 Auxiliar function to evaluate a function. Returns NULL on error. More...
 
- Protected Member Functions inherited from GmValueSetDataAccessorBase< T >
 GmValueSetDataAccessorBase (GmValueSetData *vs, const GmLogCategory &logger, UnitConverter *conv, QString desiredUnit)
 Constructor. More...
 
GmValueSetDatavs ()
 Atomically returns a copy of the value set data shared pointer. More...
 
const GmValueSetDatavs () const
 Const overload of the homonimous function.
 
template<>
GmValueSetDatavs ()
 
template<>
const GmValueSetDatavs () const
 
template<>
GmValueSetDatavs ()
 
template<>
const GmValueSetDatavs () const
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
- Protected Member Functions inherited from GmValueAccessorBase
const double * evalValue (GmUserFunctionEvaluator *functionEval, int index, const GmVector *coord) const
 An auxiliary function tailored for evaluating functions identified by its evaluator. This function should be called by implementations of valueAt(), and scalarValueAt() for ValueData objects of type GM_VDT_FUNCTION_EVAL. More...
 
const double * evalValue (GmUserFunction *functionDef, int index, const GmVector *coord) const
 Overload of evalValue(GmUserFunctionEvaluator*, ...) receiving a user function object. Should be called for ValueData objects of type GM_VDT_FUNCTION.
 
const double * evalDefValue (int index, const GmVector *coord) const
 Simmilar to evalValue(), this function evaluates a default value function. Should be called only when _info->defIsFunction() returns true.
 
virtual double convertToAccessorUnit (double val) const
 An utility function that given a value, converts it to the accessor unit. If no conversion is needed, returns val.
 
virtual const double * convertToAccessorUnit (const double *p) const
 An utility function that given a pointer to the stored data, converts the value to the accessor unit and returns a pointer to the internal buffer used to store the converted value. If no conversion is needed, returns p.
 
virtual void convertFromAccessorUnit (double val, double *dst) const
 Copies the values given by val into the area pointed to by dst, converting units if needed.
 
virtual void convertFromAccessorUnit (const double *val, double *dst) const
 Copies the values given by val into the area pointed to by dst, converting units if needed.
 
double * convData () const
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Static Public Member Functions inherited from GmValueAccessorBase
static bool fillMatrixFromLuaTable (double *m, int nlin, int ncol, LuaTable &t, const GmValueInfo *info, const double *defVal, QString &err)
 An auxilliar function that given a Lua table storing either a list of doubles or a list of lists of doubles, fills the given matrix m, stored in the pre-allocated vector with size nlin * ncol and organized "per column". More...
 
- Protected Attributes inherited from GmValueAccessorBase
GmValueInfo_info
 The metadata describing the values returned by this accessor.
 
const GmLogCategory_logger
 The logger object used to report errors while accessing or setting data.
 
GmTLBuffer< double, true > * _convData
 Per thread local buffer used to store converted data. Null if _conv == NULL.
 
UnitConverter_conv
 Unit converter.
 
UnitConverter_rconv
 Unit converter in the reverse direction: from desired unit to data unit.
 
QString _unit
 The unit in which data will be returned. Needed for the case when _conv = NULL and _info->unit() is empty.
 
- Properties inherited from QObject
 objectName
 

Detailed Description

template<class T>
class GmValueSetDataAccessor< T >

An accessor implementation that can work with any kind of GmValueSetData, with or without functions, but without unit conversion support.

Constructor & Destructor Documentation

◆ GmValueSetDataAccessor() [1/2]

template<class T >
GmValueSetDataAccessor< T >::GmValueSetDataAccessor ( GmValueSetData vs,
const GmLogCategory logger,
QString  desiredUnit 
)

Constructor.

Parameters
vsThe value set providing the accessed data
loggerThe logger used to report errors
desiredUnitThe desired unit. This parameter is needed for the accessor to report correctly its unit in the particular case when the value set does not have an unit (its unit is empty) and the desired unit is different from empty. In this case there is no converter but a desiredUnit exists.

◆ GmValueSetDataAccessor() [2/2]

template<class T >
GmValueSetDataAccessor< T >::GmValueSetDataAccessor ( GmValueSetData vs,
const GmLogCategory logger,
UnitConverter conv,
QString  desiredUnit 
)
protected

Overload of the basic class constructor, receiving a unit converter as an extra parameter. Should be used only by derived classes adding conversion to this implementation.

This constructor exists only to allow forwarding the converter to the GmMValueAccessor constructor.

Member Function Documentation

◆ eval()

template<class T >
const double * GmValueSetDataAccessor< T >::eval ( const GmValueSetData vsd,
GmValueSetData::StoredValueType  type,
int  index,
const GmVector coord 
) const
inlineprotected

Auxiliar function to evaluate a function. Returns NULL on error.

Receives vsd as a parameter to make sure that it evaluates the function in the same environment seen by the caller

◆ setFunctionValue() [1/2]

template<class T >
virtual bool GmValueSetDataAccessor< T >::setFunctionValue ( int  index,
GmUserFunction functionDef 
)
inlinevirtual

Overload of setValue() storing a user function definition.

This is the intended way to store a user function if the value set corresponding to this accessor is NOT directly tied to a mesh

(its a property set ValueSet, for example)

Implements GmValueAccessor.

◆ setFunctionValue() [2/2]

template<class T >
virtual bool GmValueSetDataAccessor< T >::setFunctionValue ( int  index,
GmUserFunctionEvaluator functionEval 
)
inlinevirtual

Overload of setValue() storing a user function evaluation context.

This is the intended way to store a user function if the value set corresponding to this accessor is directly tied to a mesh (a node or cell attribute, for example). Storing an evaluator is more efficient than a function definition, but can only be done if the value set is not shared between several meshes.

Implements GmValueAccessor.

◆ valueAt()

template<class T >
const double * GmValueSetDataAccessor< T >::valueAt ( int  index,
const GmVector coord 
) const
virtual

Returns the value associated with the "index" position of the data set, evaluated at the requested position (when necessary).

If the data is a function reference, the function will be called and the result returned. Also, the results will be converted to the requested desired unit.

The function returns the address of an array (possibly internal to the accessor), storing the requested data, which can be a scalar, a vector or a matrix, linearized using COLUMN MAJOR ORDER. This array contents is valid only UNTIL a new call to the accessor is done. This restriction allows for the accessor implementation to be free to return a pointer to the data when no unit conversion is needed or a pointer to a static internal buffer when converting values.

If an error happens while evaluating a function, the result will be the (converted) default value for the data set and an error message will be logged (if the default value is itself a function, the function will return a vector filled with zeros, converted to the desired unit if needed).

The set of coordinates is used only for the evaluation of user functions over cell attributes / properties. A NULL pointer can be passed if the accessor context doesn't needs this information (and that's why this parameter is a GmVector* and not a GmVector&).

The coordinate values depends on the type of cell. For 'plain' cells, it should be cartesian coordinates in the same unit as coordinates are expressed in the mesh.

For element cells, it should be natural coordinates.

Implements GmValueAccessor.


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