GemaLib
The GeMA library
Loading...
Searching...
No Matches
gmSimulationLoader.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_SIMULATION_LOADER_H_
25#define _GEMA_SIMULATION_LOADER_H_
26
27#include <QObject>
28#include <QString>
29
30#include <gmLog.h>
31
33
34class GmPluginLoader;
35class GmPluginInfo;
36class GmPath;
37class LuaEnv;
38class LuaTable;
39
40struct lua_State;
41
44{
46
47public:
50
51 void replaceDofileInEnv(LuaEnv& env, bool trackFiles, QString table = "");
53
54 bool setupPlugins(QString pluginDirs);
55
56 bool load(GmSimulationData* simData, QString simFile, bool rsrcFile, LuaEnv* env);
57
58 bool loadSharedEnvironments(GmSimulationData* simData, const QMap<QString, QString>& globalVars,
59 bool redirectPrint, QList<LuaEnv*>& workerEnvList);
60
62 const QMap<QString, QString>& globalVars,
63 lua_State* state, bool redirectPrint, int tid);
64
67
68signals:
69
78 void sectionParsed(QString section, LuaTable& data);
79
80private:
81
83 bool redirectPrint, int tid);
84
85 static int emmitSectionParsed (lua_State* L);
86 static int translateDofilePath(lua_State* L);
87 static QString translateScriptName(void* context, QString scriptName);
88
89 bool loadSimulationInfo(GmSimulationData* simData, LuaTable& globalTab);
90 bool loadModelInfo (GmSimulationData* simData, LuaTable& globalTab);
91 bool loadSolutionInfo (GmSimulationData* simData, LuaTable& globalTab);
92 bool loadResultsInfo (GmSimulationData* simData, LuaTable& globalTab);
93 bool loadSharedBlocks (GmSimulationData* simData, LuaTable& globalTab);
94
98};
99
100#endif
101
Auxiliary class responsible for loading simulation information from a Lua File.
Definition gmSimulationLoader.h:44
void replaceDofileInEnv(LuaEnv &env, bool trackFiles, QString table="")
Utilitary function used to replace the dofile method inside the given environment so that it can tran...
Definition gmSimulationLoader.cpp:102
GmPath * _paths
Object storing information about relevant paths used in the simulation.
Definition gmSimulationLoader.h:96
bool loadModelInfo(GmSimulationData *simData, LuaTable &globalTab)
Loads model data from the Lua table received as a parameter.
Definition gmSimulationLoader.cpp:825
static int translateDofilePath(lua_State *L)
Function called by the Lua script while executing a dofile() call to translate path strings.
Definition gmSimulationLoader.cpp:730
static int emmitSectionParsed(lua_State *L)
Function called by the Lua script to emmit a sectionParsed() signal.
Definition gmSimulationLoader.cpp:703
bool load(GmSimulationData *simData, QString simFile, bool rsrcFile, LuaEnv *env)
Loads data defining the model to be simulated.
Definition gmSimulationLoader.cpp:232
~GmSimulationLoader()
Destructor.
Definition gmSimulationLoader.cpp:82
bool loadSharedEnvironments(GmSimulationData *simData, const QMap< QString, QString > &globalVars, bool redirectPrint, QList< LuaEnv * > &workerEnvList)
Similar to load(), this function creates and prepares the Lua environments needed by worker threads,...
Definition gmSimulationLoader.cpp:356
GmSimulationLoader(GmPath *paths)
Constructor. Receives as a parameter the object used to control application paths.
Definition gmSimulationLoader.cpp:71
bool loadResultsInfo(GmSimulationData *simData, LuaTable &globalTab)
Loads results configuration data from the Lua table received as a parameter.
Definition gmSimulationLoader.cpp:857
GmPluginLoader * _pluginLoader
Plugin loader.
Definition gmSimulationLoader.h:97
void sectionParsed(QString section, LuaTable &data)
Signal emmited whenever a model section has been parsed from the Lua file.
bool loadSharedBlocks(GmSimulationData *simData, LuaTable &globalTab)
Loads shared block code from the set of files containing shared blocks stored in the given Lua table.
Definition gmSimulationLoader.cpp:874
bool loadSimulationInfo(GmSimulationData *simData, LuaTable &globalTab)
Loads simulation data from the Lua environment.
Definition gmSimulationLoader.cpp:769
bool loadSolutionInfo(GmSimulationData *simData, LuaTable &globalTab)
Loads solution data from the Lua table received as a parameter.
Definition gmSimulationLoader.cpp:841
GmPluginLoader * pluginLoader() const
Returns the plugin loader.
Definition gmSimulationLoader.h:66
LuaEnv * loadSharedEnv(GmSimulationData *simData, const QMap< QString, QString > &globalVars, bool redirectPrint, int tid)
Worker function for loadSharedEnvironments(), creating the environment for a single thread.
Definition gmSimulationLoader.cpp:598
LuaEnv * prepareSimulationEnvironment(GmSimulationData *simData, QString simFile, const QMap< QString, QString > &globalVars, lua_State *state, bool redirectPrint, int tid)
Creates and prepares the Lua environment that will be used to load the simulation file / shared code ...
Definition gmSimulationLoader.cpp:415
static QString translateScriptName(void *context, QString scriptName)
Callback called by the replaced dofile from LuaEnv to adjust the given script name for use in error m...
Definition gmSimulationLoader.cpp:749
QString translatePath(QString path)
Utilitary function used to translate macros in a path, replacing them by the appropriate location.
Definition gmSimulationLoader.cpp:159
GmLogCategory _logger
The logger object used to emmit messages.
Definition gmSimulationLoader.h:95
bool setupPlugins(QString pluginDirs)
Setup plugins, loading information from available options.
Definition gmSimulationLoader.cpp:171
Q_OBJECTQ_OBJECT