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

Signals

void monitoredValueChanged (int trackId, const GmResultsTrackedData &value, bool waitForMore)
 The signal emitted 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 signalize that a sequence of monitored value changes has ended.
 
void monitoredIndexChanged (int dataSetId, const GmResultsTrackedIndexData &value)
 The signal emitted when there is a new index data available for a monitor rule.
 
void monitoredAttributeInfoChanged (int trackId, int dataSetId, QString name, QString description, int type, QString unit, int nlin, int ncol, QString format)
 The signal emitted 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, GmResultsDataSet * > & resultDataSets () const
 Returns a const reference to the results data set map.
 
const QMap< QString, GmResultsTimeSet * > & timeSets () const
 Returns a const reference to the results time set map.
 
const QMap< QString, GmResultsRule * > & resultsRules () const
 Returns a const reference to the results rules map.
 
const QVector< GmMonitorResultsRule * > & monitorResultRules () const
 Returns a const reference to the monitor results rules vector.
 
bool addResultsDataSet (GmResultsDataSet *ds)
 Adds a results data set to the results data. Returns false if an object with the same id already exists. Takes ownership of the object.
 
bool addTimeSet (GmResultsTimeSet *timeSet)
 Adds a time set to the results data. Returns false if an object with the same id already exists. Takes ownership of the object.
 
bool addResultsRule (GmResultsRule *rule)
 Adds a results rule to the results data. Returns false if an object with the same id already exists. Takes ownership of the object.
 
bool evalRules (const QStringList &ruleIds=QStringList(), bool force=false, bool timeManagerPrint=false)
 Evaluates the set of stored save, print & monitor rules. If ruleIds is empty, the full set of rules will be evaluated. Otherwise, only those with matching ids will be evaluated.
 
void resetEvalAttrValue (int attrId=-1)
 Asks the time manager to reset the current attribute values used for time set evaluation, so that the time set execution rule times evaluation starts again. An optional attribute id specifies that only that attribute value should be reset.
 
double nextEvalAttrValue (int attrId, GmResultsTimeManagerEvalMode mode=GM_RTM_ALL, QString timeSet="")
 Returns the next attribute value where a result rule will be activated. Receives as parameter the attribute id. The mode parameter defines wether intervals, moments or both tables will be queried. A third optional parameter can filter the result by a time set name if the attribute is tied to more than one time set. Returns DBL_MAX if there is no next value for this attribute (on this time set, if given).
 
double lastEvalAttrValue (int attrId, GmResultsTimeManagerEvalMode mode=GM_RTM_ALL, QString timeSet="")
 Returns the last attribute value where a result rule will be activated. Receives as parameter the attribute id. The mode parameter defines wether intervals, moments or both tables will be queried. A third optional parameter can filter the result by a time set name if the attribute is tied to more than one time set. Returns DBL_MAX if there is none for this attribute or if the interval is open for the attribute (on this time set, if given).
 
const GmSimulationDatasimulationData () const
 Returns the associated simulation data object.
 
GmAttributeResultsManagerattributes () const
 Returns the attribute manager.
 
GmResultsTimeManagertimeManager () const
 Returns the results time manager.
 
int nextMonitoredDataSetId ()
 Returns the next available monitored data set id and increments the number of monitored data sets.
 
int nextMonitoredDataSrcId ()
 Returns the next available monitored data src id and increments the number of monitored data srcs.
 
int numMonitoredDataSets () const
 Returns the number of monitored data sets (data sets associated to a monitor rule).
 
int numMonitoredDataSrcs () const
 Returns the number of monitored data srcs (data srcs inside data sets that are associated to a monitor rule).
 
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, through the special "time" result attribute.
 
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 emit messages.
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 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 QObjectListchildren () 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 ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

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.
 
QMap< QString, GmResultsDataSet * > _dataSetMap
 Map storing result data set, keyed by data set id.
 
QMap< QString, GmResultsTimeSet * > _timeSetMap
 Map storing time sets, keyed by rule id.
 
QMap< QString, GmResultsRule * > _rulesMap
 Map storing save, print and monitor result rules, keyed by rule id.
 
QVector< GmMonitorResultsRule * > _monitorRules
 Subset of _rulesMap, storing only monitor result rules.
 
GmAttributeResultsManager_attrManager
 The attribute manager storing attribute values + their matching with data sources.
 
int _timeAttributeId
 The id stored in _attrManager for the standard "time" attribute.
 
GmResultsTimeManager_timeManager
 The results time manager. Mutable for construction on first use.
 
int _numMonitoredDataSets
 The number of data sets that are being monitored by a monitor results rule.
 
int _numMonitoredDataSrcs
 The sum of the number of data sources in the set of monitored data sets.
 
int _evalRulesItem
 The progress item for evalRules() calls.
 
int _evalRulesCallCounterAttribute
 The counter attribute used to track the number of calls to evalRules()
 
GmLogCategory _logger
 The logger object used by rules to emit messages.
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- 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

◆ evalRules()

bool GmResultsData::evalRules ( const QStringList & ruleIds = QStringList(),
bool force = false,
bool timeManagerPrint = false )

Evaluates the set of stored save, print & monitor rules. If ruleIds is empty, the full set of rules will be evaluated. Otherwise, only those with matching ids will be evaluated.

If force is false, rules associated to a time set will only be evaluated if attribute values match the times defined by registered time sets. Otherwise (force is true), time sets are ignored an the rules are always evaluated. Rules that are not associated with a time set will always be executed.

If timeManagerPrint is true, asks the time manager to print to the logger some extra information on its internal structure. Will have an effect only if force is false and there are rules associated to time sets. For regression tests purpose only.

Returns false on errors (messages are printed with the result logger on errors).

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.

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


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