vpr::ThreadRunFunctor< OBJ_TYPE > Class Template Reference

A variation on vpr::ThreadMemberFunctor that requires a class that implements the "runnable" concept. More...

#include <vpr/Thread/ThreadFunctor.h>

Inheritance diagram for vpr::ThreadRunFunctor< OBJ_TYPE >:

Inheritance graph
[legend]
Collaboration diagram for vpr::ThreadRunFunctor< OBJ_TYPE >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef void(OBJ_TYPE::*) FunPtr ()

Public Member Functions

 ThreadRunFunctor (OBJ_TYPE *theObject)
virtual ~ThreadRunFunctor ()
void operator() (void *arg)
 Overloaded operator() used for invoking the function encapsulated by this object.
void operator() ()
 Overloaded operator() used for invoking the function encapsulated by this object.
virtual void setArg (void *arg)
 Sets the argument passed to the encapsulated function.
virtual bool isValid ()
 Function to see if we have a valid functor.

Detailed Description

template<typename OBJ_TYPE>
class vpr::ThreadRunFunctor< OBJ_TYPE >

A variation on vpr::ThreadMemberFunctor that requires a class that implements the "runnable" concept.

That is, the class must have a run() method with the following signature: void run(). No argument will be passed to the runnable object when its run() method is invoked. Instead, it is up to the class author to ensure that the object has all information it needs to do its job before the thread is spawned.

Definition at line 173 of file ThreadFunctor.h.


Member Typedef Documentation

template<typename OBJ_TYPE>
typedef void(OBJ_TYPE::* ) vpr::ThreadRunFunctor< OBJ_TYPE >::FunPtr()

Definition at line 176 of file ThreadFunctor.h.


Constructor & Destructor Documentation

template<typename OBJ_TYPE>
vpr::ThreadRunFunctor< OBJ_TYPE >::ThreadRunFunctor ( OBJ_TYPE *  theObject  )  [inline]

Definition at line 178 of file ThreadFunctor.h.

00179       : mObject(theObject)
00180       , mFunction(NULL)
00181    {
00182       mFunction = &OBJ_TYPE::run;
00183    }

template<typename OBJ_TYPE>
virtual vpr::ThreadRunFunctor< OBJ_TYPE >::~ThreadRunFunctor (  )  [inline, virtual]

Definition at line 185 of file ThreadFunctor.h.

00186    {
00187       mObject   = (OBJ_TYPE*) 0xDEADBEEF;
00188 //      mFunction = (FunPtr) 0xDEADBEEF;
00189    }


Member Function Documentation

template<typename OBJ_TYPE>
void vpr::ThreadRunFunctor< OBJ_TYPE >::operator() ( void *  arg  )  [inline, virtual]

Overloaded operator() used for invoking the function encapsulated by this object.

This version takes an argument that is passed on to the function.

Parameters:
arg The argument to be passed to the encapsulated function.

Implements vpr::BaseThreadFunctor.

Definition at line 191 of file ThreadFunctor.h.

00192    {
00193       boost::ignore_unused_variable_warning(arg);
00194       (mObject->*mFunction)();
00195    }

template<typename OBJ_TYPE>
void vpr::ThreadRunFunctor< OBJ_TYPE >::operator() (  )  [inline, virtual]

Overloaded operator() used for invoking the function encapsulated by this object.

This version takes no argument and instead passes the argument given when this object was constructed.

Implements vpr::BaseThreadFunctor.

Definition at line 197 of file ThreadFunctor.h.

00198    {
00199       (mObject->*mFunction)();
00200    }

template<typename OBJ_TYPE>
virtual void vpr::ThreadRunFunctor< OBJ_TYPE >::setArg ( void *  arg  )  [inline, virtual]

Sets the argument passed to the encapsulated function.

This will be used when the function is invoked through the overloaded operator().

Implements vpr::BaseThreadFunctor.

Definition at line 202 of file ThreadFunctor.h.

00203    {
00204       boost::ignore_unused_variable_warning(arg);
00205    }

template<typename OBJ_TYPE>
virtual bool vpr::ThreadRunFunctor< OBJ_TYPE >::isValid (  )  [inline, virtual]

Function to see if we have a valid functor.

Implements vpr::BaseThreadFunctor.

Definition at line 207 of file ThreadFunctor.h.

References vprASSERT.

00208    {
00209       if ( (NULL == mObject) || ((OBJ_TYPE*) 0xDEADBEEF == mObject) )
00210       {
00211          vprASSERT(NULL != mObject);
00212          vprASSERT((OBJ_TYPE*)0xDEADBEEF != mObject);
00213          return false;
00214       }
00215       else if ( (NULL == mFunction) /* || ((FunPtr) 0xDEADBEEF == mFunction) */ )
00216       {
00217          return false;
00218       }
00219       else
00220       {
00221          return true;
00222       }
00223    }


The documentation for this class was generated from the following file:
Generated on Thu Jan 4 10:55:56 2007 for VR Juggler Portable Runtime by  doxygen 1.5.1