Orxonox  0.0.5 Codename: Arcturus
Public Types | Public Member Functions | List of all members
orxonox::Functor Class Referenceabstract

The Functor classes are used to wrap function pointers. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/command/Functor.h>

Inheritance diagram for orxonox::Functor:
orxonox::FunctorMember< O > orxonox::FunctorMember< void > orxonox::FunctorPointer< detail::FunctionType< F, R, O, isconst, Params... >::Type, O > orxonox::FunctorPointer< F, O > orxonox::FunctorTemplate< F, R, O, isconst, Params >

Public Types

enum  Type { Type::Static, Type::Member }
 Defines the type of a function (static or member) More...
 

Public Member Functions

virtual ~Functor ()=default
 
virtual FunctorPtr clone ()=0
 Creates a new instance of Functor with the same values like this (used instead of a copy-constructor) More...
 
virtual void evaluateArgument (unsigned int index, MultiType &argument) const =0
 Converts a given argument to the type of the parameter with given index (the first parameter has index 0). More...
 
virtual const std::type_info & getFullIdentifier () const =0
 Returns the full identifier of the function-pointer which is defined as typeid(F), where F is the type of the stored function-pointer. Used to compare functors. More...
 
virtual const std::type_info & getHeaderIdentifier () const =0
 Returns an identifier of the header of the function (doesn't include the function's class). Used to compare functors. More...
 
virtual const std::type_info & getHeaderIdentifier (unsigned int params) const =0
 Returns an identifier of the header of the function (doesn't include the function's class), but regards only the first params parameters. Used to compare functions if an Executor provides default-values for the other parameters. More...
 
virtual unsigned int getParamCount () const =0
 Returns the number of parameters of the function. More...
 
virtual voidgetRawObjectPointer () const =0
 Returns the object-pointer. More...
 
virtual Type getType () const =0
 Returns the type of the function: static or member. More...
 
virtual std::string getTypenameParam (unsigned int index) const =0
 Returns the type-name of the parameter with given index (the first parameter has index 0). More...
 
virtual std::string getTypenameReturnvalue () const =0
 Returns the type-name of the return-value. More...
 
virtual bool hasReturnvalue () const =0
 Returns true if the function has a return-value. More...
 
virtual MultiType operator() (const MultiType &param1=MultiType::Null, const MultiType &param2=MultiType::Null, const MultiType &param3=MultiType::Null, const MultiType &param4=MultiType::Null, const MultiType &param5=MultiType::Null)=0
 Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function. More...
 
virtual void setRawObjectPointer (void *object)=0
 Assigns an object-pointer to the functor which is used to execute a member-function. More...
 
virtual void setSafeMode (bool bSafeMode)=0
 Enables or disables the safe mode which causes the functor to change the object pointer to nullptr if the object is deleted (only member functors). More...
 

Detailed Description

The Functor classes are used to wrap function pointers.

Function-pointers in C++ have a pretty complicated syntax and you can't store and call them unless you know the exact type. A Functor can be used to wrap a function-pointer and to store it independent of its type. You can also call it independently of its parameters by passing the arguments as MultiType. They are converted automatically to the right type.

Functor is a pure virtual base class.

See also
See Functor.h for some examples.

Member Enumeration Documentation

Defines the type of a function (static or member)

Enumerator
Static 
Member 

Constructor & Destructor Documentation

virtual orxonox::Functor::~Functor ( )
virtualdefault

Member Function Documentation

virtual FunctorPtr orxonox::Functor::clone ( )
pure virtual

Creates a new instance of Functor with the same values like this (used instead of a copy-constructor)

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual void orxonox::Functor::evaluateArgument ( unsigned int  index,
MultiType argument 
) const
pure virtual

Converts a given argument to the type of the parameter with given index (the first parameter has index 0).

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual const std::type_info& orxonox::Functor::getFullIdentifier ( ) const
pure virtual

Returns the full identifier of the function-pointer which is defined as typeid(F), where F is the type of the stored function-pointer. Used to compare functors.

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual const std::type_info& orxonox::Functor::getHeaderIdentifier ( ) const
pure virtual

Returns an identifier of the header of the function (doesn't include the function's class). Used to compare functors.

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual const std::type_info& orxonox::Functor::getHeaderIdentifier ( unsigned int  params) const
pure virtual

Returns an identifier of the header of the function (doesn't include the function's class), but regards only the first params parameters. Used to compare functions if an Executor provides default-values for the other parameters.

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual unsigned int orxonox::Functor::getParamCount ( ) const
pure virtual

Returns the number of parameters of the function.

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual void* orxonox::Functor::getRawObjectPointer ( ) const
pure virtual

Returns the object-pointer.

Implemented in orxonox::FunctorMember< void >, and orxonox::FunctorMember< O >.

virtual Type orxonox::Functor::getType ( ) const
pure virtual

Returns the type of the function: static or member.

Implemented in orxonox::FunctorMember< void >, and orxonox::FunctorMember< O >.

virtual std::string orxonox::Functor::getTypenameParam ( unsigned int  index) const
pure virtual

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

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual std::string orxonox::Functor::getTypenameReturnvalue ( ) const
pure virtual

Returns the type-name of the return-value.

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual bool orxonox::Functor::hasReturnvalue ( ) const
pure virtual

Returns true if the function has a return-value.

Implemented in orxonox::FunctorTemplate< F, R, O, isconst, Params >.

virtual MultiType orxonox::Functor::operator() ( const MultiType param1 = MultiType::Null,
const MultiType param2 = MultiType::Null,
const MultiType param3 = MultiType::Null,
const MultiType param4 = MultiType::Null,
const MultiType param5 = MultiType::Null 
)
pure virtual

Calls the function-pointer with up to five arguments. In case of a member-function, the assigned object-pointer is used to call the function.

Returns
Returns the return-value of the function (if any; MultiType::Null otherwise)

Implemented in orxonox::FunctorMember< void >, and orxonox::FunctorMember< O >.

virtual void orxonox::Functor::setRawObjectPointer ( void object)
pure virtual

Assigns an object-pointer to the functor which is used to execute a member-function.

Implemented in orxonox::FunctorMember< void >, and orxonox::FunctorMember< O >.

virtual void orxonox::Functor::setSafeMode ( bool  bSafeMode)
pure virtual

Enables or disables the safe mode which causes the functor to change the object pointer to nullptr if the object is deleted (only member functors).

Implemented in orxonox::FunctorMember< void >, and orxonox::FunctorMember< O >.


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