![]() |
GemaCoreLib
The GeMA Core library
|
A class used to host the metadata and the values for all attributes added to the results data. This includes the attributes referenced by result data sets and attributes created by the progress stats classes, also managing their correspondence. It also controls which attributes are being monitored and among those, which of them should have value changes broadcasted "immediately". More...
#include <gmAttributeResultsManager.h>


Classes | |
| union | AttrValue |
| The union representing the saved value Using a QString instead of a QString* should be possible, but would require an explicit destructor for the union due to the non POD member and more complicated code to init the value and destroy the union. See, for example, https://en.cppreference.com/w/cpp/language/union Since the set of string attributes is minimal, storing a pointer should not really matter. More... | |
| struct | AttrValueWithStats |
| An option to store an attribute value with statistics. More... | |
| struct | RegisteredAttrData |
| The data associated with registered attributes. It includes the object "owner" to allow for auto deregistering when the object is destroyed. This helps to solve some destruction order dependencies related to objects holding a simulation model data pointer, used to access the results data only to unregister attributes on the object destructor (see the comments on SVN revision 4139). More... | |
Signals | |
| void | attributeRegistered (int id, QString name) |
| Signal emitted whenever a new attribute was registered by registerResultAttribute() | |
| void | attributeUnregistered (int id, QString name) |
| Signal emitted whenever a registered attribute is removed by removeResultAttribute() or by its owner being deleted. | |
Public Member Functions | |
| GmAttributeResultsManager (GmResultsData *resultsData) | |
| Constructor. | |
| ~GmAttributeResultsManager () | |
| Destructor. | |
| void | clear () |
| Clears the manager, releasing every stored attribute. | |
| void | enableMonitoring () |
| Enables the emission of the monitorValueChanged() family of signals (from the resultsData object) | |
| int | registerResultAttribute (const QObject *owner, QString name, QString description, Unit unit, int nlin, int ncol, QString format, int stats) |
| 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. | |
| void | removeResultAttribute (int id) |
| Removes the given attribute from the set of registered attributes. | |
| bool | renameResultAttribute (int id, QString newName) |
| Renames an existing result attribute. Returns false if the new name is not unique. If there was any data src connected to the old name, it will be unregistered. Any unregistered attributes for the new name will be registered. | |
| bool | registerAttributeDataSrc (GmResultsDataSet *dataSet, GmAttributeResultsDataSrc *ds, QString &err) |
| Registers a data set attribute data src, adding it to the registered or unregistered maps. If a matching registered attribute exists, estabilishes the connection. Returns false if the unit from the data src is incompatible with the unit of an already registered attribute, filling err with a message. | |
| void | updateRegisteredAttributeDataSrc (GmResultsDataSet *dataSet, GmAttributeResultsDataSrc *ds) |
| Given a registered attribute, updates the given dataSet + ds pair status from unmonitored to monitored. | |
| void | removeAttributeDataSet (GmResultsDataSet *dataSet) |
| Removes from the manager any references to a data set or its child data srcs. | |
| 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. | |
| void | clearAttributeStatistics (int id) |
| Clears the attribute statistics. Does nothing if id does not save statistic values. | |
| void | updateAttributeStatistics (int id) |
| Updates the attribute statistics with the current attribute value. Does nothing if id does not svae statistic values. | |
| bool | isValidAttributeId (int id) const |
| Returns true if the given id is a valid attribute id. | |
| const QObject * | attributeIdOwner (int id) const |
| Returns the owner object for the given result attribute. | |
| 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 GmAttributeResultsDataSrcInfo * | resultAttributeInfo (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. | |
| const double * | resultAttributeStatisticsMinBuffer (int id) const |
| Returns the internal buffer used to store the minimum saved result for the given NUMERIC result attribute id. Returns NULL if no statistics are saved. | |
| const double * | resultAttributeStatisticsMaxBuffer (int id) const |
| Returns the internal buffer used to store the maximum saved result for the given NUMERIC result attribute id. Returns NULL if no statistics were saved. | |
| const double * | resultAttributeStatisticsSumBuffer (int id) const |
| Returns the internal buffer used to store the sum of the saved results for the given NUMERIC result attribute id. Returns NULL if no statistics were saved. | |
| quint64 | resultAttributeStatisticsCount (int id) const |
| Returns the count of the saved results for the given NUMERIC result attribute id. Returns 0 if no statistics were saved. | |
Public Member Functions inherited from QObject | |
| virtual const QMetaObject * | metaObject () 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) |
| QThread * | thread () 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) |
| T | 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 ®Exp, 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< QByteArray > | dynamicPropertyNames () const const |
| void | destroyed (QObject *obj) |
| void | objectNameChanged (const QString &objectName) |
| QObject * | parent () const const |
| bool | inherits (const char *className) const const |
| void | deleteLater () |
| Q_DISABLE_COPY (Class) | |
| Q_DISABLE_MOVE (Class) | |
| Q_DISABLE_COPY_MOVE (Class) | |
| T | qobject_cast (QObject *object) |
| T | qobject_cast (const QObject *object) |
| T | qFindChild (const QObject *obj, const QString &name) |
| QList< T > | qFindChildren (const QObject *obj, const QString &name) |
| QList< T > | qFindChildren (const QObject *obj, const QRegExp ®Exp) |
| 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 Slots | |
| void | removeRegisteredAttributes (QObject *owner) |
| Removes from the set of result attributes all attributes tied to the given object. | |
Private Member Functions | |
| Q_DISABLE_COPY (GmAttributeResultsManager) | |
| RegisteredAttrData * | data (int id) const |
| Helper function to return the full attribute data associated to a valid attribute id. | |
| GmAttributeResultsDataSrcInfo * | info (int id) const |
| Helper function to return the attribute info associated to a valid attribute id. | |
| AttrValue & | value (int id) const |
| Helper function to return the attribute value associated to a valid attribute id. | |
| void | unregisteredToRegistered (RegisteredAttrData *ad, int attrId) |
| Moves data set + data src pairs from the unregistered map to a registered attribute. | |
| void | registeredToUnregistered (RegisteredAttrData *ad) |
| Moves data set + data src pairs associated to an attribute to the unregistered list. | |
| void | emitValueChanged (RegisteredAttrData *ad, double val) |
| Emits the monitoredValueChanged signal creating a GmResultsTrackedData object. Unit conversion is executed per data src if needed. | |
| void | emitValueChanged (RegisteredAttrData *ad, QString val) |
| Emits the monitoredValueChanged signal creating a GmResultsTrackedData object. | |
| void | emitValueChanged (RegisteredAttrData *ad, const double *valList, int n) |
| Emits the monitoredValueChanged signal creating a GmResultsTrackedData object. Unit conversion is executed per data src if needed. | |
Private Attributes | |
| GmResultsData * | _resultsData |
| The results data object. Used for emitting signals whenever an attribute value is changed for a monitored attribute whose changes should be broadcasted "immediately". | |
| bool | _monitor |
| Is there someone monitoring data changes? | |
| QMap< QString, int > | _resultAttributesMap |
| Map storing for each registered attribute name its id on the _resultAttributes list. | |
| QtPtrList< RegisteredAttrData > | _resultAttributes |
| A list storing for each registered result attribute its data. Might contain "holes" due to unregistered attributes. The list "owns" the stored pointers thanks to the true value passed on the list constructor. | |
| QMap< QString, QVector< QPair< GmResultsDataSet *, GmAttributeResultsDataSrc * > > > | _unregisteredAttributes |
| A map storing for each unregistered attribute name, the set of dataSet + dataSrc pairs referencing this attribute. | |
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 | |
| QObject * | sender () 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 | |
A class used to host the metadata and the values for all attributes added to the results data. This includes the attributes referenced by result data sets and attributes created by the progress stats classes, also managing their correspondence. It also controls which attributes are being monitored and among those, which of them should have value changes broadcasted "immediately".
Attribute names must be unique. Since most attributes are created by the run progress classes, and those classes already create unique names, this should not be a problem.
Registered attributes are attributes that where created by a call to registerResultAttribute(), either during the orchestration (like any attribute created by the progress stats classes) or before the simulation loading (is there any?)
Unregistered attributes are attributes mentioned in a results data set that where not registered yet.
| int GmAttributeResultsManager::registerResultAttribute | ( | const QObject * | owner, |
| QString | name, | ||
| QString | description, | ||
| Unit | unit, | ||
| int | nlin, | ||
| int | ncol, | ||
| QString | format, | ||
| int | stats ) |
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.
If an attribute with the same name was referenced by a data set, estabilishes the connection between the two, provided that the units match.
| void GmAttributeResultsManager::removeAttributeDataSet | ( | GmResultsDataSet * | dataSet | ) |
Removes from the manager any references to a data set or its child data srcs.
Needed to remove pending references to a data set when it is deleted due to syntax error while loading a data set. The data set is deleted, but previously registered attributes can have a reference to the data set. When later the progress stats items that owns those attributes are deleted, the stale data set may be referenced, leading to an invalid pointer access.