GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmRunProgressReport.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_RUN_PROGRESS_REPORT_H_
25#define _GEMA_RUN_PROGRESS_REPORT_H_
26
27#include "gmResultsData.h"
28#include <unit.h>
29#include <qtPtrList.h>
30
31class GmResultsData;
32class Unit;
36
40{
41public:
42
49
51 using ValueFunctionT = std::function<void(GmRunProgressReport* report, int col, int itemId, void* itemUserData)>;
52
53 GmRunProgressReport(GmResultsData* resultsData, QString fileName, const GmLogCategory& logger);
54
56
58 QString fileName() const { return _fileName; }
59
61 void setTitle(QString title) { _title = title; }
62
64 void addItemDescription(QString description) { _itemDescriptions.append(description); }
65
66 int addColumn(int itemId, int attrId, QString colTitle="", bool autoTimeUnit = false, int width = -1, ColAlignment align = GM_RUNPROG_REPORT_AUTO, int attrDim = -1);
67 int addColumn(QString colTitle, QString colUnit, QString fmt = "", bool autoTimeUnit = false, int width = -1, ColAlignment align = GM_RUNPROG_REPORT_RIGHT);
68
69 void setColumnValueFunction(int col, const ValueFunctionT& f);
70 void setColumnIgnoreOnZero(int col);
71
72 void setColumnValue(int col, int val);
73 void setColumnValue(int col, double val);
74 void setColumnValue(int col, const double* val, int size);
75 void setColumnValue(int col, QString str);
76
77 void saveReportLine(int itemId, void* itemUserData);
78 void saveTrailler(QString traillerStr);
79
80private:
81 Q_DISABLE_COPY(GmRunProgressReport);
82
83 void saveReportHeader();
84 void saveFormattedHeader(bool title);
85 void saveFormattedLine();
86 void saveFormattedTrailler(QString traillerStr);
87
88 void saveCsvHeader(bool title);
89 void saveCsvLine();
90 void saveCsvTrailler(QString traillerStr);
91
106
107 QStringList prepareTitle (QString title, QString unit) const;
108 QStringList splitMultilineStr(QString title, bool trim) const;
109 int findColumnWidth (const ColData& colData, int dataSize) const;
110
111 QString alignStr (QString str, int width, ColAlignment align) const;
112
117 bool _csv;
118 FILE* _file;
123};
124
125#endif
126
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 class used to create formatted reports based on ProgressStats item attribute values.
Definition gmRunProgressReport.h:40
QString _fileName
Output file name.
Definition gmRunProgressReport.h:116
QVector< ColData > _columns
The set of report columns.
Definition gmRunProgressReport.h:121
QStringList _itemDescriptions
Item descriptions, saved between the title and the column headers.
Definition gmRunProgressReport.h:120
ColAlignment
Definition gmRunProgressReport.h:43
@ GM_RUNPROG_REPORT_CENTER
Column data is aligned to the center.
Definition gmRunProgressReport.h:45
@ GM_RUNPROG_REPORT_AUTO
Column data is aligned according to the data type as defined by the associated result attribute.
Definition gmRunProgressReport.h:47
@ GM_RUNPROG_REPORT_LEFT
Column data is aligned to the left (default for strings)
Definition gmRunProgressReport.h:44
@ GM_RUNPROG_REPORT_RIGHT
Column data is aligned to the right (default for numbers)
Definition gmRunProgressReport.h:46
void addItemDescription(QString description)
Adds an item description to the report.
Definition gmRunProgressReport.h:64
QString fileName() const
Returns the output file name for this report.
Definition gmRunProgressReport.h:58
bool _csv
Save to csv file? If not, a formatted text file will be saved.
Definition gmRunProgressReport.h:117
GmRunProgressStats * _ps
The ProgressStats object that owns this report.
Definition gmRunProgressReport.h:114
const GmLogCategory & _logger
The logger used to display error messages.
Definition gmRunProgressReport.h:115
std::function< void(GmRunProgressReport *report, int col, int itemId, void *itemUserData)> ValueFunctionT
The column value function type.
Definition gmRunProgressReport.h:51
GmResultsData * _resultsData
The results data object storing data attributes.
Definition gmRunProgressReport.h:113
int _numHeaderRows
The number of rows needed for the header. Set to -1 if there was an error creating the save file.
Definition gmRunProgressReport.h:122
QString _title
The report title.
Definition gmRunProgressReport.h:119
void setTitle(QString title)
Adjusts the report title.
Definition gmRunProgressReport.h:61
FILE * _file
The output file handle.
Definition gmRunProgressReport.h:118
A class used to store time, memory and additional values statistics related to the simulation loading...
Definition gmRunProgressStats.h:42
An item used to store time, memory and additional values statistics related to the simulation loading...
Definition gmRunProgressStatsItem.h:39
#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 the GmResultsData class.
Definition gmRunProgressReport.h:93
int _attrDim
A dimension index used to select a vector attribute dimension to display, as a scalar,...
Definition gmRunProgressReport.h:101
bool _ignoreOnZero
If set to true, a zero value will be printed as an empty column.
Definition gmRunProgressReport.h:102
ColAlignment _align
The column alignment. AUTO values should already have been translated when stored.
Definition gmRunProgressReport.h:97
int _attrId
The attribute index providing the column data or -1 if given manually.
Definition gmRunProgressReport.h:100
QStringList _title
The column title, split in multiple rows, if needed with added unit row if unit is not empty.
Definition gmRunProgressReport.h:94
QString _fmt
The format string used to convert numeric values.
Definition gmRunProgressReport.h:98
QString _value
The formatted column value when manually provided.
Definition gmRunProgressReport.h:103
ValueFunctionT _colValueFunction
A function that, when present, is called by saveReportLine() to update the column value.
Definition gmRunProgressReport.h:104
int _autoTime
Should we try to auto adjust time unit according to the value? If different from -1,...
Definition gmRunProgressReport.h:99
QString _unit
The column unit.
Definition gmRunProgressReport.h:95
int _width
The column width.
Definition gmRunProgressReport.h:96