Orxonox
0.0.5 Codename: Arcturus
|
This class is used to wrap a Functor and to store default values for any of its parameters. More...
#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/command/Executor.h>
Public Member Functions | |
Executor (const FunctorPtr &functor, const std::string &name="") | |
Constructor: Creates an executor. More... | |
Executor (const Executor &other) | |
Copy-constructor: Creates a new executor with the same values and a clone of the wrapped Functor. More... | |
virtual | ~Executor ()=default |
bool | allDefaultValuesSet () const |
Returns true if the executor has a default value for each parameter of the wrapped function, so it can be called without passing additional arguments. More... | |
bool | defaultValueSet (unsigned int index) const |
Returns true if the executor contains a default value for the parameter with given index (the first parameter has index 0). More... | |
int | evaluateArguments (const SubString &arguments, MultiType arg[MAX_FUNCTOR_ARGUMENTS], int *error=nullptr, const std::string &delimiter=" ") const |
Converts the arguments in a SubString to the right type, so they can be used to execute the function without further conversions. More... | |
MultiType | getDefaultValue (unsigned int index) const |
Returns the default value for a parameter with given index (the first parameter has index 0). More... | |
const FunctorPtr & | getFunctor () const |
Returns the functor. More... | |
const std::string & | getName () const |
Returns the name of the executor. More... | |
unsigned int | getParamCount () const |
Returns the number of parameters of the wrapped function. More... | |
Functor::Type | getType () const |
Returns the type of the wrapped function (static or member). More... | |
std::string | getTypenameParam (unsigned int param) const |
Returns the name of the type of a parameter with given index (the first parameter has index 0). More... | |
std::string | getTypenameReturnvalue () const |
Returns the name of the type of the return value. More... | |
bool | hasReturnvalue () const |
Returns true if the wrapped function returns a value. More... | |
MultiType | operator() () const |
Calls the wrapped function with 0 arguments. If the function needs more arguments, the executor's default values are used. More... | |
MultiType | operator() (const MultiType &arg1) const |
Calls the wrapped function with 1 argument. If the function needs more arguments, the executor's default values are used. More... | |
MultiType | operator() (const MultiType &arg1, const MultiType &arg2) const |
Calls the wrapped function with 2 arguments. If the function needs more arguments, the executor's default values are used. More... | |
MultiType | operator() (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3) const |
Calls the wrapped function with 3 arguments. If the function needs more arguments, the executor's default values are used. More... | |
MultiType | operator() (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3, const MultiType &arg4) const |
Calls the wrapped function with 4 arguments. If the function needs more arguments, the executor's default values are used. More... | |
MultiType | operator() (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3, const MultiType &arg4, const MultiType &arg5) const |
Calls the wrapped function with 5 arguments. If the function needs more arguments, the executor's default values are used. More... | |
MultiType | parse (const std::string &arguments, int *error=nullptr, const std::string &delimiter=" ", bool bPrintError=false) const |
Calls the wrapped function with arguments that are passed in a string. More... | |
MultiType | parse (const SubString &arguments, int *error=nullptr, const std::string &delimiter=" ", bool bPrintError=false) const |
Calls the wrapped function with arguments that are passed as tokens in a SubString. More... | |
void | setDefaultValue (unsigned int index, const MultiType &arg) |
Defines the default value for a parameter with given index (the first parameter has index 0). More... | |
void | setDefaultValues (const MultiType &arg1) |
Defines the default value for the first parameter. More... | |
void | setDefaultValues (const MultiType &arg1, const MultiType &arg2) |
Defines the default value for the first two parameters. More... | |
void | setDefaultValues (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3) |
Defines the default value for the first three parameters. More... | |
void | setDefaultValues (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3, const MultiType &arg4) |
Defines the default value for the first four parameters. More... | |
void | setDefaultValues (const MultiType &arg1, const MultiType &arg2, const MultiType &arg3, const MultiType &arg4, const MultiType &arg5) |
Defines the default value for the first five parameters. More... | |
void | setFunctor (const FunctorPtr &functor) |
Changes the functor. More... | |
void | setName (const std::string &name) |
Changes the name of the executor. More... | |
Protected Attributes | |
MultiType | defaultValue_ [MAX_FUNCTOR_ARGUMENTS] |
The default values, one for each parameter. More... | |
FunctorPtr | functor_ |
The underlying Functor that wraps a function. More... | |
std::string | name_ |
The name of the executor. More... | |
This class is used to wrap a Functor and to store default values for any of its parameters.
orxonox::Executor::Executor | ( | const FunctorPtr & | functor, |
const std::string & | name = "" |
||
) |
Constructor: Creates an executor.
functor | The wrapped functor |
name | The name of the executor (optional, used mostly for debug output) |
orxonox::Executor::Executor | ( | const Executor & | other | ) |
Copy-constructor: Creates a new executor with the same values and a clone of the wrapped Functor.
|
virtualdefault |
bool orxonox::Executor::allDefaultValuesSet | ( | ) | const |
Returns true if the executor has a default value for each parameter of the wrapped function, so it can be called without passing additional arguments.
|
inline |
Returns true if the executor contains a default value for the parameter with given index (the first parameter has index 0).
int orxonox::Executor::evaluateArguments | ( | const SubString & | arguments, |
MultiType | arg[MAX_FUNCTOR_ARGUMENTS], | ||
int * | error = nullptr , |
||
const std::string & | delimiter = " " |
||
) | const |
Converts the arguments in a SubString to the right type, so they can be used to execute the function without further conversions.
arguments | The arguments that should be converted |
arg | An array of MultiType where the converted arguments will be stored |
error | A pointer to a variable (or nullptr) that is used to store the error code (see CommandExecutor error codes) |
delimiter | The delimiter that was used to separate the arguments in the SubString arguments (used to join the surplus arguments) |
|
inline |
Returns the default value for a parameter with given index (the first parameter has index 0).
|
inline |
Returns the functor.
|
inline |
Returns the name of the executor.
|
inline |
Returns the number of parameters of the wrapped function.
|
inline |
Returns the type of the wrapped function (static or member).
|
inline |
Returns the name of the type of a parameter with given index (the first parameter has index 0).
|
inline |
Returns the name of the type of the return value.
|
inline |
Returns true if the wrapped function returns a value.
|
inline |
Calls the wrapped function with 0 arguments. If the function needs more arguments, the executor's default values are used.
Calls the wrapped function with 1 argument. If the function needs more arguments, the executor's default values are used.
|
inline |
Calls the wrapped function with 2 arguments. If the function needs more arguments, the executor's default values are used.
|
inline |
Calls the wrapped function with 3 arguments. If the function needs more arguments, the executor's default values are used.
|
inline |
Calls the wrapped function with 4 arguments. If the function needs more arguments, the executor's default values are used.
|
inline |
Calls the wrapped function with 5 arguments. If the function needs more arguments, the executor's default values are used.
MultiType orxonox::Executor::parse | ( | const std::string & | arguments, |
int * | error = nullptr , |
||
const std::string & | delimiter = " " , |
||
bool | bPrintError = false |
||
) | const |
Calls the wrapped function with arguments that are passed in a string.
arguments | The arguments that should be passed to the function, separated by delimiter |
error | A pointer to a variable (or nullptr) that is used to store the error code (see CommandExecutor error codes) |
delimiter | The delimiter that is used to separate the arguments in the string arguments |
bPrintError | If true, errors are printed to the console if the function couldn't be executed with the given arguments |
MultiType orxonox::Executor::parse | ( | const SubString & | arguments, |
int * | error = nullptr , |
||
const std::string & | delimiter = " " , |
||
bool | bPrintError = false |
||
) | const |
Calls the wrapped function with arguments that are passed as tokens in a SubString.
arguments | The arguments that should be passed to the function |
error | A pointer to a variable (or nullptr) that is used to store the error code (see CommandExecutor error codes) |
delimiter | The delimiter that was used to separate the arguments in the SubString arguments (used to join the surplus arguments) |
bPrintError | If true, errors are printed to the console if the function couldn't be executed with the given arguments |
Defines the default value for a parameter with given index (the first parameter has index 0).
Defines the default value for the first parameter.
Defines the default value for the first two parameters.
void orxonox::Executor::setDefaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2, | ||
const MultiType & | arg3 | ||
) |
Defines the default value for the first three parameters.
void orxonox::Executor::setDefaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2, | ||
const MultiType & | arg3, | ||
const MultiType & | arg4 | ||
) |
Defines the default value for the first four parameters.
void orxonox::Executor::setDefaultValues | ( | const MultiType & | arg1, |
const MultiType & | arg2, | ||
const MultiType & | arg3, | ||
const MultiType & | arg4, | ||
const MultiType & | arg5 | ||
) |
Defines the default value for the first five parameters.
|
inline |
Changes the functor.
|
inline |
Changes the name of the executor.
|
protected |
The default values, one for each parameter.
|
protected |
The underlying Functor that wraps a function.
|
protected |
The name of the executor.