dtDAL::Functor Class Reference

This class is the base Functor class. More...

#include <functor.h>

Inheritance diagram for dtDAL::Functor:

dtDAL::Functor0 dtDAL::Functor0Ret< RT > dtDAL::Functor0Ret< bool > dtDAL::Functor0Ret< double > dtDAL::Functor0Ret< dtDAL::GameEvent * > dtDAL::Functor0Ret< float > dtDAL::Functor0Ret< int > dtDAL::Functor0Ret< long > dtDAL::Functor0Ret< osg::Vec2 > dtDAL::Functor0Ret< osg::Vec2d > dtDAL::Functor0Ret< osg::Vec2f > dtDAL::Functor0Ret< osg::Vec3 > dtDAL::Functor0Ret< osg::Vec3d > dtDAL::Functor0Ret< osg::Vec3f > dtDAL::Functor0Ret< osg::Vec4 > dtDAL::Functor0Ret< osg::Vec4d > dtDAL::Functor0Ret< osg::Vec4f > dtDAL::Functor0Ret< std::string > dtDAL::Functor0Ret< T & > dtDAL::Functor1< P1 > dtDAL::Functor1< bool > dtDAL::Functor1< const osg::Vec2 & > dtDAL::Functor1< const osg::Vec2d & > dtDAL::Functor1< const osg::Vec2f & > dtDAL::Functor1< const osg::Vec3 & > dtDAL::Functor1< const osg::Vec3d & > dtDAL::Functor1< const osg::Vec3f & > dtDAL::Functor1< const osg::Vec4 & > dtDAL::Functor1< const osg::Vec4d & > dtDAL::Functor1< const osg::Vec4f & > dtDAL::Functor1< const std::string & > dtDAL::Functor1< double > dtDAL::Functor1< dtDAL::GameEvent * > dtDAL::Functor1< float > dtDAL::Functor1< int > dtDAL::Functor1< long > dtDAL::Functor1< T & >

List of all members.

Public Types

typedef void(Functor::* BaseMemFunc )()
typedef void(* BaseFunc )()

Public Member Functions

BaseFunc getBaseFunc () const
void * getCallee () const
const char * getMemFunc () const

Protected Member Functions

 Functor ()
 Functor (const void *c, BaseFunc f, const void *mf, size_t sz)

Protected Attributes

union {
   BaseFunc   f
   char   memFunc [16]
}; 
void * callee
 Generic pointer to a class instance who's member function the functor should invoke.


Detailed Description

This class is the base Functor class.

A Functor is an object that acts like a function. It is therefore, an object-oriented way of encapsulating function pointers. These can be quite handy for complex callback mechanisms. Much of this Functor and its set of classes was inspired by the paper: CALLBACKS IN C++ USING TEMPLATE FUNCTORS, by Rich Hickey

The current implementation of Functor supports the following types:
Functor0 - Function with no parameters and no return value.
Functor1 - Function with 1 parameter and no return value.
Functor2 - Function with 2 parameters and no return value.
Functor3 - Function with 3 parameters and no return value.
Functor4 - Function with 4 parameters and no return value.
Functor0Ret - Function with no parameters and a return value.
Functor1Ret - Function with 1 parameter and a return value.
Functor2Ret - Function with 2 parameters and a return value.
Functor3Ret - Function with 3 parameters and a return value.
Functor4Ret - Function with 4 parameters and a return value.
Functors with no return value should be created using the MakeFunctor function. The functors with a return value should be created using the MakeFunctorRet function. Each function has three versions for each of the functor types. These versions support const class member functions, non-const class member functions, and regular functions. Once created, a functor can be treated like an ordinary function since each functor has an operator() which is paramaterized on both the parameters and return type.
Note:
The functors are completely type-safe and work correctly when used with virtual functions. They also are flexible such that a function with a return value on a non-return value functor will be safely ignored.

Member Typedef Documentation

typedef void(Functor::* dtDAL::Functor::BaseMemFunc)()

typedef void(* dtDAL::Functor::BaseFunc)()


Constructor & Destructor Documentation

dtDAL::Functor::Functor (  )  [inline, protected]

dtDAL::Functor::Functor ( const void *  c,
BaseFunc  f,
const void *  mf,
size_t  sz 
) [inline, protected]


Member Function Documentation

BaseFunc dtDAL::Functor::getBaseFunc (  )  const [inline]

void* dtDAL::Functor::getCallee (  )  const [inline]

const char* dtDAL::Functor::getMemFunc (  )  const [inline]


Member Data Documentation

BaseFunc dtDAL::Functor::f

char dtDAL::Functor::memFunc[16]

union { ... } [protected]

void* dtDAL::Functor::callee [protected]

Generic pointer to a class instance who's member function the functor should invoke.

This is typecast'd to the appropriate class in the specific functor implementation.


http://www.delta3d.org
2.0.0 generated 14 Feb 2008