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

listener::Listener Class Reference

Class which is responsible of listening to events. More...

#include <listener.h>

Inheritance diagram for listener::Listener:

listener::ListenerForEvent< EVENT > listener::ListenerForEvent< E > listener::MultiplexerListener List of all members.

Public Types

typedef unsigned int ID

Public Member Functions

 Listener (unsigned int priority=0)
 Listener (Publisher *, unsigned int priority=0)
void set_publisher (Publisher *)
ID get_id () const
unsigned int get_priority () const
 Get the priority of this Listener. Default value is set to 0, which is the higuest one.
void set_priority (unsigned int)
 Set the priority of this Listener. The higuest priority is 0.
void add_event_filter (EventFilter *)
 Install a new event-filter (non-permanent => that can be removed).
void add_permanent_event_filter (EventFilter *)
 Install a permanent EventFilter. When calling remove_all_event_filters, permanent EventFilter are not removed.
void remove_all_event_filters ()
 Remove all non-permanent EventFilter.
void block_events ()
 Block the Event emition.
void unblock_events ()
 Unblock the Event emition.
bool are_events_blocked () const
 Return true if this Listener is blocked from emitting events.
template<typename LISTENER>
bool inherits_from ()
 Tells if this class inherits from the LISTENER class.
virtual void dump_listener (std::ostream &, int spaces=0)
bool operator< (const Listener &l) const
bool operator> (const Listener &l) const

Protected Member Functions

Subscribersubscriber ()
 Get the Subscriber of this Listener.
Publisherpublisher ()
 Get the Publisher of this Listener.
virtual bool process_event (Event *)=0
 This method is called when receiving an event and that the filters return true after processing.
void dump_infos (std::ostream &, int spaces=0)

Friends

class SubscriberDeletePtr
class Subscriber
class Publisher

Detailed Description

Class which is responsible of listening to events.

You don't need to care about deleting listeners. Subscribers will do that for you.

Note:
Client code have to override the pure virtual protected method process_event. Also, it recommanded to create a Listener for one type of Event and only one.


Member Function Documentation

void listener::Listener::add_event_filter EventFilter  ) 
 

Install a new event-filter (non-permanent => that can be removed).

Note:
You can add as many filters as you want.

void listener::Listener::add_permanent_event_filter EventFilter  ) 
 

Install a permanent EventFilter. When calling remove_all_event_filters, permanent EventFilter are not removed.

Note:
You can add as many permanent EventFilter as you want.

virtual bool listener::Listener::process_event Event  )  [protected, pure virtual]
 

This method is called when receiving an event and that the filters return true after processing.

Returns:
true if the ecent was process, false otherwise
Usually, client code uses this method to call virtual functions (if the Listener is inherited), or basic::function (binded function type to call).

If any of the installed filters failed or if this Listener is blocked, this method is not called.

Implemented in listener::ListenerForEvent< EVENT >, listener::MultiplexerListener, and listener::ListenerForEvent< E >.

void listener::Listener::set_priority unsigned  int  ) 
 

Set the priority of this Listener. The higuest priority is 0.

If two Listeners have different priority, the Listener with the smaller priority value will be call first.


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