22#include <vlutil/vlFilename.h>
54 template <
typename RT>
55 RT
findData(
const std::string& name,
bool resolveDots =
true);
57 template <
typename RT>
58 RT
findDataOr(
const std::string& name, RT defaultValue,
bool silent =
false,
bool resolveDots =
true);
60 template <
typename RT>
100 virtual bool hasField(
const std::string& name,
bool resolveDots =
true);
109 template <
typename RT>
110 RT
findData(
const std::string& name,
bool resolveDots =
true);
112 template <
typename RT>
113 RT
findDataOr(
const std::string& name, RT defaultValue,
bool silent =
false,
bool resolveDots =
true);
115 template <
typename RT>
174template <
typename RT>
180 std::string err =
"Cannot find field: " + name;
181 LOG_WARN(
"Util") << err << std::endl;
190 return state.get<RT>(-1);
193template <
typename RT>
196 DtASSERT(index > 0,
"lua table indexes start at 1");
201 std::string err =
"Cannot find field: " + index;
202 LOG_WARN(
"Util") << err << std::endl;
211 return state.get<RT>(-1);
214template <
typename RT>
217 if (
hasField(name, resolveDots) ==
false)
221 LOG_VERBOSE(
"Util") <<
"Did not find requested field \"" << name <<
"\" using default value" << std::endl;
230template <
typename RT>
232 const std::string& name, RT defaultValue,
bool silent,
bool resolveDots )
234 return myGlobalTable.findDataOr<RT>(name, defaultValue, silent, resolveDots);
237template <
typename RT>
243template <
typename RT>
#define DtASSERT(exp, description)
Primary assertion macro for runtime validation.
Definition assert.h:53
Table-based access to Lua state for configuration data.
Definition initializer.h:38
bool myThrowOnMissingField
Controls exception behavior for missing fields.
Definition initializer.h:71
virtual void setThrowOnMissingField(bool set)
Sets whether to throw exceptions for missing fields.
virtual ~DtInitTable() override
Destructor.
DtInitTable(lua_State &state, int index, bool throwOnMissingField=true)
Constructor with existing Lua state and table.
DtInitTable()
Default constructor.
RT findDataOr(const std::string &name, RT defaultValue, bool silent=false, bool resolveDots=true)
Definition initializer.h:215
RT findData(const std::string &name, bool resolveDots=true)
Definition initializer.h:175
Configuration initializer for VREngage components.
Definition initializer.h:80
virtual bool addConfigString(std::string str)
Adds configuration from a string.
RT findDataOr(const std::string &name, RT defaultValue, bool silent=false, bool resolveDots=true)
Definition initializer.h:231
char ** argv()
Gets the array of command-line arguments.
int myArgc
Number of command-line arguments.
Definition initializer.h:167
bool myThrowOnMissingField
Controls exception behavior for missing fields.
Definition initializer.h:164
DtInitializer(int argc, char *argv[], bool throwOnMissingField=true)
Constructor using command-line arguments.
virtual bool hasField(const std::string &name, bool resolveDots=true)
Checks if a configuration field exists.
char ** myArgv
Array of command-line argument strings.
Definition initializer.h:170
virtual bool loadConfigScript()
Reloads the configuration script.
DtInitializer(DtFilename configFile, bool throwOnMissingField=true)
Constructor using a configuration file.
virtual bool addConfigScript(std::string filename)
Adds an additional configuration file.
void initImportFunction()
Initializes the 'import' function in Lua.
void createGlobalTable()
Creates and initializes the global table.
DtFilename myConfigFilename
Path to the main configuration file.
Definition initializer.h:158
DtInitTable myGlobalTable
Table wrapper for the Lua global environment.
Definition initializer.h:161
int argc()
Gets the number of command-line arguments.
virtual ~DtInitializer() override
Virtual destructor.
RT findData(const std::string &name, bool resolveDots=true)
Retrieves a configuration value by name.
Definition initializer.h:238
virtual lua_State * state()
Gets the Lua state associated with this object.
virtual bool hasField(const std::string &name, bool resolveDots=true)
Checks if the table has a field with the given name.
virtual bool getItemOnStack(const std::string &name, bool resolveDots)
Retrieves a named item from the table and pushes it onto the stack.
DtLuaObject()
Default constructor.
lua_State * myState
Pointer to the Lua state.
Definition luaObject.h:163
A utility class for automatically cleaning the Lua stack.
Definition luaStackCleaner.h:28
Class for managing a Lua state and providing high-level operations.
Definition luaState.h:43
DtLuaState(const DtLuaState &orig)
Copy constructor (not implemented)
Defines export macros for the VREngage Utility library.
#define UTIL_DLL
Export/import macro for non-Windows platforms.
Definition export.h:39
Provides logging functionality with various severity levels and channels.
#define LOG_WARN(channel)
Macro to log a warning message to log files.
Definition logger.h:69
#define LOG_VERBOSE(channel)
Macro to log a verbose message to log files.
Definition logger.h:79
Provides a RAII mechanism for automatically cleaning the Lua stack.
Provides an interface for interacting with a Lua state in VREngage.
Include export definitions for this library.
Definition glsVreMessageUtil.h:49