Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

thread::CallBack Class Template Reference

Manage a list of callbacks. More...

#include <thread_util.h>

List of all members.

Public Methods

 CallBack (const CallBack &)
 CallBack ()
size_t Add (CBFunct *callback_inst)
 Add a instance to callback list. More...

bool Del (size_t ID)
void Run (const T &t)
 Run thru the callback list and call back. More...


Detailed Description

template<typename T>
class thread::CallBack< T >

Manage a list of callbacks.

This class makes the use of C++ like callbacks easy. You can simply add or remove an instance to/from callback list. If you call the method Run(const T&) all callbacks get called. It is safe and usefull, to make a instance of this class to public member of the object, that uses callbacks.

Parameters:
T  The callback get a constant reference to this type as parameter.


Constructor & Destructor Documentation

template<typename T>
thread::CallBack< T >::CallBack const CallBack< T > &   
 

Warning:
copy constructor not implemented


Member Function Documentation

template<typename T>
size_t thread::CallBack< T >::Add CBFunct   callback_inst
 

Add a instance to callback list.

Since CBFunct is abstract, you have to inherit it from CBFunct and overload the CBFunct::operator()(const Arg &). You can call this function even within a callback of the same instance.

Parameters:
callback_inst  The instance you want to add to the callback list.
Returns:
ID of your callback. You need this to remove the instance form list.

template<typename T>
bool thread::CallBack< T >::Del size_t    ID
 

\biref Delete a instance from callback list.

You can call this function even within a callback of the same instance.

Parameters:
ID  of the callback you want to delete from callback list.
Returns:
true if successfully deleted (i.e. the ID did exist)

template<typename T>
void thread::CallBack< T >::Run const T &    t
 

Run thru the callback list and call back.

Simply calls all callbacks in list, but can handle callbacks, that access the same instance (i.e. adding or deleting somthing from callback list)

Parameters:
t  Parameter you want to pass to all the callbacks.


The documentation for this class was generated from the following file:
Generated on Sun Apr 14 17:37:03 2002 for libvtql by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002