![]() |
Plasma Engine
2.0
|
Base class for all types of plConsoleFunction, represents functions to be exposed to plConsole. More...
#include <ConsoleFunction.h>
Public Member Functions | |
plConsoleFunctionBase (plStringView sFunctionName, plStringView sDescription) | |
The constructor takes the function name and description as it should appear in the console. | |
plStringView | GetName () const |
Returns the name of the function as it should be exposed in the console. | |
plStringView | GetDescription () const |
Returns the description of the function as it should appear in the console. | |
virtual plUInt32 | GetNumParameters () const =0 |
Returns the number of parameters that this function takes. | |
virtual plVariant::Type::Enum | GetParameterType (plUInt32 uiParam) const =0 |
Returns the type of the n-th parameter. | |
virtual plResult | Call (plArrayPtr< plVariant > params)=0 |
Calls the function. Each parameter must be put into an plVariant and all of them are passed along as an array. | |
Additional Inherited Members | |
![]() | |
static const plRTTI * | GetStaticRTTI () |
![]() | |
plEnumerable * | m_pNextInstance |
Base class for all types of plConsoleFunction, represents functions to be exposed to plConsole.
Console functions are similar to plCVar's in that they can be executed from the plConsole. A console function can wrap many different types of functions with differing number and types of parameters. plConsoleFunction uses an plDelegate internally to store the function reference, so even member functions would be possible.
All console functions are enumerable, as their base class plConsoleFunctionBase is an plEnumerable class.
Console functions can have between zero and six parameters. The LuaInterpreter for plConsole only supports parameter types (unsigned) int, float/double, bool and string and uses the conversion feature of plVariant to map the lua input to the final function.
To make a function available as a console function, create a global variable of type plConsoleFunction with the proper template arguments to mirror its parameters and return type. Note that although functions with return types are accepted, the return value is currently always ignored.
Here the global function MyConsoleFunc2 is exposed to the console. The return value type and parameter types are passed as template arguments. ConFunc_MyConsoleFunc2 is now the global variable that represents the function for the console. The first string is the name with which the function is exposed, which is also used for auto-completion. The second string is the description of the function. Here we inserted the parameter list with types, so that the user knows how to use it. Finally the last parameter is the actual function to expose.
|
pure virtual |
Calls the function. Each parameter must be put into an plVariant and all of them are passed along as an array.
Returns PL_FAILURE, if the number of parameters did not match, or any parameter was not convertible to the actual type that the function expects.
Implemented in plConsoleFunction< R(PL_LIST(P, ARG_COUNT))>.
|
pure virtual |
Returns the number of parameters that this function takes.
Implemented in plConsoleFunction< R(PL_LIST(P, ARG_COUNT))>.
|
pure virtual |
Returns the type of the n-th parameter.
Implemented in plConsoleFunction< R(PL_LIST(P, ARG_COUNT))>.