Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Member Functions | List of all members
orxonox::FunctorTemplate< F, R, O, isconst, Params > Class Template Reference

FunctorTemplate is a child class of FunctorPointer and implements all functions that need to know the exact types of the parameters, return-value, and class. More...

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

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

Public Member Functions

 FunctorTemplate (typename detail::FunctionType< F, R, O, isconst, Params... >::Type functionPointer, O *object=nullptr)
 Constructor: Initializes the base class. More...
 
virtual FunctorPtr clone () override
 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 override
 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 override
 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 override
 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 override
 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 override
 Returns the number of parameters of the function. More...
 
virtual std::string getTypenameParam (unsigned int index) const override
 Returns the type-name of the parameter with given index (the first parameter has index 0). More...
 
virtual std::string getTypenameReturnvalue () const override
 Returns the type-name of the return-value. More...
 
virtual bool hasReturnvalue () const override
 Returns true if the function has a return-value. More...
 
virtual MultiType operator() (O *object, 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) override
 Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be nullptr. More...
 
- Public Member Functions inherited from orxonox::FunctorPointer< detail::FunctionType< F, R, O, isconst, Params... >::Type, O >
 FunctorPointer (detail::FunctionType< F, R, O, isconst, Params... >::TypefunctionPointer, O *object=nullptr)
 Constructor: Initializes the base class and stores the function-pointer. More...
 
detail::FunctionType< F, R, O, isconst, Params... >::Type getFunction () const
 Returns the function-pointer. More...
 
void setFunction (detail::FunctionType< F, R, O, isconst, Params... >::TypefunctionPointer)
 Changes the function-pointer. More...
 
- Public Member Functions inherited from orxonox::FunctorMember< O >
 FunctorMember (O *object=nullptr)
 Constructor: Stores the object-pointer. More...
 
virtual ~FunctorMember ()
 
O * getObject () const
 Returns the object-pointer. More...
 
virtual voidgetRawObjectPointer () const override
 Returns the object-pointer. More...
 
virtual Functor::Type getType () const override
 Returns the type of the function: static or member. 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) override
 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...
 
void setObject (O *object)
 Assigns an object-pointer to the functor which is used to execute a member-function. More...
 
virtual void setRawObjectPointer (void *object) override
 Assigns an object-pointer to the functor which is used to execute a member-function. More...
 
virtual void setSafeMode (bool bSafeMode) override
 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...
 
- Public Member Functions inherited from orxonox::Functor
virtual ~Functor ()=default
 

Private Member Functions

template<class... Types>
const std::type_info & getTypelistIdentifier (detail::type_list< Types... >) const
 Helper function that deduces a parameter pack of types and returns the corresponding identifier. More...
 

Additional Inherited Members

- Public Types inherited from orxonox::Functor
enum  Type { Type::Static, Type::Member }
 Defines the type of a function (static or member) More...
 
- Protected Member Functions inherited from orxonox::FunctorMember< O >
virtual void objectDeleted () override
 Will be called by Destroyable::~Destroyable() if the stored object is a Destroyable and deleted and the Functor is in safe mode. More...
 
void registerObject (Destroyable *object)
 Casts the object and registers as destruction listener if the object is a Destroyable. More...
 
void registerObject (void *object)
 
void unregisterObject (Destroyable *object)
 Casts the object and unregisters as destruction listener if the object is a Destroyable. More...
 
void unregisterObject (void *object)
 
- Protected Member Functions inherited from orxonox::DestructionListener
virtual ~DestructionListener ()
 
void registerAsDestructionListener (Destroyable *object)
 
void unregisterAsDestructionListener (Destroyable *object)
 
- Protected Attributes inherited from orxonox::FunctorPointer< detail::FunctionType< F, R, O, isconst, Params... >::Type, O >
detail::FunctionType< F, R, O, isconst, Params... >::Type functionPointer_
 The stored function-pointer. More...
 
- Protected Attributes inherited from orxonox::FunctorMember< O >
bool bSafeMode_
 If true, the functor is in safe mode and registers itself as listener at the object and changes the pointer to nullptr if the object is deleted. More...
 
O * object_
 The stored object-pointer, used to execute a member-function (or nullptr for static functions) More...
 

Detailed Description

template<class F, class R, class O, bool isconst, class... Params>
class orxonox::FunctorTemplate< F, R, O, isconst, Params >

FunctorTemplate is a child class of FunctorPointer and implements all functions that need to know the exact types of the parameters, return-value, and class.

Parameters
Fthe type of the function-object (or void if a function-pointer is used).
RThe type of the return-value of the function
OThe class of the function
isconstTrue if the function is a const member-function
ParamsThe types of the parameters

This template has many parameters and is usually not used directly. It is created by createFunctor(), but only the base-classes Functor, FunctorMember, and FunctorPointer are used directly. It implements all the virtual functions that are declared by its base classes.

All template arguments can be void.

Constructor & Destructor Documentation

template<class F , class R , class O , bool isconst, class... Params>
orxonox::FunctorTemplate< F, R, O, isconst, Params >::FunctorTemplate ( typename detail::FunctionType< F, R, O, isconst, Params... >::Type  functionPointer,
O *  object = nullptr 
)
inline

Constructor: Initializes the base class.

Member Function Documentation

template<class F , class R , class O , bool isconst, class... Params>
virtual FunctorPtr orxonox::FunctorTemplate< F, R, O, isconst, Params >::clone ( )
inlineoverridevirtual

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

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual void orxonox::FunctorTemplate< F, R, O, isconst, Params >::evaluateArgument ( unsigned int  index,
MultiType argument 
) const
inlineoverridevirtual

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

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual const std::type_info& orxonox::FunctorTemplate< F, R, O, isconst, Params >::getFullIdentifier ( ) const
inlineoverridevirtual

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.

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual const std::type_info& orxonox::FunctorTemplate< F, R, O, isconst, Params >::getHeaderIdentifier ( ) const
inlineoverridevirtual

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

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual const std::type_info& orxonox::FunctorTemplate< F, R, O, isconst, Params >::getHeaderIdentifier ( unsigned int  params) const
inlineoverridevirtual

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.

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual unsigned int orxonox::FunctorTemplate< F, R, O, isconst, Params >::getParamCount ( ) const
inlineoverridevirtual

Returns the number of parameters of the function.

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
template<class... Types>
const std::type_info& orxonox::FunctorTemplate< F, R, O, isconst, Params >::getTypelistIdentifier ( detail::type_list< Types... >  ) const
inlineprivate

Helper function that deduces a parameter pack of types and returns the corresponding identifier.

template<class F , class R , class O , bool isconst, class... Params>
virtual std::string orxonox::FunctorTemplate< F, R, O, isconst, Params >::getTypenameParam ( unsigned int  index) const
inlineoverridevirtual

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

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual std::string orxonox::FunctorTemplate< F, R, O, isconst, Params >::getTypenameReturnvalue ( ) const
inlineoverridevirtual

Returns the type-name of the return-value.

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual bool orxonox::FunctorTemplate< F, R, O, isconst, Params >::hasReturnvalue ( ) const
inlineoverridevirtual

Returns true if the function has a return-value.

Implements orxonox::Functor.

template<class F , class R , class O , bool isconst, class... Params>
virtual MultiType orxonox::FunctorTemplate< F, R, O, isconst, Params >::operator() ( O *  object,
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 
)
inlineoverridevirtual

Calls the function-pointer with up to five arguments and an object. In case of a static-function, the object can be nullptr.

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

Implements orxonox::FunctorMember< O >.


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