GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
GmSaveResultsRule Class Reference

A results rule saving the associated data sets to a file. More...

#include <gmSaveResultsRule.h>

Inheritance diagram for GmSaveResultsRule:
Collaboration diagram for GmSaveResultsRule:

Public Types

enum  GmSimpleSaveFormat { GM_REPORT , GM_HISTORY }
 

Public Member Functions

virtual ~GmSaveResultsRule ()
 Destructor.
 
virtual GmResultsRuleType type () const
 Returns the result rule type.
 
virtual void print (const GmLogCategory &logger, GmLogLevel level) const
 Prints the rule description to the appointed logger / level.
 
virtual bool run (const GmLogCategory &logger)
 Saves the data specified by the associated data sets to the specified output file.
 
- Public Member Functions inherited from GmResultsRule
virtual ~GmResultsRule ()
 Destructor.
 
QString id () const
 Returns the result rule name.
 
QString description () const
 Returns the result rule description.
 
const QVector< GmResultsDataSet * > & dataSets () const
 Returns the list of data sets acted upon by this rule.
 
const QVector< GmResultsTimeSet * > & timeSets () const
 Returns the list of time sets defining when this rule should be acted upon.
 
bool hasTimeSet () const
 Returns true if this rule is associated with a time set.
 

Static Public Member Functions

static GmSaveResultsRuleloadFromTable (const GmResultsData *data, LuaTable &tab, const GmLogCategory &parseLogger, const GmSimulationData *simData)
 Parses either a save rule definition from the given Lua table, returning a save rule object.
 

Private Types

enum  ReadyState { FILE_INIT_PENDING , FILE_OK , FILE_DONE , FILE_ERROR }
 

Private Member Functions

 Q_DISABLE_COPY (GmSaveResultsRule)
 
 GmSaveResultsRule (QString id, QString description, const QVector< GmResultsDataSet * > &dataSets, const QVector< GmResultsTimeSet * > &timeSets, QString outputFile, const QVariantMap &formatOptions, bool trackObj, const GmSimulationData *simData)
 Constructor.
 
bool fileIOInit (const GmLogCategory &logger)
 Prepares the output file to be written using data srcs from the associated data sets. File saving is done with the GmFileIO class.
 
bool fileIOSave (const GmLogCategory &logger)
 Saves the current data to the previously prepared output file using the GmFileIO class. Uses the time attribute as the current time. No mesh changing is supported.
 
template<class T >
void fileIOCheckAndAddDataSrcs (const GmResultsDataSet *dset, GmResultsDataSrcType type, QString typeStr, QSet< QString > &idSet, QVector< const T * > &data, QStringList &groups, bool &tryGroups, bool warn, const GmLogCategory &logger)
 Helper function useed by fileIOInit() to check the data srcs of the given type from the given data set and add them to the given data vector.
 
bool simpleInit (const GmLogCategory &logger)
 Prepares the output file to be written using the simple file format.
 
bool simpleSave (const GmLogCategory &logger)
 Saves current data to the output file using the simple file format.
 
void simpleWriteReportData (const GmResultsDataSet *dataSet)
 
void simpleWriteHistoryEvalSetHeader (const GmResultsDataSet *dataSet)
 
void simpleWriteHistoryEvalSetData (const GmResultsDataSet *dataSet)
 

Private Attributes

QString _outputFileName
 The output file, stored with translated paths.
 
QVariantMap _formatOptions
 Table with options specific to the type of saved file.
 
ReadyState _fileState
 Flag with the output file state.
 
GmFileIO_fileIo
 The file IO handle for savig operation using a GmFileIO object.
 
bool _fileIoSingleTime
 Flag stating that the output file should support a single result set.
 
bool _fileIoCloseOnTimeSetEnd
 "Regression test" flag stating that the file should be closed after the time set last save time. Needed for file comparison at the orchestration.
 
std::fstream _simpleFile
 The output file for saving operation using the "simple" model.
 
GmSimpleSaveFormat _simpleFormat
 The saved format for the output file when using the "simple" model.
 
bool _simpleWriteHeader
 Controls whether the header should be printed or not for the HISTORY format.
 
QString _simpleSep
 The column separator for HISTORY format.
 

Additional Inherited Members

- Protected Member Functions inherited from GmResultsRule
 GmResultsRule (QString id, QString description, const QVector< GmResultsDataSet * > &dataSets, const QVector< GmResultsTimeSet * > &timeSets, bool trackObj, const GmSimulationData *simData)
 Constructor. The rule does NOT own the data sets and time sets.
 
- Static Protected Member Functions inherited from GmResultsRule
static bool fillCommonFields (const GmResultsData *data, LuaTable &tab, const GmLogCategory &logger, QString &id, QString &description, QVector< GmResultsDataSet * > &dataSets, QVector< GmResultsTimeSet * > &timeSets, bool &trackObj)
 Helper function for the loadFromTable functions from derived classes. Parses the common fields for every result rule from the given Lua table. The logger is used to emmit messages during rule parsing. The data object is used to find data sets and time sets on the results data object.
 
- Protected Attributes inherited from GmResultsRule
QString _id
 The save rule id (name)
 
QString _description
 A description of the save rule.
 
QVector< GmResultsDataSet * > _dataSets
 The list of associated data sets.
 
QVector< GmResultsTimeSet * > _timeSets
 The list of associated time sets.
 
const GmSimulationData_simData
 The simulation data object.
 
int _itemId
 The run progress item id for result rules of this kind (subclass: save rules, print rules or monitor rules)

 
int _objItemId
 The run progress item for this object if the user requested to monitor the time for this specific result rule.
 

Detailed Description

A results rule saving the associated data sets to a file.

Member Enumeration Documentation

◆ ReadyState

Enumerator
FILE_INIT_PENDING 

The fiel has not been initialized yet.

FILE_OK 

The file is OK for saving.

FILE_DONE 

The file has already been written and closed.

FILE_ERROR 

There was an error while initializing the file.

Member Function Documentation

◆ fileIOInit()

bool GmSaveResultsRule::fileIOInit ( const GmLogCategory & logger)
private

Prepares the output file to be written using data srcs from the associated data sets. File saving is done with the GmFileIO class.

If we have multiple data sets, we must make sure that they are sharing the same mesh. For each data set, if it contains eval sets, they will be ignored unless the eval set is a cell group. At present, either the full mesh or a cell group will be always considered. If multiple eval sets reference different cell groups, the groups will be ignored. If one eval set references a set of groups but the others reference the whole mesh, the set of groups will be used. If a data src appears in multiple data sets, only its first appearence will be considered. Attribute data sets are ignored. User transformations applied to data srcs are ignored.

◆ loadFromTable()

GmSaveResultsRule * GmSaveResultsRule::loadFromTable ( const GmResultsData * data,
LuaTable & tab,
const GmLogCategory & parseLogger,
const GmSimulationData * simData )
static

Parses either a save rule definition from the given Lua table, returning a save rule object.

The parseLogger is used to emmit messages during rule parsing.

◆ print()

void GmSaveResultsRule::print ( const GmLogCategory & logger,
GmLogLevel level ) const
virtual

Prints the rule description to the appointed logger / level.

Reimplemented from GmResultsRule.

◆ run()

bool GmSaveResultsRule::run ( const GmLogCategory & logger)
virtual

Saves the data specified by the associated data sets to the specified output file.

Implements GmResultsRule.

◆ type()

virtual GmResultsRuleType GmSaveResultsRule::type ( ) const
inlinevirtual

Returns the result rule type.

Implements GmResultsRule.


The documentation for this class was generated from the following files: