GemaCoreLib
The GeMA Core library
Loading...
Searching...
No Matches
gmProcess.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_PROCESS_H_
25#define _GEMA_PROCESS_H_
26
27#include "gmPluginObject.h"
28#include "gmPluginCategory.h"
29
31#include "gmSimulationData.h"
32
33#include <luaTable.h>
34
36
39{
40public:
41 GmProcess(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
42 virtual ~GmProcess();
43
44 // Comments on the base class
45 virtual const char* pluginCategory() const { return GM_PLUGIN_PROCESS; }
46
47 virtual bool loadPrivateData(LuaTable& table);
48 virtual void printParameters(const GmLogCategory& logger);
49
53 virtual void loadFunctions(LuaTable& table) = 0;
54
56 virtual QStringList functionList() const = 0;
57
58 int createProgressStatsItem(GmRunProgressStats* ps, const char* name);
59
60protected:
68 template <class T> void registerFunctions(LuaTable& table, typename GmProcessMethodRedirector<T>::MethodRegistry* methods, bool noProgressStats = false)
69 {
70 lua_State* L = table.env()->state();
71 table.push();
72 GmProcessMethodRedirector<T>::registerMethods(L, methods, (T*)this, noProgressStats ? NULL : simulationData()->progressStats());
73 lua_pop(L, 1);
74 }
75
83 {
84 QStringList list;
85 typename GmProcessMethodRedirector<T>::MethodRegistry* r; //Linux needs this
86 for(r = methods; r->_name; ++r)
87 list.append(r->_name);
88 return list;
89 }
90
91private:
93};
94
95#endif
Class representing a category with multiple logging levels.
Definition gmLog.h:58
Base interface class for all object plugins.
Definition gmPluginObject.h:37
GmSimulationData * simulationData() const
Returns a reference to the simulation data object keeping global simulation information.
Definition gmPluginObject.h:88
virtual void printParameters(const GmLogCategory &logger)=0
Asks the object to print all of its parameters using the provided logger.
Definition gmPluginObject.cpp:62
virtual bool loadPrivateData(LuaTable &table)=0
Function called by the model loader to give the object acess to it's private parameters....
Base interface class for Process type plugins.
Definition gmProcess.h:39
void registerFunctions(LuaTable &table, typename GmProcessMethodRedirector< T >::MethodRegistry *methods, bool noProgressStats=false)
Helper function to make it very easy to implement loadFunctions()
Definition gmProcess.h:68
virtual void loadFunctions(LuaTable &table)=0
Virtual function that should be implemented by plugins to fill table with the set of functions export...
virtual const char * pluginCategory() const
Returns the plugin category.
Definition gmProcess.h:45
int _processProgressItem
The root progress stats item related to this process.
Definition gmProcess.h:92
QStringList buildFunctionList(typename GmProcessMethodRedirector< T >::MethodRegistry *methods) const
Helper function to make it very easy to implement functionList() and keep it consistent with loadFunc...
Definition gmProcess.h:82
virtual QStringList functionList() const =0
Returns the set of function names exported by this process object.
static void registerMethods(lua_State *L, struct MethodRegistry *methods, T *obj, GmRunProgressStats *ps)
Registra na tabela contida na pilha as funções contidas em methods. Obj deve conter ponteiro para o o...
Definition gmProcessMethodRedirector.h:63
A class used to store time, memory and additional values statistics related to the simulation loading...
Definition gmRunProgressStats.h:42
Auxiliar class used to store the complete set of simulation data.
Definition gmSimulationData.h:55
lua_State * state()
LuaEnv * env() const
void push() const
#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 macros for standard plugin categories.
#define GM_PLUGIN_PROCESS
Plugin implements processes.
Definition gmPluginCategory.h:31
Declaration of the GmPluginObject base class.
Declaration of the GmProcessMethodRedirector class.
Declaration of the GmSimulationData class.
void append(const T &value)
Classe auxiliar para registro dos nomes e métodos a serem chamados.
Definition gmProcessMethodRedirector.h:44
const char * _name
Nome do método exportado.
Definition gmProcessMethodRedirector.h:45