GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmResultsData.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
24#ifndef _GEMA_RESULTS_DATA_H_
25#define _GEMA_RESULTS_DATA_H_
26
27#include "gmCoreConfig.h"
28#include "gmLog.h"
29#include "gmVector.h"
30#include "gmMatrix.h"
34
35#include <QString>
36#include <QMap>
37#include <QObject>
38#include <QMutex>
39
43class GmResultsRule;
46
49
51class Unit;
52
53
58{
59 Q_OBJECT
60
61public:
62 GmResultsData(const GmSimulationData* simData);
64
66 void clear();
67
69 const QMap<QString, GmResultsDataSet*>& resultDataSets() const { return _dataSetMap; }
70
72 const QMap<QString, GmResultsTimeSet*>& timeSets() const { return _timeSetMap; }
73
75 const QMap<QString, GmResultsRule*>& resultsRules() const { return _rulesMap; }
76
78 const QVector<GmMonitorResultsRule*>& monitorResultRules() const { return _monitorRules; }
79
80 bool addResultsDataSet(GmResultsDataSet* ds);
81 bool addTimeSet (GmResultsTimeSet* timeSet);
82 bool addResultsRule (GmResultsRule* rule);
83
84 bool evalRules(const QStringList& ruleIds = QStringList(), bool force = false, bool timeManagerPrint = false);
85 void resetEvalAttrValue(int attrId = -1);
86 double nextEvalAttrValue (int attrId, GmResultsTimeManagerEvalMode mode = GM_RTM_ALL, QString timeSet = "");
87 double lastEvalAttrValue (int attrId, GmResultsTimeManagerEvalMode mode = GM_RTM_ALL, QString timeSet = "");
88
90 const GmSimulationData* simulationData() const { return _simData; }
91
93 GmAttributeResultsManager* attributes() const { return _attrManager; }
94
97 {
98 if(!_timeManager)
99 _timeManager = new GmResultsTimeManager(this, _logger);
100 return _timeManager;
101 }
102
104 int nextMonitoredDataSetId() { return _numMonitoredDataSets++; }
105
107 int nextMonitoredDataSrcId() { return _numMonitoredDataSrcs++; }
108
110 int numMonitoredDataSets() const { return _numMonitoredDataSets; }
111
113 int numMonitoredDataSrcs() const { return _numMonitoredDataSrcs; }
114
116 void enableMonitoring() { _monitor = true; _attrManager->enableMonitoring(); }
117
122 QMutex* monitoringMutex() { return &_monitorMutex; }
123
124 void setCurrentTime(double time);
125
126 void printInfo(const GmLogCategory& logger);
127
129 const GmLogCategory& logger() const { return _logger; }
130
131signals:
132
141 void monitoredValueChanged(int trackId, const GmResultsTrackedData& value, bool waitForMore);
142
145
147 void monitoredIndexChanged(int dataSetId, const GmResultsTrackedIndexData& value);
148
150 void monitoredAttributeInfoChanged(int trackId, int dataSetId, QString name, QString description,
151 int type, QString unit, int nlin, int ncol, QString format);
152
153
154private:
156 bool _monitor;
157
169
177
180
183
185};
186
187#endif
188
A class implementing the GmResultsDataSrcInfo interface, storing the metadata and id for a result dat...
Definition gmAttributeResultsDataSrc.h:41
A class used to host the metadata and the values for all attributes added to the results data....
Definition gmAttributeResultsManager.h:60
Class representing a category with multiple logging levels.
Definition gmLog.h:58
A results rule used to send the associated data sets to the monitor server thread.
Definition gmMonitorResultsRule.h:34
Auxiliar class used to store the complete set of results data for a simulation.
Definition gmResultsData.h:58
int nextMonitoredDataSrcId()
Returns the next available monitored data src id and increments the number of monitored data srcs.
Definition gmResultsData.h:107
int numMonitoredDataSrcs() const
Returns the number of monitored data srcs (data srcs inside data sets that are associated to a monito...
Definition gmResultsData.h:113
void monitoredValueChangedDone()
A signal emitted to signalize that a sequence of monitored value changes has ended.
void enableMonitoring()
Enables the emission of the monitorValueChanged() family of signals.
Definition gmResultsData.h:116
GmResultsTimeManager * timeManager() const
Returns the results time manager.
Definition gmResultsData.h:96
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.
int numMonitoredDataSets() const
Returns the number of monitored data sets (data sets associated to a monitor rule).
Definition gmResultsData.h:110
const QMap< QString, GmResultsDataSet * > & resultDataSets() const
Returns a const reference to the results data set map.
Definition gmResultsData.h:69
const QMap< QString, GmResultsRule * > & resultsRules() const
Returns a const reference to the results rules map.
Definition gmResultsData.h:75
int _timeAttributeId
The id stored in _attrManager for the standard "time" attribute.
Definition gmResultsData.h:175
int _numMonitoredDataSets
The number of data sets that are being monitored by a monitor results rule.
Definition gmResultsData.h:178
QMutex _monitorMutex
A mutex shared with the monitor thread to protect access to rule metadata, AFTER the model loading....
Definition gmResultsData.h:168
QVector< GmMonitorResultsRule * > _monitorRules
Subset of _rulesMap, storing only monitor result rules.
Definition gmResultsData.h:173
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 o...
int _numMonitoredDataSrcs
The sum of the number of data sources in the set of monitored data sets.
Definition gmResultsData.h:179
const QVector< GmMonitorResultsRule * > & monitorResultRules() const
Returns a const reference to the monitor results rules vector.
Definition gmResultsData.h:78
const GmLogCategory & logger() const
Returns the internal logger used by rules to emit messages.
Definition gmResultsData.h:129
int _evalRulesItem
The progress item for evalRules() calls.
Definition gmResultsData.h:181
void monitoredIndexChanged(int dataSetId, const GmResultsTrackedIndexData &value)
The signal emitted when there is a new index data available for a monitor rule.
QMap< QString, GmResultsRule * > _rulesMap
Map storing save, print and monitor result rules, keyed by rule id.
Definition gmResultsData.h:172
const GmSimulationData * simulationData() const
Returns the associated simulation data object.
Definition gmResultsData.h:90
GmResultsTimeManager * _timeManager
The results time manager. Mutable for construction on first use.
Definition gmResultsData.h:176
QMap< QString, GmResultsDataSet * > _dataSetMap
Map storing result data set, keyed by data set id.
Definition gmResultsData.h:170
bool _monitor
Is there someone monitoring data changes?
Definition gmResultsData.h:156
int nextMonitoredDataSetId()
Returns the next available monitored data set id and increments the number of monitored data sets.
Definition gmResultsData.h:104
const GmSimulationData * _simData
The simulation data object.
Definition gmResultsData.h:155
GmAttributeResultsManager * attributes() const
Returns the attribute manager.
Definition gmResultsData.h:93
GmAttributeResultsManager * _attrManager
The attribute manager storing attribute values + their matching with data sources.
Definition gmResultsData.h:174
GmLogCategory _logger
The logger object used by rules to emit messages.
Definition gmResultsData.h:184
QMutex * monitoringMutex()
Returns the mutex needed to protect access to rule metadata AFTER the model loading....
Definition gmResultsData.h:122
QMap< QString, GmResultsTimeSet * > _timeSetMap
Map storing time sets, keyed by rule id.
Definition gmResultsData.h:171
int _evalRulesCallCounterAttribute
The counter attribute used to track the number of calls to evalRules()
Definition gmResultsData.h:182
const QMap< QString, GmResultsTimeSet * > & timeSets() const
Returns a const reference to the results time set map.
Definition gmResultsData.h:72
A set storing what should be exported (saved / printed / monitored) by the result rule classes.
Definition gmResultsDataSet.h:58
A result rule represents an action that will be executed over one or more data sets at the moments (t...
Definition gmResultsRule.h:56
Collects all the time data from several TimeSet objects, controlling the next time "moments" (time,...
Definition gmResultsTimeManager.h:48
A rule specifying the execution moments (time, iterations, etc) that a result rule should be executed...
Definition gmResultsTimeSet.h:39
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
Declaration of the GmAttributeResultsDataSrcInfo class.
Declaration of the GmAttributeResultsManager class.
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 support functions and macros for information logging.
Declaration of the GmMatrix class.
Declaration of the GmResultsTimeManager class.
GmResultsTimeManagerEvalMode
The evaluation mode for GmResultsTimeManager::nextEvalAttrValue() and lastEvalAttrValue() calls.
Definition gmResultsTimeManager.h:36
@ GM_RTM_ALL
Next and last queries will check both the interval and moment time set definitions.
Definition gmResultsTimeManager.h:39
Declaration of the GmVector class.
A tracked data value. Can be either a double vector or a string. Thanks to the implicitly shared natu...
Definition gmResultsTrackedData.h:39
The index data for a result rule, storing "evaluation point" data for node, cell or gauss based indic...
Definition gmResultsTrackedData.h:65