PDG engine v0.9.5
 All Classes Namespaces Functions Variables Groups Pages
Public Member Functions | List of all members
EventEmitter Class Reference

Distributes events to event handlers. More...

Inheritance diagram for EventEmitter:
Inheritance graph
[legend]

Public Member Functions

 addHandler (IEventHandler inHandler, int inEventType=all_events)
 add a new handler for some event type, or for all events if no type specified.
 
 blockEvent (int inEventType)
 temporarily ignore all events of a particular type.
 
 clear ()
 remove all handlers
 
 removeHandler (IEventHandler inHandler, int inEventType=all_events)
 remove a handler for some event type, or for all events (see note) if no type specified.
 
 unblockEvent (int inEventType)
 stop ignoring events of a particular type
 

Detailed Description

Distributes events to event handlers.

Precondition
API Stability: 3 - Stable. The API has proven satisfactory, but cleanup in the underlying code may cause minor changes. Backwards-compatibility is guaranteed.

The EventEmitter expects the game developer to implement IEventHandler subclasses and register them to handle various events they are interested in.

See Also
IEventHandler
Events

Member Function Documentation

addHandler ( IEventHandler  inHandler,
int  inEventType = all_events 
)

add a new handler for some event type, or for all events if no type specified.

Parameters
inHandlerthe IEventHandler object which will handle the events
inEventTypethe type of event to handle
blockEvent ( int  inEventType)

temporarily ignore all events of a particular type.

Events that are blocked are NOT cached for later, they are just dropped.

Parameters
inEventTypethe type of event to block
clear ( )

remove all handlers

removeHandler ( IEventHandler  inHandler,
int  inEventType = all_events 
)

remove a handler for some event type, or for all events (see note) if no type specified.

If the handler is listed multiple times it will only remove it once.

It is safe to call remove handler from within an event handler's handleEvent() call.

Parameters
inHandlerthe object to handle events
inEventTypethe type of event to stop handling
Note
inType == all_events doesn't work quite like you might expect. If you have registered a handler for multiple events, but not with all_events, doing removeHandler(handler, all_events) will do nothing. Basically, all_events is a special event type that matches all event types when considering whether to invoke a handler or not.
unblockEvent ( int  inEventType)

stop ignoring events of a particular type

Parameters
inEventTypethe type of event to unblock

User Comments