VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions
DtCallbackListT< Callback > Class Template Reference

template<typename Callback>
class DtCallbackListT< Callback >

This is a templated class which manages a list of callbacks. A class is instantiated from this template by specifying the the callback class. The callback class must have an operator() which calls the callback. The callback can take any number of arguments which will be passed to it from invokeCallbacks.

Note
It is safe to add and remove callbacks from this table during callback invocation, so callbacks functions may safely remove themselves.
It is safe to add and remove callbacks simultaneously from multiple threads.
A version of this class for callback with no arguments is DtNoArgumentCallbackList.

Classes

struct  DtCallbackInfoType
 

Public Member Functions

 DtCallbackListT ()
 
DtCallbackConnection addCallback (const Callback &callback, bool *addedFirst=0)
 
void removeCallback (const Callback &callback, bool *removedLast=0)
 
void removeCallback (const boost::function< bool(const Callback &)> &removePredicate, bool *removedLast=0)
 
void removeAll ()
 
void invokeCallbacks ()
 
template<typename T1 >
void invokeCallbacks (const T1 &)
 
template<typename T1 , typename T2 >
void invokeCallbacks (const T1 &, const T2 &)
 
template<typename T1 , typename T2 , typename T3 >
void invokeCallbacks (const T1 &, const T2 &, const T3 &)
 

Protected Member Functions

bool disconnect (const DtCallbackInfoType &)
 

Protected Attributes

tbb::spin_mutex myMutex
 
DtCallbackInfoType::List myCallbackList
 
unsigned myCallbackCount
 

Private Member Functions

 DtCallbackListT (const DtCallbackListT &)
 
DtCallbackListToperator= (const DtCallbackListT &)
 

Constructor & Destructor Documentation

template<typename Callback >
DtCallbackListT< Callback >::DtCallbackListT ( )
inline

Default constructor.

template<typename Callback >
DtCallbackListT< Callback >::DtCallbackListT ( const DtCallbackListT< Callback > &  )
private

Member Function Documentation

template<typename Callback >
DtCallbackConnection DtCallbackListT< Callback >::addCallback ( const Callback callback,
bool addedFirst = 0 
)

Adds a new callback to the list. A duplicate entry is checked for first, and if found, this new function is not added.

Note
It is safe to call this from inside a callback function.
Parameters
addedFirstif supplied will be set to true if this was the first callback added.
Returns
Connection object to disconnect this callback.
template<typename Callback >
void DtCallbackListT< Callback >::removeCallback ( const Callback callback,
bool removedLast = 0 
)

Removes the specified callback from the list if it exists. Uses the equality operator of the supplied callback to test which callback to remove.

Note
It is safe to call this from inside a callback function.
Parameters
removedLastif supplied will be set to true if the removed callback was the last one in the list.
template<typename Callback >
void DtCallbackListT< Callback >::removeCallback ( const boost::function< bool(const Callback &)> &  removePredicate,
bool removedLast = 0 
)

Removes the specified callback from the list if it exists.

Note
It is safe to call this from inside a callback function.
Parameters
removePredicatepredicate to select which callback to remove. Use this if constructing a Callback object for equality testing is expensive.
removedLastif supplied will be set to true if the removed callback was the last one in the list.
template<typename Callback >
void DtCallbackListT< Callback >::removeAll ( )

Removes all callbacks that have been registered.

template<typename Callback >
void DtCallbackListT< Callback >::invokeCallbacks ( )

Invokes all the callbacks currently on the callback list.

Note
These methods must not be called by any of the callbacks they invoke.
template<typename Callback >
template<typename T1 >
void DtCallbackListT< Callback >::invokeCallbacks ( const T1 &  )

Invokes all the callbacks currently on the callback list.

Note
These methods must not be called by any of the callbacks they invoke.
template<typename Callback >
template<typename T1 , typename T2 >
void DtCallbackListT< Callback >::invokeCallbacks ( const T1 &  ,
const T2 &   
)

Invokes all the callbacks currently on the callback list.

Note
These methods must not be called by any of the callbacks they invoke.
template<typename Callback >
template<typename T1 , typename T2 , typename T3 >
void DtCallbackListT< Callback >::invokeCallbacks ( const T1 &  ,
const T2 &  ,
const T3 &   
)

Invokes all the callbacks currently on the callback list.

Note
These methods must not be called by any of the callbacks they invoke.
template<typename Callback >
bool DtCallbackListT< Callback >::disconnect ( const DtCallbackInfoType )
protected
template<typename Callback >
DtCallbackListT& DtCallbackListT< Callback >::operator= ( const DtCallbackListT< Callback > &  )
private

Member Data Documentation

template<typename Callback >
tbb::spin_mutex DtCallbackListT< Callback >::myMutex
mutableprotected
template<typename Callback >
DtCallbackInfoType::List DtCallbackListT< Callback >::myCallbackList
protected
template<typename Callback >
unsigned DtCallbackListT< Callback >::myCallbackCount
protected

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

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)