GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmSaveResultsRule.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_SAVE_RESULTS_RULE_H_
25#define _GEMA_SAVE_RESULTS_RULE_H_
26
27#include "gmResultsRule.h"
29#include "gmCoreConfig.h"
30
31#include <QVariant>
32#include <QSet>
33#include <fstream> // std::ofstream
34
36class GmFileIO;
37
38
41{
42public:
43 enum GmSimpleSaveFormat {
44 GM_REPORT,
45 GM_HISTORY,
46 };
47
48 virtual ~GmSaveResultsRule();
49
50 // See commets on the base class
51 virtual GmResultsRuleType type() const { return GM_RESULTS_SAVE_RULE; }
52
53 virtual void print(const GmLogCategory& logger, GmLogLevel level) const;
54
55 virtual bool run(const GmLogCategory& logger);
56
57 static GmSaveResultsRule* loadFromTable(const GmResultsData* data, LuaTable& tab, const GmLogCategory& parseLogger, const GmSimulationData* simData);
58
59private:
60 Q_DISABLE_COPY(GmSaveResultsRule);
61
62 GmSaveResultsRule(QString id, QString description, const QVector<GmResultsDataSet*>& dataSets,
63 const QVector<GmResultsTimeSet*>& timeSets, QString outputFile,
64 const QVariantMap& formatOptions, bool trackObj, const GmSimulationData* simData);
65
66 bool fileIOInit(const GmLogCategory& logger);
67 bool fileIOSave(const GmLogCategory& logger);
68
69 template <class T>
70 void fileIOCheckAndAddDataSrcs(const GmResultsDataSet* dset, GmResultsDataSrcType type, QString typeStr,
71 QSet<QString>& idSet, QVector<const T*>& data, QStringList& groups,
72 bool& tryGroups, bool warn, const GmLogCategory& logger);
73
74 bool simpleInit(const GmLogCategory& logger);
75 bool simpleSave(const GmLogCategory& logger);
76 void simpleWriteReportData (const GmResultsDataSet* dataSet);
77 void simpleWriteHistoryEvalSetHeader(const GmResultsDataSet* dataSet);
78 void simpleWriteHistoryEvalSetData (const GmResultsDataSet* dataSet);
79
87
89 QVariantMap _formatOptions;
91
95
96 std::fstream _simpleFile;
97 GmSimpleSaveFormat _simpleFormat;
100};
101#endif
An object for conducting high level aspects of writing results to export files and / or reading mesh ...
Definition gmFileIO.h:68
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 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
virtual void print(const GmLogCategory &logger, GmLogLevel level) const
Prints the rule description to the appointed logger / level.
Definition gmResultsRule.cpp:145
virtual bool run(const GmLogCategory &logger)=0
The virtual method responsible for executing this rule's actions.
A results rule saving the associated data sets to a file.
Definition gmSaveResultsRule.h:41
bool _fileIoCloseOnTimeSetEnd
"Regression test" flag stating that the file should be closed after the time set last save time....
Definition gmSaveResultsRule.h:94
GmFileIO * _fileIo
The file IO handle for savig operation using a GmFileIO object.
Definition gmSaveResultsRule.h:92
QVariantMap _formatOptions
Table with options specific to the type of saved file.
Definition gmSaveResultsRule.h:89
virtual GmResultsRuleType type() const
Returns the result rule type.
Definition gmSaveResultsRule.h:51
bool _simpleWriteHeader
Controls whether the header should be printed or not for the HISTORY format.
Definition gmSaveResultsRule.h:98
std::fstream _simpleFile
The output file for saving operation using the "simple" model.
Definition gmSaveResultsRule.h:96
QString _simpleSep
The column separator for HISTORY format.
Definition gmSaveResultsRule.h:99
GmSimpleSaveFormat _simpleFormat
The saved format for the output file when using the "simple" model.
Definition gmSaveResultsRule.h:97
ReadyState _fileState
Flag with the output file state.
Definition gmSaveResultsRule.h:90
bool _fileIoSingleTime
Flag stating that the output file should support a single result set.
Definition gmSaveResultsRule.h:93
ReadyState
Definition gmSaveResultsRule.h:81
@ FILE_OK
The file is OK for saving.
Definition gmSaveResultsRule.h:83
@ FILE_INIT_PENDING
The fiel has not been initialized yet.
Definition gmSaveResultsRule.h:82
@ FILE_ERROR
There was an error while initializing the file.
Definition gmSaveResultsRule.h:85
@ FILE_DONE
The file has already been written and closed.
Definition gmSaveResultsRule.h:84
QString _outputFileName
The output file, stored with translated paths.
Definition gmSaveResultsRule.h:88
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
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
GmLogLevel
Available log levels list.
Definition gmLog.h:36
Declaration of the GmResultsDataSrcInfo interface.
GmResultsDataSrcType
The types of data sources stored by a rule.
Definition gmResultsDataSrcInfo.h:33
Declaration of the GmResultsRule class.
GmResultsRuleType
The current available types for a result rule.
Definition gmResultsRule.h:41
@ GM_RESULTS_SAVE_RULE
A save rule.
Definition gmResultsRule.h:42