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

EventSender< EvType > Class Template Reference

List of all members.

Public Types

typedef Listener< EvType > TListener
 Simpler form of Listener<EvType>.


Static Public Methods

void remove (TListener &)
void add (TListener &)
void send (const EvType &)
bool isSending ()
bool hasListeners ()
unsigned int getNumListeners ()
unsigned int getMinNumIgnored ()

Friends

class Listener< EvType >
 So Listener<EvType> can call register etc.


Detailed Description

template<typename EvType>
class EventSender< EvType >

Sender of events of type EvType. All public methods are static since there is only one instance of the sender. EventSender maintains a registry of listeners who want to receive the events it sends.

Usage:

Definition at line 34 of file EventSender.hh.


Member Function Documentation

template<typename EvType>
void EventSender< EvType >::add TListener   listener [inline, static]
 

Add the listener to the registry. Does nothing if the listener is already registered.

Definition at line 196 of file EventSender.hh.

template<typename EvType>
unsigned int EventSender< EvType >::getMinNumIgnored   [inline, static]
 

Get how many listeners have ignored the event that is currently being sent and that they have received. This number is reset to 0 before every call to send(const EvType&). This number is a minimum, since a listener is not required to tell EventSender<EvType> that it is ignoring an event.

Definition at line 132 of file EventSender.hh.

template<typename EvType>
unsigned int EventSender< EvType >::getNumListeners   [inline, static]
 

Get how many listeners are currently registered. Note that if isSending() is true, then this number does not take into account listeners that are queued for registration/removal.

Definition at line 143 of file EventSender.hh.

template<typename EvType>
bool EventSender< EvType >::hasListeners   [inline, static]
 

Are there listeners currently registered? If this returns false, creating and send()ing and event just wastes cpu cycles since no one will hear event.

Returns:
true if there are listeners in registry

Definition at line 119 of file EventSender.hh.

template<typename EvType>
bool EventSender< EvType >::isSending   [inline, static]
 

Is this event sender currently sending the event to its listeners? True if yes, false otherwise.

Definition at line 176 of file EventSender.hh.

Referenced by Listener< EvType >::ignoreThisEvent().

template<typename EvType>
void EventSender< EvType >::remove TListener   listener [inline, static]
 

Remove the listener from the registry. Does nothing if the listener is not in the registry.

Definition at line 186 of file EventSender.hh.

template<typename EvType>
void EventSender< EvType >::send const EvType &    event [inline, static]
 

Send the event to its listeners.

  • Upon return, getNumIgnored() will have the number of listeners who have ignored the event.
  • If one of the called listeners calls registerListener or removeListener, the operation will be queued and processed only after the event has been sent to all listeners. This insures the integrity of the list of listeners during the send() process.
  • Throws an exception if called while another send() is taking place, see IllegalSendError. You can use isSending() to test whether a send is taking place.
  • All other exceptions are caught
Exceptions:
IllegalSendError 

Definition at line 166 of file EventSender.hh.

Referenced by PolymorphEvent::~PolymorphEvent().


The documentation for this class was generated from the following files:
Generated on Sun Feb 16 16:56:24 2003 for C++ Event Handling Template Library by doxygen1.2.18