GemaCoreLib
The GeMA Core library
Signals | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
GmResultsData Class Reference

Auxiliar class used to store the complete set of results data for a simulation. More...

#include <gmResultsData.h>

Inheritance diagram for GmResultsData:
Inheritance graph
[legend]
Collaboration diagram for GmResultsData:
Collaboration graph
[legend]

Signals

void monitoredValueChanged (int trackId, const GmResultTrackedData &value, bool waitForMore)
 The signal emited when there is a new tracked value available. The waitForMore flag indicates that other signals will be emitted shortly. The last emit in the sequence should set the flag to false. Alternatively,pending messages are sent when the monitoredValueChangedDone() signal is emitted. The number/type of values in the given tracked object should be compatible with the size/type associated with the given trackId.
 
void monitoredValueChangedDone ()
 A signal emitted to sinalize that a sequence of monitored value changes has ended.
 
void monitoredIndexChanged (int ruleId, const GmResultTrackedIndexData &value)
 The signal emited when there is a new index data available for a monitor rule.
 
void monitoredAttributeInfoChanged (int trackId, int ruleId, QString name, QString description, int type, QString unit, int nlin, int ncol, QString format)
 The signal emited when the metadata for a monitored attribute changed.
 

Public Member Functions

 GmResultsData (const GmSimulationData *simData)
 Constructor.
 
 ~GmResultsData ()
 Destructor.
 
void clear ()
 Clears the results data, deleting every result object and restoring the object to its construction state.
 
const QMap< QString, GmResultsRule * > & monitorRules () const
 Returns a const reference to the monitor rules map.
 
const QMap< QString, GmResultsRule * > & saveRules () const
 Returns a const reference to the save rules map.
 
bool addMonitorRule (GmResultsRule *rule)
 Adds a monitor rule to the results data. Returns false if an object with the same id already exists. Takes ownership of the object.
 
bool addSaveRule (GmResultsRule *rule)
 Adds a save rule to the results data. Returns false if an object with the same id already exists. Takes ownership of the object.
 
int numTrackedDataSrcs () const
 Returns the number of data srcs inside the set of monitor rules.
 
bool evalRules (QString ruleId="")
 Evaluates the set of stored monitor & save rules. If ruleId is empty, the full set of rules will be evaluated. Otherwise, only those with matching id will be evaluated. Returns false on errors (messages are printed with the result logger on errors).
 
int registerResultAttribute (const void *owner, QString name, QString description, Unit unit, int nlin, int ncol, QString format)
 Registers a new result attribute, belonging to the given "owner" object. A size of 0 (nlin = 0 and ncol = 0) means that this is a string attribute. Returns the result id or -1 if an attribute with the same name already exists, registered by another owner. If the attribute exists but was registered by the same owner, its properties (unit, dimension and / or format) are updated and the same id returned. It is not possible to change an attribute from numeric based to a string based value (returns -1). Also returns -1 if the registered attribute unit is incompatible with a previous rule unit.
 
void removeRegisteredAttributes (void *owner)
 Removes from the set of result attributes all attributes tied to the given object. This prevents an unlikely scenario where a reused object address can cause trouble (old attributes from a deleted object recognised as being owned by another object created afterwards)
 
bool registerAttributeRuleDataSrc (GmResultsRule *rule, GmAttributeResultDataSrc *ds)
 Registers a monitor rule attribute data src, adding it to the registered or unregistered maps. If a matching result attribute exists, estabilishes the connection. Returns false (and emmits an error message) if another rule already registered a data src with this same name or if the unit from the data src is incompatible with the unit of a already registered attribute.
 
void setResultAttributeValue (int id, double val)
 Sets the value for a scalar result attribute identified by its id.
 
void setResultAttributeValue (int id, double val1, double val2)
 Sets the value for a vector[2] result attribute identified by its id.
 
void setResultAttributeValue (int id, double val1, double val2, double val3)
 Sets the value for a vector[3] result attribute identified by its id.
 
void setResultAttributeValue (int id, const double *val)
 Sets the value for a multi valued result attribute identified by its id. Assumes that the given vector has size equal to the size given by its metadata. The values are copied.
 
void setResultAttributeValue (int id, const GmVector &val)
 Sets the value for a vector valued result attribute identified by its id. Assumes that the given vector has size equal to the size given by its metadata. The values are copied.
 
void setResultAttributeValue (int id, const GmMatrix &val)
 Sets the value for a matrix valued result attribute identified by its id. Assumes that the given matrix has size equal to the size given by its metadata. The values are copied.
 
void setResultAttributeValue (int id, QString val)
 Sets the value for a string based result attribute identified by its id.
 
int resultAttributeId (QString name) const
 Returns the id associated with the given result attribute name or -1 if no attribute with that name exists.
 
bool isNumericResult (int id) const
 Returns true if the given valid result id refers to a numeric based value.
 
const GmAttributeResultDataSrcInforesultAttributeInfo (int id) const
 Returns the metadata associated with the given result attribute id.
 
const double * resultAttributeBuffer (int id) const
 Returns the internal buffer used to store the last saved result for the given NUMERIC result attribute id.
 
QString resultAttributeString (int id) const
 Returns the string value for the given STRING result attribute id.
 
void enableMonitoring ()
 Enables the emission of the monitorValueChanged() family of signals.
 
QMutexmonitoringMutex ()
 Returns the mutex needed to protect access to rule metadata AFTER the model loading. More info on the comments at the _monitorMutex definition.
 
void setCurrentTime (double time)
 Publishes the current simulation time, throgh the special "time" result attribute.
 
GmResultsSerializernewSerializer (QString fileType, const GmLogCategory &logger) const
 Returns a new serializer to save mesh data to files of type fileType. More...
 
void printInfo (const GmLogCategory &logger)
 Prints information about the simulation using the provided logger (Info category)
 
const GmLogCategorylogger () const
 Returns the internal logger used by rules to emmit messages.
 
- 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 ()
 

Private Member Functions

GmAttributeResultDataSrcmonitoredAttrDataSrc (int id)
 Helper function to return the attribute data src for monitored attributes or NULL otherwise.
 
bool evalRule (GmResultsRule *rule, bool monitorRule)
 Work horse for evalRules()
 

Private Attributes

const GmSimulationData_simData
 The simulation data object.
 
bool _monitor
 Is there someone monitoring data changes?
 
QMutex _monitorMutex
 A mutex shared with the monitor thread to protect access to rule metadata, AFTER the model loading. At present, the only information that can change after model loading is the registering of new result attributes, so the only data that needs protecting is the access to the contents of a result attribute info object. More...
 
QMap< QString, GmResultsRule * > _monitorMap
 Map storing monitor result rules, keyed by rule id.
 
QMap< QString, GmResultsRule * > _saveMap
 Map storing save result rules, keyed by rule id.
 
int _numTrackedSrcs
 The sum of the number of data srcs in the set of monitor result rules.
 
GmLogCategory _logger
 The logger object used by rules to emmit messages.
 
QMap< QString, QPair< const void *, int > > _resultAttributeMap
 Map storing for each registered result attribute name its id and the object that registered that name (the later is used to allow an object to re-register its own attributes, perhaps with a different unit or dimension, but preventing name clashes from different "owners"). If the id is < firstStringAttributeId, it is an index in _resultAttributeData. Otherwise, (id - firstStringAttributeId) will be an index in _resultStringAttributeData.
 
int _timeAttributeId
 The id stored in _resultAttributeMap for the stanard "time" attribute.
 
QVector< QPair< GmAttributeResultDataSrcInfo *, double * > > _resultAttributeData
 A list storing for each registered numeric result attribute its metadata. More...
 
QVector< QPair< GmAttributeResultDataSrcInfo *, QString > > _resultStringAttributeData
 A list storing for each registered string result attribute its metadata. More...
 
QMap< int, QPair< GmResultsRule *, GmAttributeResultDataSrc * > > _registeredRuleAttributesMap
 A map storing for each result attribute id with an associated rule data src, that rule + data src object.
 
QMap< QString, QPair< GmResultsRule *, GmAttributeResultDataSrc * > > _unregisteredRuleAttributesMap
 A map storing for each yet unregistered monitor rule attribute, its associated rule + data src.
 

Static Private Attributes

static const int firstStringAttributeId = 1000
 The id for the first string attribute.
 

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)
 
- 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)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Auxiliar class used to store the complete set of results data for a simulation.

Member Function Documentation

◆ newSerializer()

GmResultsSerializer * GmResultsData::newSerializer ( QString  fileType,
const GmLogCategory logger 
) const

Returns a new serializer to save mesh data to files of type fileType.

Returns false for unknown file types. The returned pointer should be deleted by the caller after use.

Member Data Documentation

◆ _monitorMutex

QMutex GmResultsData::_monitorMutex
private

A mutex shared with the monitor thread to protect access to rule metadata, AFTER the model loading. At present, the only information that can change after model loading is the registering of new result attributes, so the only data that needs protecting is the access to the contents of a result attribute info object.

Especifically, this mutex is currently used to prevent a race between the main thread registering a new attribute while the monitor thread sends results metadata on a new connection.

◆ _resultAttributeData

QVector<QPair<GmAttributeResultDataSrcInfo*, double*> > GmResultsData::_resultAttributeData
private

A list storing for each registered numeric result attribute its metadata.

  • its value, stored in an allocated buffer with the size given by the metadata. Might contain "holes" due to unregistered attributes.

◆ _resultStringAttributeData

QVector<QPair<GmAttributeResultDataSrcInfo*, QString> > GmResultsData::_resultStringAttributeData
private

A list storing for each registered string result attribute its metadata.

  • its value. Might contain "holes" due to unregistered attributes.

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