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

MCEvent Class Reference

Implementation of light-weight events. More...

#include <mcllib/MCEvent.h>

Inheritance diagram for MCEvent:

MCVariantType List of all members.

Public Types

typedef mcuint32 MCEventId
 Type of an event id.

Public Member Functions

MCEventId getEventId () const
 Get the event Id.
const MCStringgetEventName () const
 Get the registered name of the event.
 MCEvent (const MCEvent &event)
 Copy constructor.
 MCEvent (MCEventId eventId, const MCVariantType &vt)
 Event with data.
 MCEvent (MCEventId eventId)
 Event with no data.
void notify () const
 Notify listeners of this event.

Static Public Member Functions

void addListener (MCEventId eventId, MCEventListener *pListener)
 Add an event listener.
MCEventId getEventId (const MCString &eventName)
 Get the event Id for a registered event name.
const MCStringgetEventName (MCEventId eventId)
 Get the name of an event.
MCEventId registerEvent (const MCString &name)
 Register an event name.
void removeListener (MCEventId eventId, MCEventListener *pListener)
 Remove an event listener.

Detailed Description

Implementation of light-weight events.

Events are sent to all registered listeners. Different types of event can be listened for independently. An event Id is used to distinguish between different types of event. Event Ids are obtained via the registerEvent static method which supplies an event Id given an event name. It is recommended that the following form be used for event names - event.domain (e.g. event.my.com). Do not use the domain miba.co.uk. An event may have data associated with it in the form of a variant. Variants allow arbitrary data to be handled in a run-time type-safe manner. Note: To obtain any stored data use the base class methods (variant type).

See also:
MCVariantType


Constructor & Destructor Documentation

MCEvent MCEventId  eventId  ) 
 

Event with no data.

Parameters:
eventId the id of the event obtained from getEventId()

MCEvent MCEventId  eventId,
const MCVariantType vt
 

Event with data.

Parameters:
eventId the id of the event obtained from getEventId()
vt the data for the event


Member Function Documentation

void addListener MCEventId  eventId,
MCEventListener pListener
[static]
 

Add an event listener.

Parameters:
eventId is the event that the listener is interested in. eventId must have been obtained through a call to the registerEvent() method. If eventId has not been registered an exception is thrown.
pListener is a listener allocated using new.

MCEventId getEventId const MCString eventName  )  [static]
 

Get the event Id for a registered event name.

Parameters:
eventName name of the event to get the id for. An exception is thrown if the named event does not exist.
Returns:
the event id for the registered event.

MCEventId getEventId  )  const
 

Get the event Id.

Returns:
the event id for this event

const MCString& getEventName MCEventId  eventId  )  [static]
 

Get the name of an event.

Parameters:
eventId the eventId to get the name of. If the event Id has not been registered an exception is thrown.
Returns:
the name of the eventId

const MCString& getEventName  )  const
 

Get the registered name of the event.

Uses the event id for the event to obtain the name.

Returns:
the registered name of the event

void notify  )  const
 

Notify listeners of this event.

The method may return before all registered listeners have been notified.

MCEventId registerEvent const MCString name  )  [static]
 

Register an event name.

Parameters:
name the name of the event to register
Returns:
the event Id for the name. If the name is already registered the existing event Id is returned. Note that event ids may change between application invocations. This applies to system event ids also.

void removeListener MCEventId  eventId,
MCEventListener pListener
[static]
 

Remove an event listener.

Parameters:
eventId is the event that the listener was registered on. eventId must have been obtained through a call to the registerEvent() method. If eventId has not been registered an exception is thrown.
pListener is a listener that was previously registered with addListener(). If pListener is not registered for the specified eventId no action is taken.


Generated on Wed Jan 12 19:05:49 2005 for MCLLIB by  doxygen 1.3.9.1