24#ifndef _GEMA_RUN_PROGRESS_STATS_H_
25#define _GEMA_RUN_PROGRESS_STATS_H_
59 GM_RUNPROG_TRACK_TIME = 0x0001,
60 GM_RUNPROG_TRACK_MEM = 0x0002,
61 GM_RUNPROG_TRACK_REPORT_AT_END = 0x0004,
62 GM_RUNPROG_TRACK_REPORT_STATS = 0x0008,
63 GM_RUNPROG_TRACK_STATS_MIN = 0x0010,
64 GM_RUNPROG_TRACK_STATS_MAX = 0x0020,
65 GM_RUNPROG_TRACK_STATS_AVG = 0x0040,
66 GM_RUNPROG_TRACK_STATS_TOTAL = 0x0080,
67 GM_RUNPROG_TRACK_STATS_ALL = 0x00F0,
68 GM_RUNPROG_TRACK_ATTR_DEFAULT = 0x0100,
69 GM_RUNPROG_TRACK_DEFAULT = GM_RUNPROG_TRACK_TIME | GM_RUNPROG_TRACK_REPORT_STATS |
70 GM_RUNPROG_TRACK_STATS_ALL,
84 if(item ==
":default")
87 _levelMap[item] = level;
96 static int itemOptionsFromLevel(
QString item,
bool mem =
false,
bool* detailedStats = NULL);
98 int registerItem(
const QObject* owner,
int fatherItemId,
QString name,
int options = GM_RUNPROG_TRACK_DEFAULT,
QString autoId =
"");
99 QString itemName (
int itemId)
const;
100 int findItem (
int fatherItemId,
QString name)
const;
101 bool renameItem (
int itemId,
QString autoId);
104 bool validItemId(
int itemId)
const {
return itemId >= 0 && itemId < _items.listSize() && _items[itemId]; }
106 const QObject* itemOwner(
int itemId)
const;
108 void setItemData(
int itemId,
void* data);
110 void registerNestedItem(
int trackingItemId,
int trackedItemId);
121 QString format,
int statOptions = GM_RUNPROG_TRACK_ATTR_DEFAULT)
123 assert(validItemId(itemId));
124 return registerAttribute(_items[itemId], name, description, unit, nlin, ncol, format, statOptions);
129 int statOptions = GM_RUNPROG_TRACK_ATTR_DEFAULT)
131 return registerAttribute(itemId, name, description, unit, 1, 1, format, statOptions);
137 return registerAttribute(itemId, name, description,
Unit(), 1, 1,
".0f", statOptions);
143 return registerAttribute(itemId, name, description,
Unit(), 0, 0,
"", statOptions);
146 inline int attr(
int itemId,
int attrId)
const;
151 int findAttribute(
int itemId,
QString name)
const;
152 int findAttribute(
int itemId,
int nestedId,
QString name)
const;
154 int autoTimeItemAttribute(
int itemId)
const;
155 int autoMemItemAttribute (
int itemId)
const;
161 void itemStart(
int itemId);
162 void itemEnd (
int itemId);
168 const double*
numericAttributeValue(
int itemId,
int attrId)
const {
return _attrm->resultAttributeBuffer(attr(itemId, attrId)); }
172 void setAttributeValue(
int itemId,
int attrId,
double val) { _attrm->setResultAttributeValue(attr(itemId, attrId), val); }
175 void setAttributeValue(
int itemId,
int attrId,
double val1,
double val2) { _attrm->setResultAttributeValue(attr(itemId, attrId), val1, val2); }
178 void setAttributeValue(
int itemId,
int attrId,
double val1,
double val2,
double val3) { _attrm->setResultAttributeValue(attr(itemId, attrId), val1, val2, val3); }
183 void setAttributeValue(
int itemId,
int attrId,
const double* val) { _attrm->setResultAttributeValue(attr(itemId, attrId), val); }
196 void setAttributeValue(
int itemId,
int attrId,
int val) { _attrm->setResultAttributeValue(attr(itemId, attrId), (
double)val); }
199 void setAttributeValue(
int itemId,
int attrId,
unsigned val) { _attrm->setResultAttributeValue(attr(itemId, attrId), (
double)val); }
205 void setAttributeValue(
int itemId,
int attrId,
const char* val) { _attrm->setResultAttributeValue(attr(itemId, attrId),
QString(val)); }
210 const double* v = _attrm->resultAttributeBuffer(attr(itemId, attrId));
211 _attrm->setResultAttributeValue(attr(itemId, attrId), *v + 1);
217 const double* v = _attrm->resultAttributeBuffer(attr(itemId, attrId));
218 _attrm->setResultAttributeValue(attr(itemId, attrId), *v - 1);
221 void reportStats(
QString finalStatusStr, qint64 runTime);
225 void removeRegisteredItem(
int itemId);
228 void removeRegisteredItems(
QObject* owner);
238 Unit unit,
int nlin,
int ncol,
QString format,
int statOptions);
240 void csvStatsFillReportData (
bool totalOnly,
const QStringList& filters, qint64 runTime,
248 void addReportTraillers()
const;
254 QtPtrList<GmRunProgressStatsItem>
_items;
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
Auxiliar class used to store the complete set of results data for a simulation.
Definition gmResultsData.h:58
A RAII class used to simplify tracking an item with a progressStats object. When the object is create...
Definition gmRunProgressStats.h:268
int _itemId
The item id. -1 if tracking is not necessary.
Definition gmRunProgressStats.h:296
GmRunProgressStats * _ps
The progress stats object. NULL if tracking is not necessary.
Definition gmRunProgressStats.h:295
An alternative implementation of GmRunProgress that when called from a worker thread does nothing.
Definition gmRunProgressStats.h:301
A class used to create formatted reports based on ProgressStats item attribute values.
Definition gmRunProgressReport.h:40
A class used to store time, memory and additional values statistics related to the simulation loading...
Definition gmRunProgressStats.h:42
GmAttributeResultsManager * attrManager() const
Returns the global attribute manager.
Definition gmRunProgressStats.h:149
static Level _defLevel
The default level for entries that are not present on _levelMap.
Definition gmRunProgressStats.h:257
static void setLevelConfiguration(QString item, Level level)
Sets the level configuration for an item. Should be called before item creation. Intended usage is to...
Definition gmRunProgressStats.h:82
void setAttributeValue(int itemId, int attrId, double val1, double val2, double val3)
Sets the value for a vector[3] result attribute identified by its id (returned by registerAttribute()...
Definition gmRunProgressStats.h:178
void setAttributeValue(int itemId, int attrId, double val1, double val2)
Sets the value for a vector[2] result attribute identified by its id (returned by registerAttribute()...
Definition gmRunProgressStats.h:175
GmResultsData * _resultsData
The results data object storing item attributes.
Definition gmRunProgressStats.h:250
QString strAttributeValue(int itemId, int attrId) const
Returns the current value for a string attribute.
Definition gmRunProgressStats.h:165
void setAttributeValue(int itemId, int attrId, const char *val)
Sets the value for a string attribute identified by its id (returned by registerStringAttribute())
Definition gmRunProgressStats.h:205
int registerCounterAttribute(int itemId, QString name, QString description, int statOptions=GM_RUNPROG_TRACK_ATTR_DEFAULT)
Registers a counter attribute, always printed as an integer value.
Definition gmRunProgressStats.h:135
int registerAttribute(int itemId, QString name, QString description, Unit unit, int nlin, int ncol, QString format, int statOptions=GM_RUNPROG_TRACK_ATTR_DEFAULT)
Registers a new value attribute for the given item.
Definition gmRunProgressStats.h:120
bool validItemId(int itemId) const
Returns true if the given id is a valid item id.
Definition gmRunProgressStats.h:104
TrackOptions
Definition gmRunProgressStats.h:58
void setAttributeValue(int itemId, int attrId, const GmMatrix &val)
Sets the value for a matrix valued attribute identified by its id (returned by registerAttribute())....
Definition gmRunProgressStats.h:193
GmAttributeResultsManager * _attrm
The attribute manager (from _resultsData)
Definition gmRunProgressStats.h:251
void setAttributeValue(int itemId, int attrId, int val)
Sets the value for a counter attribute identified by its id (returned by registerCounterAttribute())
Definition gmRunProgressStats.h:196
void setAttributeValue(int itemId, int attrId, double val)
Sets the value for a scalar result attribute identified by its id (returned by registerAttribute())
Definition gmRunProgressStats.h:172
static Level configuredLevel(QString item)
The configured level for the given item. Can be used to choose the appropriate track options dependin...
Definition gmRunProgressStats.h:94
QMap< QString, int > _itemsMap
Maps item names to their position on _items.
Definition gmRunProgressStats.h:255
static Level defLevel()
Returns the default level.
Definition gmRunProgressStats.h:91
int registerStringAttribute(int itemId, QString name, QString description, int statOptions=GM_RUNPROG_TRACK_ATTR_DEFAULT)
Registers a string attribute.
Definition gmRunProgressStats.h:141
int registerScalarAttribute(int itemId, QString name, QString description, Unit unit, QString format, int statOptions=GM_RUNPROG_TRACK_ATTR_DEFAULT)
Registers a scalar attribute.
Definition gmRunProgressStats.h:128
QVector< GmRunProgressReport * > _reports
The set of added reports, owned by the progress object.
Definition gmRunProgressStats.h:258
void setAttributeValue(int itemId, int attrId, QString val)
Sets the value for a string attribute identified by its id (returned by registerStringAttribute())
Definition gmRunProgressStats.h:202
const double * numericAttributeValue(int itemId, int attrId) const
Returns the current value for a numeric attribute.
Definition gmRunProgressStats.h:168
void setAttributeValue(int itemId, int attrId, unsigned val)
Sets the value for a counter attribute identified by its id (returned by registerCounterAttribute())
Definition gmRunProgressStats.h:199
void itemEnd(int itemId)
Notifies the progress object that the operation tied to the given item has just finished.
Definition gmRunProgressStats.cpp:614
QtPtrList< GmRunProgressStatsItem > _items
The set of registered items. Might include NULL entries!
Definition gmRunProgressStats.h:254
Level
Definition gmRunProgressStats.h:47
@ GM_RUNPROG_DISABLED
No statistics at all.
Definition gmRunProgressStats.h:48
@ GM_RUNPROG_DS_DP
Detailed statistics, Detailed printing.
Definition gmRunProgressStats.h:52
@ GM_RUNPROG_NS_SP
Normal statistics, Summary printing. The default if not changed by a call to setLevelConfiguration()
Definition gmRunProgressStats.h:49
@ GM_RUNPROG_DS_SP
Detailed statistics, Summary printing.
Definition gmRunProgressStats.h:51
@ GM_RUNPROG_NS_DP
Normal statistics, Detailed printing.
Definition gmRunProgressStats.h:50
void incAttributeValue(int itemId, int attrId)
Increments the current value of a "counter" attribute, doing the equivalent of attr = attr + 1.
Definition gmRunProgressStats.h:208
GmLogCategory _logger
The logger object used to emit messages when logging to the standard log file.
Definition gmRunProgressStats.h:252
void itemStart(int itemId)
Notifies the progress object that the operation tied to the given item is about to start.
Definition gmRunProgressStats.cpp:580
void setAttributeValue(int itemId, int attrId, const GmVector &val)
Sets the value for a vector valued attribute identified by its id (returned by registerAttribute())....
Definition gmRunProgressStats.h:188
void setAttributeValue(int itemId, int attrId, const double *val)
Sets the value for a multi valued attribute identified by its id (returned by registerAttribute())....
Definition gmRunProgressStats.h:183
static QMap< QString, Level > _levelMap
The map with item level configuration. Filled BEFORE item creation and used to init item levels.
Definition gmRunProgressStats.h:256
void decAttributeValue(int itemId, int attrId)
Decrements the current value of a "counter" attribute, doing the equivalent of attr = attr - 1.
Definition gmRunProgressStats.h:215
An item used to store time, memory and additional values statistics related to the simulation loading...
Definition gmRunProgressStatsItem.h:39
static bool inMainThread()
Is the current thread the main thread? Equivalent to comparing the currentId() with 0.
Definition gmThreadManager.h:174
#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
arma::mat GmMatrix
The basic type for a GeMA matrix object. Currently based on an Armadillo matrix.
Definition gmMatrix.h:38
Declaration of the GmResultsData class.
Declaration of the GmThreadManager class.
arma::vec GmVector
The basic type for a GeMA vector object. Currently based on an Armadillo vector.
Definition gmVector.h:34