Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members

listener::Subscriber Class Reference

Class which is responsible of subscribing to a publisher in order to receives events by using Listeners. More...

#include <subscriber.h>

List of all members.

Public Member Functions

Listener::ID add_listener (Listener *l)
 Add a new Listener to this Subscriber.
bool remove_listener_with_id (const Listener::ID &id)
 Remove a Listener given its unique ID.
void remove_all_listener ()
 Remove all listeners from this Subscriber.
void add_event_filter (Listener::ID, EventFilter *)
 Install an EventFilter for a given installed Listener.
void add_event_filter (EventFilter *)
 Install an EventFilter for all installed Listener and futur Listeners to install.
void remove_all_event_filters ()
 Remove all EventFilter for the installed Listener and for the futur Listener to install.
Listenerget_listener_with_id (const Listener::ID &) const
 Get the Listener given its unique ID id.
void block_events ()
 Block the event reception.
void unblock_events ()
 Unblock the event reception.
bool are_events_blocked () const
 Return true if this Subscriber is blocked from receiving events.
void dump_subscriber (std::ostream &, int spaces=0)

Protected Member Functions

Publisherget_source ()
 Return the Publisher which sent the event.
template<typename LISTENER>
Listener::ID register_listener ()
 This method have to be used when inheriting from a Listener, in order to register this listener (do be done within the constructor).

Friends

class Publisher
class MultiplexerListener


Detailed Description

Class which is responsible of subscribing to a publisher in order to receives events by using Listeners.

When a Subscriber is destroyed, its listeners are automatically unregistered from the Publisher and destroyed. Therefor, this class doesn't need to be trackable (unlike boost::signal)

Note:
There is several ways to use the Subscriber. You can inherits from this class, or you can encapsulate this class within your class and connect the listeners to methods of your class by using basic::bind and basic::function


Member Function Documentation

Listener::ID listener::Subscriber::add_listener Listener l  ) 
 

Add a new Listener to this Subscriber.

Returns:
the unique ID of the newly insterted Listener

Publisher * listener::Subscriber::get_source  )  [inline, protected]
 

Return the Publisher which sent the event.

Only available when recieving an event or a member is called from a listener. Otherwise, return NULL

template<typename LISTENER>
Listener::ID listener::Subscriber::register_listener  )  [inline, protected]
 

This method have to be used when inheriting from a Listener, in order to register this listener (do be done within the constructor).

Returns:
Listener::ID the unique id of the registered listener

bool listener::Subscriber::remove_listener_with_id const Listener::ID &  id  ) 
 

Remove a Listener given its unique ID.

Parameters:
id the ID of the Listener to remove
Returns:
true if successful, false otherwise


The documentation for this class was generated from the following file:
Generated on Mon Jan 30 11:57:50 2006 for EventListener by  doxygen 1.3.9.1