GemaCoreLib
The GeMA Core library
Public Member Functions | Private Member Functions | Private Attributes | List of all members
GmSimulationData Class Reference

Auxiliar class used to store the complete set of simulation data. More...

#include <gmSimulationData.h>

Collaboration diagram for GmSimulationData:
Collaboration graph
[legend]

Public Member Functions

 GmSimulationData (GmPluginLoader *loader, const GmPath *paths, const QVariantMap &configConstants, const QVariantMap &configOptions)
 Constructor. Must be followed by a calls to setSimulationGlobalInfo() and init().
 
 ~GmSimulationData ()
 Destructor.
 
void init ()
 Initializes the simulation data. Must be called AFTER the initialization of _options by a call to setSimulationGlobalInfo() More...
 
void clearData ()
 Calls clear for the objects returned by modelData(), solutionData() and resultsData()
 
QString name () const
 Returns the simulation name.
 
QString description () const
 Returns the simulation description.
 
const QStringListloadedFiles () const
 Returns the list of loaded files for this simulation.
 
void setSimulationGlobalInfo (QString name, QString description, QVariantMap &constants, QVariantMap &options)
 Updates the simulation global attributes: name & description.
 
void setLoadedFiles (const QStringList &loadedFiles)
 Updates the list of loaded files for this simulation.
 
void setSharedCode (QString sharedCode)
 Updates the shared code.
 
GmModelDatamodelData () const
 Returns the model data associated to this simulation.
 
GmSolutionDatasolutionData () const
 Returns the solution definition associated to this simulation.
 
GmResultsDataresultsData () const
 Returns the results configuration associated to this simulation.
 
QString sharedCode () const
 Returns the shared code associated to this simulation.
 
GmPluginLoaderloader () const
 Returns the plugin loader to allow for plugins to load other plugins.
 
const GmPathpaths () const
 Returns the object storing information for path macro susbstitution.
 
void printInfo ()
 Prints information about the simulation. More...
 
bool cancelRequested () const
 Do we have a pending request to cancel the simulation? More...
 
GmThreadManagerthreadManager () const
 Returns a pointer to the configured thread manager.
 
GmTaskManagertaskManager () const
 Returns a pointer to the configured task manager.
 
QtHardwareInfo * hwInfo () const
 Returns some usefull information about the execution hardware.
 
double currentTime () const
 Returns the current simulation time in the current time unit.
 
double previousTime () const
 Returns the previous simulation time in the current time unit.
 
double currentTime (const Unit &desiredUnit) const
 Returns the current time, optionally converted to the desired unit (if different from Unit()). More...
 
double previousTime (const Unit &desiredUnit) const
 Returns the previous time, optionally converted to the desired unit (if different from Unit()). More...
 
const UnittimeUnit () const
 Returns the unit in which the current time is stored.
 
void setCurrentTime (double time, bool updatePrev=true)
 Updates the current time. More...
 
void setPreviousTime (double time)
 Updates the previous time.
 
void setCurrentTimeUnit (const Unit &unit)
 Updates the current time unit.
 
const QVariantoptionValue (const QString &name) const
 Returns a reference to the given option value. Looks for the given name first in the data set read from the Simulation model. Next tries the configuration file. If not found in either, returns a reference to an empty (static) QVariant.
 
QVariant optionValue (const QString &name, const QVariant &defValue) const
 Returns the given option value. Looks for the given name first in the data set read from the Simulation model. Next tries the configuration file. If not found in either, returns the given default value.
 
const QVariantconstantValue (const QString &name) const
 Returns a reference to the given constant value. Looks for the given name first in the data set read from the Simulation model. Next tries the configuration file. If not found in either, returns a reference to an empty (static) QVariant.
 
QVariant constantValue (const QString &name, const QVariant &defValue) const
 Returns the given constant value. Looks for the given name first in the data set read from the Simulation model. Next tries the configuration file. If not found in either, returns the given default value.
 
const QVariantMap & simulationOptions () const
 Returns the map with options read from the simulation. More...
 
const QVariantMap & simulationConstants () const
 Returns the map with constants read from the simulation. More...
 
const QVariantMap & configOptions () const
 Returns the map with options read from the config file. More...
 
const QVariantMap & configConstants () const
 Returns the map with constants read from the config file. More...
 

Private Member Functions

QString variantToString (const QVariant &v)
 Returns a string representing the given variant.
 
void printMapValues (const GmLogCategory &logger, const QVariantMap &map, const QVariantMap &configMap)
 Prints the set of values stored on the given maps to the logger.
 
const QVariantmapValue (const QString &name, const QVariantMap &map, const QVariantMap &configMap) const
 Returns a reference to the given map value. Looks for the given name first in the data set read from the first map. Next tries the configuration map. If not found in either, returns a reference to an empty (static) QVariant.
 
QVariant mapValue (const QString &name, const QVariantMap &map, const QVariantMap &configMap, const QVariant &defValue) const
 Returns the given map value. Looks for the given name first in the data set read from the first map. Next tries the configuration map. If not found in either, returns the given default value.
 

Private Attributes

QString _name
 Simulation name.
 
QString _description
 Simulation description.
 
QStringList _loadedFiles
 The set of Lua files that where loaded for this simulation.
 
QVariantMap _constants
 The map with constants defined in the simulation section.
 
QVariantMap _options
 The map with options defined in the simulation section.
 
const QVariantMap & _configConstants
 The map with constants defined in the configuration file.
 
const QVariantMap & _configOptions
 The map with options defined in the configuration file.
 
GmModelData_model
 Model data.
 
GmSolutionData_solution
 Solution method data.
 
GmResultsData_results
 Results configuration data.
 
QString _sharedCode
 The shared code for setting the Lua environment for worker threads.
 
QtHardwareInfo * _hwInfo
 Some usefull information about the execution hardware.
 
QtGlobalMemUsage * _initMemoryInfo
 The global memory usage pattern before loading the simulation data.
 
GmThreadManager_threadManager
 The configured thread manager.
 
GmTaskManager_taskManager
 The configured task manager.
 
GmPluginLoader_loader
 The application plugin manager.
 
const GmPath_paths
 Object storing the set of important paths for path macro substitution.
 
double _currentTime
 The current simulation time.
 
double _prevTime
 The previous simulation time.
 
Unit _timeUnit
 The current simulation time unit.
 

Detailed Description

Auxiliar class used to store the complete set of simulation data.

Member Function Documentation

◆ cancelRequested()

bool GmSimulationData::cancelRequested ( ) const
inline

Do we have a pending request to cancel the simulation?

Returns the information stored on the thread manager, and so, can only be called after init() has been called. Effective only AFTER the simulation started running. Also check the GmSimulationDataCheckForCancelation() macro at gmSimulationDataCancelCheck.h.

◆ configConstants()

const QVariantMap& GmSimulationData::configConstants ( ) const
inline

Returns the map with constants read from the config file.

Not for general use (used by the loader only). Use the constantValue() method instead.

◆ configOptions()

const QVariantMap& GmSimulationData::configOptions ( ) const
inline

Returns the map with options read from the config file.

Not for general use (used by the loader only). Use the optionValue() method instead.

◆ currentTime()

double GmSimulationData::currentTime ( const Unit desiredUnit) const

Returns the current time, optionally converted to the desired unit (if different from Unit()).

Returns -1.0 if there is no conversion between the current time unit and the desired unit

◆ init()

void GmSimulationData::init ( )

Initializes the simulation data. Must be called AFTER the initialization of _options by a call to setSimulationGlobalInfo()

Creates the thread & task managers. Also sets config options for the shape functions module.

◆ previousTime()

double GmSimulationData::previousTime ( const Unit desiredUnit) const

Returns the previous time, optionally converted to the desired unit (if different from Unit()).

Returns -1.0 if there is no conversion between the previous time unit and the desired unit

◆ printInfo()

void GmSimulationData::printInfo ( )

Prints information about the simulation.

For allowing the user to decide which information should be printed, four different loggers are used: gema.simInfo gema.modelInfo, gema.solutionInfo and gema.resultsInfo

◆ setCurrentTime()

void GmSimulationData::setCurrentTime ( double  time,
bool  updatePrev = true 
)
inline

Updates the current time.

If updatePrev is set to true, the previous time will be updated to the current time (before the current time update), unless time is equal to 0.0 when the previous time will also be set to 0.0. When set to false, the previous time is not changed.

◆ simulationConstants()

const QVariantMap& GmSimulationData::simulationConstants ( ) const
inline

Returns the map with constants read from the simulation.

Not for general use (used by the loader only). Use the constantValue() method instead.

◆ simulationOptions()

const QVariantMap& GmSimulationData::simulationOptions ( ) const
inline

Returns the map with options read from the simulation.

Not for general use (used by the loader only). Use the optionValue() method instead.


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