OpenWalnut  1.4.0
Public Types | Public Member Functions | Private Attributes | List of all members
WGEFunctorCallback< Type > Class Template Reference

This callback allows you a simple usage of callbacks in your module. More...

#include <WGEFunctorCallback.h>

+ Inheritance diagram for WGEFunctorCallback< Type >:

Public Types

typedef osg::ref_ptr< WGEFunctorCallbackSPtr
 Shared pointer. More...
 
typedef osg::ref_ptr< const WGEFunctorCallbackConstSPtr
 Const shared pointer. More...
 
typedef boost::function< void(Type *)> FunctorType
 The type of functor supported in this callback. More...
 

Public Member Functions

 WGEFunctorCallback (FunctorType functor)
 Default constructor. More...
 
virtual ~WGEFunctorCallback ()
 Destructor. More...
 
virtual void operator() (Type *handled, osg::NodeVisitor *nv)
 This operator gets called by OSG every update cycle. More...
 
virtual void update (osg::NodeVisitor *nv, Type *handled)
 This gets called by OSG every update cycle. More...
 

Private Attributes

FunctorType m_functor
 The functor getting called each callback. More...
 

Detailed Description

template<typename Type = osg::Node>
class WGEFunctorCallback< Type >

This callback allows you a simple usage of callbacks in your module.

The callback uses function pointers and calls them every update cycle. This is especially useful if you want to use a callback in a module without the need of writing subclasses providing a shared_ptr to the parent module.

Template Parameters
Typethe callback type. You can specify every class that has a nested class called "Callback".

Definition at line 46 of file WGEFunctorCallback.h.

Member Typedef Documentation

template<typename Type = osg::Node>
typedef osg::ref_ptr< const WGEFunctorCallback > WGEFunctorCallback< Type >::ConstSPtr

Const shared pointer.

Definition at line 57 of file WGEFunctorCallback.h.

template<typename Type = osg::Node>
typedef boost::function< void ( Type* )> WGEFunctorCallback< Type >::FunctorType

The type of functor supported in this callback.

Definition at line 62 of file WGEFunctorCallback.h.

template<typename Type = osg::Node>
typedef osg::ref_ptr< WGEFunctorCallback > WGEFunctorCallback< Type >::SPtr

Shared pointer.

Definition at line 52 of file WGEFunctorCallback.h.

Constructor & Destructor Documentation

template<typename Type >
WGEFunctorCallback< Type >::WGEFunctorCallback ( FunctorType  functor)
explicit

Default constructor.

Creates the callback and sets the specified functor instance.

Parameters
functorthe function pointer.

Definition at line 102 of file WGEFunctorCallback.h.

template<typename Type >
WGEFunctorCallback< Type >::~WGEFunctorCallback ( )
virtual

Destructor.

Definition at line 110 of file WGEFunctorCallback.h.

Member Function Documentation

template<typename Type >
void WGEFunctorCallback< Type >::operator() ( Type *  handled,
osg::NodeVisitor *  nv 
)
virtual

This operator gets called by OSG every update cycle.

It calls the specified functor.

Parameters
handledthe osg node, stateset or whatever
nvthe node visitor

Definition at line 116 of file WGEFunctorCallback.h.

References WGECallbackTraits< Type >::traverse().

template<typename Type >
void WGEFunctorCallback< Type >::update ( osg::NodeVisitor *  nv,
Type *  handled 
)
virtual

This gets called by OSG every update cycle.

It calls the specified functor.

Notes:
we provide several versions here as the OSG does not uniformly use operator().
Parameters
handledthe osg node, stateset or whatever
nvthe node visitor

Definition at line 124 of file WGEFunctorCallback.h.

Member Data Documentation

template<typename Type = osg::Node>
FunctorType WGEFunctorCallback< Type >::m_functor
private

The functor getting called each callback.

Definition at line 98 of file WGEFunctorCallback.h.


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