NewNet::Event< T > Class Template Reference

Simple event dispatcher class. More...

#include <nnevent.h>

Inheritance diagram for NewNet::Event< T >:

NewNet::Object List of all members.

Public Member Functions

 Event ()
 Constructor.
 Event (const Event &that)
 Copy constructor.
virtual ~Event ()
 Destructor.
void clear ()
 Empty the event callback list.
Callbackconnect (Callback *callback)
 Connect a callback to the event.
template<class ObjectType, typename MethodType>
Callbackconnect (ObjectType *object, MethodType method)
 Connect callback to a method of an object to the event.
void disconnect (Callback *callback)
 Disconnect a callback from the event.
void operator() (T t)
 Emit the event.

Static Public Member Functions

template<class ObjectType, typename MethodType>
static Callbackbind (ObjectType *object, MethodType method)
 Create a callback to a bound method.

Classes

class  Callback
 Abstract callback type for Event. More...

Detailed Description

template<typename T>
class NewNet::Event< T >

The NewNet::Event class provides a simple and easy to use event aggregation solution. Callbacks can be registered to an event that will be invoked upon emitting the event.

Definition at line 35 of file nnevent.h.


Constructor & Destructor Documentation

template<typename T>
NewNet::Event< T >::Event (  )  [inline]

Create a new event to which you can register callbacks.

Definition at line 167 of file nnevent.h.

template<typename T>
NewNet::Event< T >::Event ( const Event< T > &  that  )  [inline]

When an event is copied, all the callbacks registered to the original event will also be connected to this event.

Definition at line 172 of file nnevent.h.

template<typename T>
virtual NewNet::Event< T >::~Event (  )  [inline, virtual]

Disconnects all callbacks from the event. Note: see clear().

Definition at line 182 of file nnevent.h.


Member Function Documentation

template<typename T>
void NewNet::Event< T >::clear (  )  [inline]

Call this to remove all the callbacks from this event. Note: the event stores a RefPtr to all the callbacks registered. Clearing the event may delete the callback if there are no other references to it.

Definition at line 193 of file nnevent.h.

Referenced by NewNet::Event< ClientType * >::~Event().

template<typename T>
Callback* NewNet::Event< T >::connect ( Callback callback  )  [inline]

Add a callback to this event so that it will get invoked when the event is emitted. Note: stores a RefPtr to the callback.

Definition at line 202 of file nnevent.h.

Referenced by NewNet::Event< ClientType * >::connect(), and NewNet::Event< ClientType * >::Event().

template<typename T>
template<class ObjectType, typename MethodType>
static Callback* NewNet::Event< T >::bind ( ObjectType *  object,
MethodType  method 
) [inline, static]

This will construct a callback object that will invoke a method of an object.

Definition at line 217 of file nnevent.h.

Referenced by NewNet::Reactor::addTimeout(), and NewNet::Event< ClientType * >::connect().

template<typename T>
template<class ObjectType, typename MethodType>
Callback* NewNet::Event< T >::connect ( ObjectType *  object,
MethodType  method 
) [inline]

Add a callback to a method of an object so that it will get invoked when the event is emitted. Note: stores a RefPtr to the newly created callback.

Definition at line 227 of file nnevent.h.

template<typename T>
void NewNet::Event< T >::disconnect ( Callback callback  )  [inline]

Remove a callback from the invocation list. Note: the event stores a RefPtr to the callback. If the event holds the last RefPtr, the callback will be deleted.

Definition at line 236 of file nnevent.h.

Referenced by NewNet::Event< ClientType * >::clear().

template<typename T>
void NewNet::Event< T >::operator() ( t  )  [inline]

Emit the event, invokes the Callback::operator()(T t) method of all registered callbacks.

Definition at line 257 of file nnevent.h.


The documentation for this class was generated from the following file:
Generated on Sun Jan 7 14:00:01 2007 for NewNet by  doxygen 1.5.1