|
AGXDynamics
2.31.1.0
|
#include <ScriptManager.h>
Inheritance diagram for agxLua::ScriptManager:Classes | |
| class | RegisterScriptPluginProxy |
| Class for instantiating a plugin that is loaded from a dynamic library. More... | |
| class | ScriptPlugin |
Public Types | |
| enum | Priority { HIGHEST_PRIORITY = 2147483647, LOWEST_PRIORITY = 10000, DEFAULT_PRIORITY = 1073741824 } |
| Specifies the ranges of the priority which can be assigned to a singleton at the time of creation. More... | |
Public Member Functions | |
| void | addScriptPlugin (ScriptPlugin *) |
| Add A script-plugin to the list of registered plugins. More... | |
| bool | doFile (const std::string &path) |
| Execute a lua script file. The file will be searched for in the specified filepath. More... | |
| bool | doGarbageCollection (agx::Real now=agx::Real(-1.0)) |
| Request garbage collection in lua, if currentTime < 0 then do it immediately. More... | |
| bool | doString (const std::string &string) |
| Execute a string containing lua code. Returns true upon success. More... | |
| virtual std::string | getClassName () const =0 |
| bool | getGarbageCollectionEnabled () const |
| agx::Real | getGarbageCollectionFrequency () const |
| std::string | getLastErrorMessage () const |
| const char * | getLogPath () |
| Return the path to the log file for lua debug text. More... | |
| lua_State * | getLua () |
| Return the current lua state (cast to lua_State) More... | |
| int | getMemoryUsed () const |
| std::string | getPluginVersion () |
| int | getPriority () const |
| Return the shutdown priority of the singleton instance. More... | |
| bool | getTreatInvalidAsErrors () const |
| void | init (lua_State *L=nullptr, unsigned int stacksize=1024) |
| Initializes the ScriptManager. More... | |
| bool | isLoaded (const std::string &libraryName) |
| bool | registerLuaEntry (const void *ptr, const char *functionName) |
| This method is used for registering a reference in a lua table. More... | |
| bool | registerSimulation (agxSDK::Simulation *simulation) |
| void | removeScriptPlugin (ScriptPlugin *) |
| Remove a script plugin from the list of registered plugins. More... | |
| bool | requestScriptPlugin (const std::string &libraryName) |
| Try to load and register a script plugin with the given libraryName. More... | |
| void | setDebugMode (bool flag=true) |
| Print debug information to the log-path (set in setLogPath) More... | |
| void | setGarbageCollectionEnabled (bool b) |
| void | setGarbageCollectionFrequency (agx::Real f) |
| void | setLastErrorMessage (const std::string &errorMessage) |
| void | setLogPath (const std::string &path) |
| Set the filename of the log file containing debug information from lua. More... | |
| void | setTreatInvalidAsErrors (const bool treatInvalidAsErrors) |
| void | shutdown () override |
| Deallocates any allocated memory. More... | |
| bool | unregisterLuaEntry (const void *ptr) |
Static Public Member Functions | |
| static ScriptManager * | instance (bool erase=false) |
| Return the singleton object If erase is true then this singleton will be de-inititialized. More... | |
Protected Member Functions | |
| void | _shutdown () |
Definition at line 58 of file agxLua/ScriptManager.h.
|
inherited |
Specifies the ranges of the priority which can be assigned to a singleton at the time of creation.
Definition at line 35 of file Singleton.h.
|
protectedinherited |
| void agxLua::ScriptManager::addScriptPlugin | ( | ScriptPlugin * | ) |
Add A script-plugin to the list of registered plugins.
Referenced by agxLua::ScriptManager::RegisterScriptPluginProxy< T >::RegisterScriptPluginProxy().
| bool agxLua::ScriptManager::doFile | ( | const std::string & | path | ) |
Execute a lua script file. The file will be searched for in the specified filepath.
Request garbage collection in lua, if currentTime < 0 then do it immediately.
Otherwise do garbage collection only if it was more than 1/getGarbageCollectionFrequency() seconds since it was last performed.
| bool agxLua::ScriptManager::doString | ( | const std::string & | string | ) |
Execute a string containing lua code. Returns true upon success.
|
pure virtualinherited |
|
inline |
Definition at line 251 of file agxLua/ScriptManager.h.
|
inline |
Definition at line 254 of file agxLua/ScriptManager.h.
|
inline |
Definition at line 266 of file agxLua/ScriptManager.h.
|
inline |
Return the path to the log file for lua debug text.
Definition at line 235 of file agxLua/ScriptManager.h.
|
inline |
Return the current lua state (cast to lua_State)
Definition at line 232 of file agxLua/ScriptManager.h.
| int agxLua::ScriptManager::getMemoryUsed | ( | ) | const |
|
inline |
Definition at line 256 of file agxLua/ScriptManager.h.
Referenced by agxLua::ScriptManager::RegisterScriptPluginProxy< T >::RegisterScriptPluginProxy().
|
inherited |
Return the shutdown priority of the singleton instance.
|
inline |
Definition at line 260 of file agxLua/ScriptManager.h.
| void agxLua::ScriptManager::init | ( | lua_State * | L = nullptr, |
| unsigned int | stacksize = 1024 |
||
| ) |
Initializes the ScriptManager.
|
static |
Return the singleton object If erase is true then this singleton will be de-inititialized.
Referenced by agxLua::ScriptManager::RegisterScriptPluginProxy< T >::RegisterScriptPluginProxy(), agxLua::ScriptManager::ScriptPlugin::ScriptPlugin(), and agxLua::ScriptManager::RegisterScriptPluginProxy< T >::~RegisterScriptPluginProxy().
| bool agxLua::ScriptManager::isLoaded | ( | const std::string & | libraryName | ) |
| bool agxLua::ScriptManager::registerLuaEntry | ( | const void * | ptr, |
| const char * | functionName | ||
| ) |
This method is used for registering a reference in a lua table.
The reason is the following:
Assume you have a object called Event. You create a Event inside a function as a local variable, local to avoid a clash with other global variables with the same name. Now this variable perhaps has a function defined: callback. So you write function myFunc() local e = Event:new() function e:callback() – do stuff end
– register the event manager:registerEvent(e) end
Now assume that the manager later on calls the callback method from the lua C API. As the variable e was declared local in the function myFunc, the call to e:callback() will fail.
This is the reason for registering a reference of the Event instance in a global table. This table is initially empty and is created by the tolua export file.
| bool agxLua::ScriptManager::registerSimulation | ( | agxSDK::Simulation * | simulation | ) |
| void agxLua::ScriptManager::removeScriptPlugin | ( | ScriptPlugin * | ) |
Remove a script plugin from the list of registered plugins.
Referenced by agxLua::ScriptManager::RegisterScriptPluginProxy< T >::~RegisterScriptPluginProxy().
| bool agxLua::ScriptManager::requestScriptPlugin | ( | const std::string & | libraryName | ) |
Try to load and register a script plugin with the given libraryName.
Referenced by agxLua::ScriptManager::RegisterScriptPluginProxy< T >::RegisterScriptPluginProxy().
| void agxLua::ScriptManager::setDebugMode | ( | bool | flag = true | ) |
Print debug information to the log-path (set in setLogPath)
| void agxLua::ScriptManager::setGarbageCollectionEnabled | ( | bool | b | ) |
Definition at line 253 of file agxLua/ScriptManager.h.
|
inline |
Definition at line 267 of file agxLua/ScriptManager.h.
|
inline |
Set the filename of the log file containing debug information from lua.
Definition at line 226 of file agxLua/ScriptManager.h.
|
inline |
Definition at line 261 of file agxLua/ScriptManager.h.
|
overridevirtual |
Deallocates any allocated memory.
Reimplemented from agx::Singleton.
| bool agxLua::ScriptManager::unregisterLuaEntry | ( | const void * | ptr | ) |