Nimbus  0.2
A game... with arrows... which should be clouds
 All Classes Functions Variables Enumerations Enumerator
Nimbus::EventSystem Class Reference

#include <EventSystem.h>

Classes

class  GlobalListener
 

Public Types

enum  EventType {
  SHUTDOWN, TICK, MOUSE_DOWN, MOUSE_UP,
  MOUSE_UPDATE, MOUSE_POSITION_UPDATE, MOUSE_POSITION_START, MOUSE_POSITION_END,
  CREATE_ENTITY, DESTROY_ENTITY, SOAR_ENTITY, TRANSLATE_ENTITY,
  ENTITY_TRANSLATED, TRANSLATION_QUERY, FLOCK_UPDATE
}
 

Public Member Functions

 EventSystem (GameEntityId owner=0)
 
virtual ~EventSystem (void)
 
bool registerListener (EventListener *listener, EventType type, filtermap filter=filtermap())
 
void unregisterListener (EventListener *listener, EventType type, filtermap filter=filtermap())
 
void fireEvent (EventType type, const payloadmap &payload=payloadmap(), EventListener *responder=NULL)
 

Static Public Member Functions

static EventSysteminitializeSingleton ()
 
static EventSystemgetSingleton ()
 

Detailed Description

The EventSystem framework handles the receving and dispatching of events to registered EventListeners.

The EventSystem is responsible for dispatching and allowing the firing of events to the registered EventListeners. EventListeners are registered and deregistered via their appropriate commands. When an EventListener is registered it will be registered to a specific type of event that that listener is built to handle.

The Events will be fired using EventSystem's functions. These events will be evaluated and distributed to their registered events.

All hail the glorious helix fossil.

Member Enumeration Documentation

EventType represents the type of event being fired or handled. These enumerations will be added to as the application expands.

Enumerator
SHUTDOWN 

The shutdown event is fired when a system asks the program to exit. The event will be handled by the main application and will proceed to cleanly shutdown all subsystems.

Payload: NONE

TICK 

An event which fires at a given rate so that more expensive operations may be spaced out.

        Payload: NONE
MOUSE_DOWN 

An event fired whenever a button on the mouse is pressed down.

        Payload:
            "ButtonPressed" => OIS::MouseButtonID
            "ScreenPosition" => Ogre::Vector2
MOUSE_UP 

An event fired whenever a button on the mouse is released.

        Payload:
            "ButtonPressed" => OIS::MouseButtonID
            "ScreenPosition" => Ogre::Vector2
MOUSE_UPDATE 

An event fired whenever the mouse moves.

        Payload:
            "ScreenPosition" => Ogre::Vector2
MOUSE_POSITION_UPDATE 

An event fired whenever the mouse moves.

        Payload:
            "Context" => std::string
            "ScreenPosition" => Ogre::Vector2
            "WorldRay" => Ogre::Ray
MOUSE_POSITION_START 

An event fired whenever the mouse moves.

May not include a payload Payload: "Context" => std::string "ScreenPosition" => Ogre::Vector2 "WorldRay" => Ogre::Ray

MOUSE_POSITION_END 

An event fired whenever the mouse moves.

May not include a payload Payload: "Context" => std::string "ScreenPosition" => Ogre::Vector2 "WorldRay" => Ogre::Ray

CREATE_ENTITY 

The event that causes the EntityFactory to produce a new entity of given type.

        Payload:
            "EntityType" => std::string
            "PositionVector" => Ogre::Vector3   // Absolute, world position (optional)
            "FacingVector" => Ogre::Vector3     // Facing vector, units in world absolute world space,
                                                    begins at the object... have fun interpretting that (optional)
            "RotationVector" => Ogre::Vector3   // Absolute, rotation vector <pitch, yaw, roll> (optional)

        Responder Payload:
            "EntityId" => GameEntityId
DESTROY_ENTITY 

The event that causes an entity to be dropped from the world and destroyed. (Don't worry... it's humane.)

        Payload:
            "EntityId" => GameEntityId
SOAR_ENTITY 

The event which carries wind induced movement information. Handled by the flocking group associated with the given entity.

        Payload:
            "EntityId" => GameEntityId
            "PositionDelta" => Ogre::Vector3
TRANSLATE_ENTITY 

The event that translates an entity in virtual world space. Used to move the entity.

        Payload:
            "EntityId" => int
            "PositionVector" => Ogre::Vector3   // Absolute, world position (optional)
            "PositionDelta" => Ogre::Vector3    // Relative position vector, applied per frame (optional)
            "RotationVector" => Ogre::Vector3   // Absolute, rotation vector <pitch, yaw, roll> (optional)
            "RotationDelta" => Ogre::Vector3    // Relative rotation vector, applied per frame (optional)
            "ScaleVector" => Ogre::Vector3      // Scale vector, should be absolute scale factor with 1.0 being original size (optional)
            "FacingVector" => Ogre::Vector3     // Facing vector, units in world absolute world space,
                                                    begins at the object (optional)
ENTITY_TRANSLATED 

The event that notifies behaviours when the entity is actually translated.

        Payload:
            "EntityId" => int
            "PositionVector" => Ogre::Vector3   // Absolute, world position (optional)
            "FacingVector" => Ogre::Vector3     // The direction the entity is currently facing (optional)
            "RotationVector" => Ogre::Vector3   // The rotation <pitch, yaw, roll> vector (optional)
            "ScaleVector" => Ogre::Vector3      // Scale vector, should be absolute scale factor with 1.0 being original size (optional)
TRANSLATION_QUERY 

The event that requests about an entity's position. Quite possibly a very bad idea to use en masse... which is, of course, what I intend to do (for lack of a better idea).

Payload: "EntityId" => int

Responder Payload: "PositionVector" => Ogre::Vector3 // Absolute, world position "FacingVector" => Ogre::Vector3 // The direction the entity is currently facing "RotationVector" => Ogre::Vector3 // The rotation <pitch, yaw, roll> vector

FLOCK_UPDATE 

The event which lets a Flocking behaviour know its new entity list.

        Payload:
            "EntityId" => GameEntityId
            "EntityList" => list<GameEntityId>

Constructor & Destructor Documentation

EventSystem::EventSystem ( GameEntityId  owner = 0)

EventSystem constructor, yep!

Parameters
ownerIdThe id of the owning entity.
EventSystem::~EventSystem ( void  )
virtual

EventSystem destructor, it DESTROYS THINGS!

Member Function Documentation

void EventSystem::fireEvent ( EventType  type,
const payloadmap &  payload = payloadmap(),
EventListener responder = NULL 
)

Fires an Event to the EventSystem to distribute to the appropriate listeners.

Parameters
eventA reference to the Event to fire.
typeThe type of Event to fire.

Here is the caller graph for this function:

static EventSystem* Nimbus::EventSystem::getSingleton ( )
inlinestatic

Gets the singleton.

Returns
The singleton.

NOTE: CAN return a null value if the EventSystem has not been initialized!!

Here is the caller graph for this function:

EventSystem * EventSystem::initializeSingleton ( )
static

Initializes the global event system singleton.

Returns
A pointer to the singleton just created.
bool EventSystem::registerListener ( EventListener listener,
EventType  type,
filtermap  filter = filtermap() 
)

Used to register an EventListener to the system for a certain type of Event.

Parameters
listenerA reference to an isntance of the listener for the Event type.
typeThe type of Event the listener would like to listen for.
filterThe filter for the events which this listener should listen to.
Returns
True for a successful registration, false if the listener could not be registered.

Here is the call graph for this function:

Here is the caller graph for this function:

void EventSystem::unregisterListener ( EventListener listener,
EventType  type,
filtermap  filter = filtermap() 
)

Used to deregister a previously registered EventListener.

Parameters
listenerA reference to the EventListener to deregister.
typeThe type of Event the listener is registered to.
filterThe filter for the event which this listener is listening to.

Here is the call graph for this function:

Here is the caller graph for this function:


The documentation for this class was generated from the following files: