nrEngine::EventManager Class Reference
[Event-Management]

Main class providing the event messaging system. More...

Inheritance diagram for nrEngine::EventManager:

nrEngine::ITask nrEngine::IThread

Public Member Functions

Result createChannel (const std::string &name)
Result removeChannel (const std::string &name)
SharedPtr< EventChannelgetChannel (const std::string &name)
Result emit (const std::string &name, SharedPtr< Event > event)
Result emitSystem (SharedPtr< Event > event)
Result updateTask ()
SharedPtr< EventcreateEvent (const std::string &eventType)
Result registerFactory (const std::string &name, SharedPtr< EventFactory > factory)
Result removeFactory (const std::string &name)

Friends

class Engine
 Only engine is allowed to create the instance.

Detailed Description

Main class providing the event messaging system.

EventManager is a class managing the whole event communication system in our engine. The system can be thought as a message bus where all senders and recievers are connected to. They send/recieve messages through this bus. In the message bus we define message channels which suppose to send/recieve only events/messages of a certain type.

Definition at line 106 of file EventManager.h.


Member Function Documentation

Result nrEngine::EventManager::createChannel ( const std::string &  name  ) 

Create a new event messaging channel. Any listener connected to this channel will recieve only the messages coming from senders connected to this channel. Any state change of the channel will produce a new notice event to give the listeners a possibility to react to the new state.

Parameters:
name Unique name for this channel
Returns:
either OK or an error code

Definition at line 48 of file EventManager.cpp.

References nrEngine::EVENT_CHANNEL_EXISTS, getChannel(), nrEngine::Log::LOG_ENGINE, and nrEngine::OK.

Referenced by nrEngine::Engine::initializeEngine().

Result nrEngine::EventManager::removeChannel ( const std::string &  name  ) 

Delete a certain communication channel. All actors connected to the channel are getting disconnected from the channel.

Parameters:
name Unique name for the channel to remove

Definition at line 65 of file EventManager.cpp.

References nrEngine::EVENT_CHANNEL_NOT_EXISTS, getChannel(), nrEngine::Log::LOG_ENGINE, and nrEngine::OK.

SharedPtr< EventChannel > nrEngine::EventManager::getChannel ( const std::string &  name  ) 

Get a channel by its name

Returns:
smart pointer to the channel

Definition at line 83 of file EventManager.cpp.

Referenced by nrEngine::EventActor::connect(), createChannel(), nrEngine::EventActor::disconnect(), emit(), removeChannel(), and nrEngine::EventActor::~EventActor().

Result nrEngine::EventManager::emit ( const std::string &  name,
SharedPtr< Event event 
)

Send a new event message to the channel. The priority number of the event will be used to check if the message should be send immediately or if it should go to the channel queue as first.

Parameters:
name Unique channel name, where to emit the event (empty for all channels)
event SMart pointer on event to be emited

Definition at line 107 of file EventManager.cpp.

References nrEngine::EVENT_CHANNEL_NOT_EXISTS, getChannel(), nrEngine::Log::LL_CHATTY, nrEngine::Log::LOG_ENGINE, and nrEngine::OK.

Referenced by nrEngine::EventActor::emit(), and emitSystem().

Result nrEngine::EventManager::emitSystem ( SharedPtr< Event event  ) 

Same as emit() but this will emit messages to the system specific default channel. This channel is used by the engine to establish a communication between system components.

NOTE: In next version this channel will be secured, so user are not allowed to send messages here anymore

Definition at line 135 of file EventManager.cpp.

References emit().

Referenced by nrEngine::ScriptEngine::add(), nrEngine::ScriptEngine::del(), nrEngine::Kernel::ResumeTask(), and nrEngine::Kernel::SuspendTask().

Result nrEngine::EventManager::updateTask (  )  [virtual]

Inherited method from the ITask interface. Our event manager is updated in each cycle to allow the channels to provide events to all connected parties.

Implements nrEngine::ITask.

Definition at line 94 of file EventManager.cpp.

References nrEngine::OK.

SharedPtr< Event > nrEngine::EventManager::createEvent ( const std::string &  eventType  ) 

Call this function if you prefer to create a new event object from all registerd factories. The function will go through all registered factories and ask them which does support the given event type. If one could be found, so create it.

Definition at line 142 of file EventManager.cpp.

Result nrEngine::EventManager::registerFactory ( const std::string &  name,
SharedPtr< EventFactory factory 
)

Register a new event factory. The given event factory will be stored in a list. The factory can later be used to create instancies of certain event types.

Parameters:
name Unique name of a factory
factory Smart pointer containing the factory object

Definition at line 155 of file EventManager.cpp.

References nrEngine::EVENT_FACTORY_FOUND, nrEngine::Log::LL_NORMAL, nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_ENGINE, and nrEngine::OK.

Result nrEngine::EventManager::removeFactory ( const std::string &  name  ) 

Delete a registered factory from the list.

Definition at line 170 of file EventManager.cpp.

References nrEngine::EVENT_FACTORY_NOT_FOUND, nrEngine::Log::LL_NORMAL, nrEngine::Log::LL_WARNING, nrEngine::Log::LOG_ENGINE, and nrEngine::OK.


The documentation for this class was generated from the following files:
Generated on Wed Sep 12 23:19:43 2007 for nrEngine by  doxygen 1.5.1