Chi-Tech
|
#include <chi_console.h>
Data Structures | |
struct | LuaFunctionRegistryEntry |
struct | LuaFuncWrapperRegEntry |
Public Types | |
using | WrapperGetInParamsFunc = chi::InputParameters(*)() |
using | WrapperCallFunc = chi::ParameterBlock(*)(const chi::InputParameters &) |
Public Member Functions | |
lua_State *& | GetConsoleState () |
std::vector< std::string > & | GetCommandBuffer () |
const std::map< std::string, LuaFunctionRegistryEntry > & | GetLuaFunctionRegistry () const |
const std::map< std::string, LuaFunctionRegistryEntry > & | GetFunctionWrapperRegistry () const |
void | RunConsoleLoop (char *fileName=nullptr) const |
int | ExecuteFile (const std::string &fileName, int argc, char **argv) const |
void | PostMPIInfo (int location_id, int number_of_processes) const |
void | FlushConsole () |
Flushes any commands in the command buffer. More... | |
void | DumpRegister () const |
Dumps the object registry to stdout. More... | |
void | UpdateConsoleBindings (const chi::RegistryStatuses &old_statuses) |
Static Public Member Functions | |
static Console & | GetInstance () noexcept |
static char | AddFunctionToRegistryGlobalNamespace (const std::string &raw_name_in_lua, lua_CFunction function_ptr) |
Adds a lua_CFunction to the registry. More... | |
static char | AddFunctionToRegistryInNamespaceWithName (lua_CFunction function_ptr, const std::string &namespace_name, const std::string &function_name) |
Adds a lua_CFunction to the registry. With namespace-table analogy. More... | |
static char | AddLuaConstantToRegistry (const std::string &namespace_name, const std::string &constant_name, const chi_data_types::Varying &value) |
Adds a constant to the lua state. More... | |
static InputParameters | DefaultGetInParamsFunc () |
A default function for returning empty input parameters. More... | |
static char | AddWrapperToRegistryInNamespaceWithName (const std::string &namespace_name, const std::string &name_in_lua, WrapperGetInParamsFunc syntax_function, WrapperCallFunc actual_function, bool ignore_null_call_func=false) |
Adds a function wrapper to the lua registry. More... | |
static void | SetLuaFuncNamespaceTableStructure (const std::string &full_lua_name, lua_CFunction function_ptr) |
Formats a namespace structure as table. More... | |
static void | SetLuaFuncWrapperNamespaceTableStructure (const std::string &full_lua_name) |
Formats a namespace structure as a table, but the last entry is a function call. More... | |
static void | SetObjectNamespaceTableStructure (const std::string &full_lua_name) |
Formats a namespace structure as a table, but the last entry contains a "Create" function and a type. More... | |
static void | FleshOutLuaTableStructure (const std::vector< std::string > &table_names) |
Makes sure a table structure exists for the list of table names. More... | |
static void | SetLuaConstant (const std::string &constant_name, const chi_data_types::Varying &value) |
static CSTMemory | GetMemoryUsage () |
Get current memory usage. More... | |
static double | GetMemoryUsageInMB () |
Get current memory usage in Megabytes. More... | |
static int | LuaWrapperCall (lua_State *L) |
Generic entry point for wrapper calls. More... | |
Private Member Functions | |
Console () noexcept | |
void | LoadRegisteredLuaItems () |
Static Private Member Functions | |
static void | AddFunctionToRegistry (const std::string &name_in_lua, lua_CFunction function_ptr) |
Private Attributes | |
lua_State * | console_state_ |
Pointer to lua console state. More... | |
std::vector< std::string > | command_buffer_ |
Buffer of commands to execute. More... | |
std::map< std::string, LuaFunctionRegistryEntry > | lua_function_registry_ |
std::map< std::string, LuaFuncWrapperRegEntry > | function_wrapper_registry_ |
std::map< std::string, chi_data_types::Varying > | lua_constants_registry_ |
Static Private Attributes | |
static Console | instance_ |
Friends | |
class | ::Chi |
Class for handling the console and scripting.
Definition at line 90 of file chi_console.h.
using chi::Console::WrapperCallFunc = chi::ParameterBlock (*)(const chi::InputParameters&) |
Definition at line 94 of file chi_console.h.
using chi::Console::WrapperGetInParamsFunc = chi::InputParameters (*)() |
Definition at line 93 of file chi_console.h.
|
privatenoexcept |
Default constructor for the console
Definition at line 19 of file chi_console_constrdestr.cc.
|
staticprivate |
Basic addition to registry. Used by the other public methods to registry a text-key to a lua function.
Definition at line 66 of file chi_console_utilities.cc.
|
static |
Adds a lua_CFunction to the registry.
Adds a lua_CFunction to the registry. The registry of functions gets parsed into the lua console when chi::Initialize
is called. This particular function will strip the namespace from the the parameter raw_name_in_lua
and cause the function to be registered in the global namespace of the lua console.
Definition at line 95 of file chi_console_utilities.cc.
|
static |
Adds a lua_CFunction to the registry. With namespace-table analogy.
Adds a lua_CFunction to the registry. The registry of functions gets parsed into the lua console when chi::Initialize
is called. The full path of the function will be derived from namespace_name
+ "::" + function_name
.
Definition at line 112 of file chi_console_utilities.cc.
|
static |
Adds a constant to the lua state.
Adds a constant to the lua state. Prepending the constant within a namespace is optional.
Definition at line 127 of file chi_console_utilities.cc.
|
static |
Adds a function wrapper to the lua registry.
Wrapper functions operate with input and output parameters, essentially hiding the lua interface.
Definition at line 159 of file chi_console_utilities.cc.
|
static |
A default function for returning empty input parameters.
Definition at line 151 of file chi_console_utilities.cc.
void chi::Console::DumpRegister | ( | ) | const |
Dumps the object registry to stdout.
Makes a formatted output, readible by the documentation scripts, of all the lua wrapper functions.
Definition at line 390 of file chi_console_utilities.cc.
int chi::Console::ExecuteFile | ( | const std::string & | fileName, |
int | argc, | ||
char ** | argv | ||
) | const |
Executes the given file in the Lua engine.
Definition at line 19 of file chi_console_utilities.cc.
|
static |
Makes sure a table structure exists for the list of table names.
Fleshes out a path in a table tree. For example, given "fee::foo::fah::koo, this routine will make sure that fee.foo.fah.koo is defined as a table tree structure. The routine will create a table structure where one is needed and leave existing ones alone.
At the end of the routine the last table in the structure will be on top of the stack.
Definition at line 305 of file chi_console_utilities.cc.
void chi::Console::FlushConsole | ( | ) |
Flushes any commands in the command buffer.
This function sends the commands contained in the command_buffer to the lua state from where it is executed. These could be commands passed via the command line or loaded elsewhere.
Definition at line 9 of file chi_console_flushconsole.cc.
|
inline |
Definition at line 131 of file chi_console.h.
|
inline |
Definition at line 130 of file chi_console.h.
|
inline |
Definition at line 140 of file chi_console.h.
|
staticnoexcept |
Access to the singleton
Definition at line 11 of file chi_console_constrdestr.cc.
|
inline |
Definition at line 134 of file chi_console.h.
|
static |
Get current memory usage.
Gets the current memory usage.
Definition at line 13 of file chi_console_memory.cc.
|
static |
Get current memory usage in Megabytes.
Gets the current memory usage in megabytes.
Definition at line 60 of file chi_console_memory.cc.
|
private |
Registers all lua items so that they are available in the console.
Definition at line 27 of file chi_console_constrdestr.cc.
|
static |
Generic entry point for wrapper calls.
This function expects at least 1 parameter. The first parameter must be a string indicating the registered name of the function wrapper to call. All other parameters will be forwarded to the function wrapper.
Definition at line 14 of file chi_console_fwrapper_call.cc.
void chi::Console::PostMPIInfo | ( | int | location_id, |
int | number_of_processes | ||
) | const |
Pushes location id and number of processes to lua state.
Definition at line 51 of file chi_console_utilities.cc.
void chi::Console::RunConsoleLoop | ( | char * | fileName = nullptr | ) | const |
Executes the loop for the console.
Wrapper to an MPI_Bcast call for a single integer broadcast from location 0.
Wrapper to an MPI_Bcast call for an array of characters broadcast from location 0.
Wrapper to an MPI_Bcast call for an array of characters broadcast from location 0. This call is for non-home locations.
Executes a string within the lua-console.
Definition at line 11 of file chi_console_loop.cc.
|
static |
Sets a lua constant in the lua state.
Definition at line 342 of file chi_console_utilities.cc.
|
static |
Formats a namespace structure as table.
Sets/Forms a lua function in the state using a namespace structure.
Definition at line 194 of file chi_console_utilities.cc.
|
static |
Formats a namespace structure as a table, but the last entry is a function call.
Sets/Forms a table structure that mimics the namespace structure of a string. For example the string "sing::sob::nook::Tigger" will be assigned a table structure sing.sob.nook.Tigger = "sing::sob::nook::Tigger"
. Then finally assigns lua call to this table.
Lambda for making a chunk
Definition at line 225 of file chi_console_utilities.cc.
|
static |
Formats a namespace structure as a table, but the last entry contains a "Create" function and a type.
Sets/Forms a table structure that mimics the namespace structure of a string. For example the string "sing::sob::nook::Tigger" will be assigned a table structure sing.sob.nook.Tigger = "sing::sob::nook::Tigger"
.
Lambda for registering object type and creation function.
Definition at line 268 of file chi_console_utilities.cc.
void chi::Console::UpdateConsoleBindings | ( | const chi::RegistryStatuses & | old_statuses | ) |
Given an old status, will update the bindings for only newly registered items.
Definition at line 416 of file chi_console_utilities.cc.
|
friend |
Definition at line 124 of file chi_console.h.
|
private |
Buffer of commands to execute.
Definition at line 111 of file chi_console.h.
|
private |
Pointer to lua console state.
Definition at line 109 of file chi_console.h.
|
private |
Definition at line 116 of file chi_console.h.
|
staticprivate |
Definition at line 112 of file chi_console.h.
|
private |
Definition at line 118 of file chi_console.h.
|
private |
Definition at line 114 of file chi_console.h.