Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Protected Attributes | List of all members
orxonox::Executor Class Reference

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>

Inheritance diagram for orxonox::Executor:
orxonox::ExecutorMember< T > orxonox::ExecutorStatic

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 FunctorPtrgetFunctor () 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...
 

Detailed Description

This class is used to wrap a Functor and to store default values for any of its parameters.

See also
See Executor.h for an example.

Constructor & Destructor Documentation

orxonox::Executor::Executor ( const FunctorPtr functor,
const std::string &  name = "" 
)

Constructor: Creates an executor.

Parameters
functorThe wrapped functor
nameThe 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.

virtual orxonox::Executor::~Executor ( )
virtualdefault

Member Function Documentation

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.

bool orxonox::Executor::defaultValueSet ( unsigned int  index) const
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.

Parameters
argumentsThe arguments that should be converted
argAn array of MultiType where the converted arguments will be stored
errorA pointer to a variable (or nullptr) that is used to store the error code (see CommandExecutor error codes)
delimiterThe delimiter that was used to separate the arguments in the SubString arguments (used to join the surplus arguments)
Returns
Returns the number of evaluated arguments
MultiType orxonox::Executor::getDefaultValue ( unsigned int  index) const
inline

Returns the default value for a parameter with given index (the first parameter has index 0).

const FunctorPtr& orxonox::Executor::getFunctor ( ) const
inline

Returns the functor.

const std::string& orxonox::Executor::getName ( void  ) const
inline

Returns the name of the executor.

unsigned int orxonox::Executor::getParamCount ( ) const
inline

Returns the number of parameters of the wrapped function.

Functor::Type orxonox::Executor::getType ( ) const
inline

Returns the type of the wrapped function (static or member).

std::string orxonox::Executor::getTypenameParam ( unsigned int  param) const
inline

Returns the name of the type of a parameter with given index (the first parameter has index 0).

std::string orxonox::Executor::getTypenameReturnvalue ( ) const
inline

Returns the name of the type of the return value.

bool orxonox::Executor::hasReturnvalue ( ) const
inline

Returns true if the wrapped function returns a value.

MultiType orxonox::Executor::operator() ( ) const
inline

Calls the wrapped function with 0 arguments. If the function needs more arguments, the executor's default values are used.

MultiType orxonox::Executor::operator() ( const MultiType arg1) const
inline

Calls the wrapped function with 1 argument. If the function needs more arguments, the executor's default values are used.

MultiType orxonox::Executor::operator() ( const MultiType arg1,
const MultiType arg2 
) const
inline

Calls the wrapped function with 2 arguments. If the function needs more arguments, the executor's default values are used.

MultiType orxonox::Executor::operator() ( const MultiType arg1,
const MultiType arg2,
const MultiType arg3 
) const
inline

Calls the wrapped function with 3 arguments. If the function needs more arguments, the executor's default values are used.

MultiType orxonox::Executor::operator() ( const MultiType arg1,
const MultiType arg2,
const MultiType arg3,
const MultiType arg4 
) const
inline

Calls the wrapped function with 4 arguments. If the function needs more arguments, the executor's default values are used.

MultiType orxonox::Executor::operator() ( const MultiType arg1,
const MultiType arg2,
const MultiType arg3,
const MultiType arg4,
const MultiType arg5 
) const
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.

Parameters
argumentsThe arguments that should be passed to the function, separated by delimiter
errorA pointer to a variable (or nullptr) that is used to store the error code (see CommandExecutor error codes)
delimiterThe delimiter that is used to separate the arguments in the string arguments
bPrintErrorIf true, errors are printed to the console if the function couldn't be executed with the given arguments
Returns
Returns the return value of the function (or MultiType::Null if there is no return value)
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.

Parameters
argumentsThe arguments that should be passed to the function
errorA pointer to a variable (or nullptr) that is used to store the error code (see CommandExecutor error codes)
delimiterThe delimiter that was used to separate the arguments in the SubString arguments (used to join the surplus arguments)
bPrintErrorIf true, errors are printed to the console if the function couldn't be executed with the given arguments
Returns
Returns the return value of the function (or MultiType::Null if there is no return value)
void orxonox::Executor::setDefaultValue ( unsigned int  index,
const MultiType arg 
)

Defines the default value for a parameter with given index (the first parameter has index 0).

void orxonox::Executor::setDefaultValues ( const MultiType arg1)

Defines the default value for the first parameter.

void orxonox::Executor::setDefaultValues ( const MultiType arg1,
const MultiType arg2 
)

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.

void orxonox::Executor::setFunctor ( const FunctorPtr functor)
inline

Changes the functor.

void orxonox::Executor::setName ( const std::string &  name)
inline

Changes the name of the executor.

Member Data Documentation

MultiType orxonox::Executor::defaultValue_[MAX_FUNCTOR_ARGUMENTS]
protected

The default values, one for each parameter.

FunctorPtr orxonox::Executor::functor_
protected

The underlying Functor that wraps a function.

std::string orxonox::Executor::name_
protected

The name of the executor.


The documentation for this class was generated from the following files: