![]() |
GemaCoreLib
The GeMA Core library
|
This class is a simple wrapper over a generic Lua table, provided in the model, that also handles the necessary steps to allow for user provided functions to be callable from multiple simulation threads. More...
#include <gmPluginData.h>
Public Member Functions | |
GmPluginData (const QVariantMap &data) | |
Constructor. Receives as parameter the already validated map with the Lua data converted to a variant map. Lua functions in the root level of the map are replaced by TLS objects in the same manner used by User functions. Only the main thread reference is initialized. Other thread references should be later set by calls to setLuaFunction(). | |
~GmPluginData () | |
Destructor. | |
QString | id () const |
Returns the object id. | |
QString | description () const |
Returns the object description. | |
QString | typeName () const |
Returns the alias with wich this object was created (or PluginData if not created by an alias) | |
QVariant | value (QString field) const |
Returns the value of the stored field as a QVariant. For Lua functions, use luaFunction() instead. | |
LuaFunction * | luaFunction (QString field) const |
Returns the Lua function associated with the named field, for the CURRENT thread, or NULL if the field is not a function. | |
const QVariantMap & | data () const |
Returns the map with stored data. | |
void | setLuaFunction (QString field, int tid, LuaFunction *func) |
Updates the Lua function for the given field and thread id. Takes ownership of the allocated pointer. | |
void | printParameters (const GmLogCategory &logger) const |
Asks the object to print all of its DEFAULT parameters using the provided logger. Additional "plugin" fields are not printed. | |
Private Attributes | |
QVariantMap | _data |
The stored data;. | |
This class is a simple wrapper over a generic Lua table, provided in the model, that also handles the necessary steps to allow for user provided functions to be callable from multiple simulation threads.
Despite its name, this class is NOT a plugin object, and its instances are created by the core library and not by plugins. It is intended to help plugins receive organized sets of data, including user functions that need to be called by the plugin, especially if that can happend from parallel threads.
Conceptually this object could belong either to the model or to the solution group of objects since its contents depends on the target plugin. In practice it is nice to see it loaded BEFORE any plugin object, who might want to reference them, so, as the model is loaded before the solution, the PluginData object ended up in the model.
In the model, PluginData can be created with the "PluginData" section or with aliases registered by plugins in their Lua info files. Aliases are assumed to be unique. The plugin can also register a plugin Lua user function to check the PluginData correctness.
The only standard fields of a PluginData table are its id and description. The model data loader also includes a typeName field that stores the alias with wich the object was created (filled with PluginData if created without an alias)
ATTENTION: In the current implementation, only functions in the first level of the source Lua table are made multi-thread aware by replacing the single LuaFunction reference by a TLS object with a reference per ThreadManager thread (the additional references should be set by calls to setLuaFunction())