|
VR-Engage
2.2
|
This class handles loading and accessing configuration data from Lua scripts. It provides a consistent interface for component initialization throughout the VREngage system, supporting command-line arguments and configuration files.
#include <initializer.h>
Public Member Functions | |
| DtInitializer (int argc, char *argv[], bool throwOnMissingField=true) | |
| DtInitializer (DtFilename configFile, bool throwOnMissingField=true) | |
| virtual | ~DtInitializer () override |
| virtual bool | hasField (const std::string &name, bool resolveDots=true) |
| template<typename RT> | |
| RT | findData (const std::string &name, bool resolveDots=true) |
| template<typename RT> | |
| RT | findDataOr (const std::string &name, RT defaultValue, bool silent=false, bool resolveDots=true) |
| template<typename RT> | |
| RT | findData (int index) |
| int | argc () |
| char ** | argv () |
| virtual bool | addConfigScript (std::string filename) |
| virtual bool | addConfigString (std::string str) |
| virtual bool | loadConfigScript () |
Public Member Functions inherited from makVre::DtLuaState | |
| DtLuaState () | |
| DtLuaState (lua_State &L) | |
| virtual | ~DtLuaState () |
| DtLuaState & | operator= (const DtLuaState &orig) |
| lua_State * | state () |
| virtual bool | hasObject (const std::string &name) |
| virtual DtLuaObject | findObject (const std::string &name) |
| virtual bool | doFile (const std::string &filename) |
| virtual bool | doScript (const std::string &data) |
| template<typename RT> | |
| RT | get (int stackIndex) |
| template<typename RT> | |
| RT | get (const std::string &name, bool resolveDots=true) |
| template<typename T> | |
| void | push (const T &data) |
| template<typename T> | |
| bool | store (const std::string &name, const T &data) |
| virtual DtLuaObject | createTable (int narr=0, int nrec=0) |
| virtual void | clearStack () |
| virtual void | stackDump () |
| virtual void | forceGarbageCollection () |
| virtual bool | getItemOnStack (const std::string &name, bool resolveDots=true) |
| virtual bool | topStackValueOk () |
| virtual int | stackSize () |
Protected Member Functions | |
| void | initImportFunction () |
| void | createGlobalTable () |
Protected Member Functions inherited from makVre::DtLuaState | |
| virtual void | printValue (int index) |
| virtual void | printTable (int index) |
Protected Attributes | |
| DtFilename | myConfigFilename |
| DtInitTable | myGlobalTable |
| bool | myThrowOnMissingField |
| int | myArgc |
| char ** | myArgv |
Protected Attributes inherited from makVre::DtLuaState | |
| lua_State * | myState |
| bool | myNeedToCloseState |
Additional Inherited Members | |
Static Public Member Functions inherited from makVre::DtLuaState | |
| template<typename T> | |
| static void | addEncoder (DtBaseEncoder *encoder) |
| template<typename T> | |
| static void | addDecoder (DtBaseDecoder *decoder) |
| template<typename T> | |
| static void | addEncoder (DtBaseEncoder *encoder) |
| template<typename T> | |
| static void | addDecoder (DtBaseDecoder *decoder) |
Protected Types inherited from makVre::DtLuaState | |
| using | EncoderMap = std::map<std::string, DtBaseEncoder*> |
| using | DecoderMap = std::map<std::string, DtBaseDecoder*> |
Static Protected Member Functions inherited from makVre::DtLuaState | |
| static void | initEncoders () |
| static void | initDecoders () |
Static Protected Attributes inherited from makVre::DtLuaState | |
| static EncoderMap | theEncoders |
| static DecoderMap | theDecoders |
| static bool | theInitializedEncoderDecoders |
| makVre::DtInitializer::DtInitializer | ( | int | argc, |
| char * | argv[], | ||
| bool | throwOnMissingField = true ) |
| makVre::DtInitializer::DtInitializer | ( | DtFilename | configFile, |
| bool | throwOnMissingField = true ) |
Constructor using a configuration file.
| configFile | Path to the Lua configuration file to load |
| throwOnMissingField | If true, throws exceptions for missing configuration fields |
|
overridevirtual |
Virtual destructor.
|
virtual |
Checks if a configuration field exists.
| name | The name of the field to check |
| resolveDots | If true, handles dotted notation for nested tables |
References findData(), and findDataOr().
| RT makVre::DtInitializer::findData | ( | const std::string & | name, |
| bool | resolveDots = true ) |
Retrieves a configuration value by name.
| RT | The type to convert the found data to |
| name | The name of the field to retrieve |
| resolveDots | If true, handles dotted notation for nested tables |
| std::string | if the field is not found and throwOnMissingField is true |
References myGlobalTable.
Referenced by hasField().
| RT makVre::DtInitializer::findDataOr | ( | const std::string & | name, |
| RT | defaultValue, | ||
| bool | silent = false, | ||
| bool | resolveDots = true ) |
References myGlobalTable.
Referenced by hasField().
| RT makVre::DtInitializer::findData | ( | int | index | ) |
References myGlobalTable.
| int makVre::DtInitializer::argc | ( | ) |
Gets the number of command-line arguments.
Referenced by DtInitializer().
| char ** makVre::DtInitializer::argv | ( | ) |
Gets the array of command-line arguments.
Referenced by DtInitializer().
|
virtual |
Adds an additional configuration file.
| filename | Path to the Lua configuration file to add |
This method can be called to load additional configuration files after initialization
|
virtual |
Adds configuration from a string.
| str | Lua code string containing configuration data |
This method can be called to add configuration from a string after initialization
|
virtual |
Reloads the configuration script.
This method can be called to reload the configuration script after modifications
|
protected |
Initializes the 'import' function in Lua.
Sets up a Lua function to import other Lua scripts into the current state
|
protected |
Creates and initializes the global table.
Creates a wrapper around the Lua global '_G' table for configuration access
|
protected |
Path to the main configuration file.
|
protected |
Table wrapper for the Lua global environment.
Referenced by findData(), findData(), and findDataOr().
|
protected |
Controls exception behavior for missing fields.
|
protected |
Number of command-line arguments.
|
protected |
Array of command-line argument strings.