GemaCoreLib
The GeMA Core library
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 
32 #include <luaTable.h>
33 
36 {
37 public:
38  GmProcess(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
39  virtual ~GmProcess();
40 
41  // Comments on the base class
42  virtual const char* pluginCategory() const { return GM_PLUGIN_PROCESS; }
43 
44  virtual bool loadPrivateData(LuaTable& table);
45  virtual void printParameters(const GmLogCategory& logger);
46 
50  virtual void loadFunctions(LuaTable& table) = 0;
51 
53  virtual QStringList functionList() const = 0;
54 
55 protected:
62  template <class T> void registerFunctions(LuaTable& table, typename GmProcessMethodRedirector<T>::MethodRegistry* methods, bool enableLogging = true)
63  {
64  lua_State* L = table.env()->state();
65  table.push();
66  GmProcessMethodRedirector<T>::registerMethods(L, methods, (T*)this, logger(), enableLogging);
67  lua_pop(L, 1);
68  }
69 
77  {
78  QStringList list;
79  typename GmProcessMethodRedirector<T>::MethodRegistry* r; //Linux needs this
80  for(r = methods; r->_name; ++r)
81  list.append(r->_name);
82  return list;
83  }
84 
85 };
86 
87 #endif
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:76
static void registerMethods(lua_State *L, struct MethodRegistry *methods, T *obj, const GmLogCategory &logger, bool enableLogging)
Registra na tabela contida na pilha as funções contidas em methods. Obj deve conter ponteiro para o o...
Definition: gmProcessMethodRedirector.h:60
virtual bool loadPrivateData(LuaTable &table)=0
Function called by the model loader to give the object acess to it's private parameters....
Declaration of the GmPluginObject base class.
lua_State * state()
virtual const GmLogCategory & logger() const
Returns the internal logger used by the plugin to emmit messages.
Definition: gmPluginObject.h:85
Declaration of the GmProcessMethodRedirector class.
Classe auxiliar para registro dos nomes e métodos a serem chamados.
Definition: gmProcessMethodRedirector.h:44
void registerFunctions(LuaTable &table, typename GmProcessMethodRedirector< T >::MethodRegistry *methods, bool enableLogging=true)
Helper function to make it very easy to implement loadFunctions()
Definition: gmProcess.h:62
Auxiliar class used to store the complete set of simulation data.
Definition: gmSimulationData.h:51
#define GM_PLUGIN_PROCESS
Plugin implements processes.
Definition: gmPluginCategory.h:31
void append(const T &value)
virtual void printParameters(const GmLogCategory &logger)=0
Asks the object to print all of its parameters using the provided logger.
Definition: gmPluginObject.cpp:62
Declaration of macros for standard plugin categories.
Base interface class for all object plugins.
Definition: gmPluginObject.h:36
#define GMC_API_EXPORT
Macro for controling if the class is being exported (GEMA_CORE_LIB defined) or imported (GEMA_CORE_LI...
Definition: gmCoreConfig.h:35
LuaEnv * env() const
Class representing a category with multiple logging levels.
Definition: gmLog.h:58
Base interface class for Process type plugins.
Definition: gmProcess.h:35
const char * _name
Nome do método exportado.
Definition: gmProcessMethodRedirector.h:45
void push() const
virtual const char * pluginCategory() const
Returns the plugin category.
Definition: gmProcess.h:42