nrEngine::EventActor Class Reference
[Event-Management]

Event actors could acts as a server and client on event communication channels. More...

Inheritance diagram for nrEngine::EventActor:

nrEngine::ScriptConnector

Public Member Functions

 EventActor ()
 Create new actor without any name (.
 EventActor (const std::string &name)
 Create a new actor within unique name.
virtual ~EventActor ()
 Release used memory and disconnect the actor from the channel.
const std::string & getName () const
void setName (const std::string &name)
virtual void OnEvent (const EventChannel &channel, SharedPtr< Event > event)=0
Result emit (SharedPtr< Event > event)
Result connect (const std::string &name)
Result disconnect (const std::string &name)

Protected Member Functions

bool isConnected (const std::string &name)
 Check whenever we are already connected to a channel.
void _noticeConnected (EventChannel *channel)
void _noticeDisconnected (EventChannel *channel)

Protected Attributes

std::string mName
 Unique name of an actor in the channel.
std::list< std::string > mChannel
 Here we store the all the channels we are connected to.

Friends

class EventChannel
 The EventChannel is a friend so he is able to change default values.

Detailed Description

Event actors could acts as a server and client on event communication channels.

EventActor is a class representing an actor working on the event messaging communication channel. An actor could recieve and send new events. It will be informed by the channel if there is new events available, so it can react on them. EventActor could also send new events to a connected channel, so it acts as a server on the communication.
We do not want to separate event servers and clients like it does in a lot of event based messaging systems.

Definition at line 41 of file EventActor.h.


Constructor & Destructor Documentation

nrEngine::EventActor::EventActor (  ) 

Create new actor without any name (.

See also:
setName() )

Definition at line 24 of file EventActor.cpp.


Member Function Documentation

const std::string & nrEngine::EventActor::getName (  )  const

Get the name of an actor. The name should be unique to a certain channel. The communication channel will use the names to access its database for actors.

Definition at line 52 of file EventActor.cpp.

References mName.

Referenced by nrEngine::EventChannel::add(), and nrEngine::EventChannel::del().

void nrEngine::EventActor::setName ( const std::string &  name  ) 

Set name for this actor. You have to setup a name before you can connect the actor to any communication channel.

Definition at line 45 of file EventActor.cpp.

References mName.

virtual void nrEngine::EventActor::OnEvent ( const EventChannel channel,
SharedPtr< Event event 
) [pure virtual]

This is a function which will be called from the channel if any new event arise. You have to check for the event types derived by this function to do the job for the certain type of events.

Parameters:
channel Channel from where does this event occurs
event Smart pointer to an event object representing the message

Implemented in nrEngine::ScriptConnector.

Result nrEngine::EventActor::emit ( SharedPtr< Event event  ) 

Send a message through all connected channels.

Parameters:
event Message to be send

Definition at line 66 of file EventActor.cpp.

References nrEngine::EventManager::emit(), nrEngine::Log::LL_ERROR, nrEngine::Log::LOG_ENGINE, mChannel, nrEngine::OK, and nrEngine::Engine::sEventManager().

Result nrEngine::EventActor::connect ( const std::string &  name  ) 

Connect an actor to a certain channel.

Parameters:
name Unique name of the channel to connect to.
Returns:
either OK or an error from EVENT_ERROR-group

Definition at line 83 of file EventActor.cpp.

References nrEngine::EVENT_ALREADY_CONNECTED, nrEngine::EVENT_NO_CHANNEL_FOUND, nrEngine::EventManager::getChannel(), isConnected(), nrEngine::OK, and nrEngine::Engine::sEventManager().

Referenced by nrEngine::ScriptConnector::ScriptConnector().

Result nrEngine::EventActor::disconnect ( const std::string &  name  ) 

Disconnect this actor from a certain channel

Parameters:
name Unique name of the channel to disconnect

Definition at line 100 of file EventActor.cpp.

References nrEngine::EVENT_NO_CHANNEL_FOUND, nrEngine::EVENT_NOT_CONNECTED, nrEngine::EventManager::getChannel(), isConnected(), nrEngine::OK, and nrEngine::Engine::sEventManager().

Referenced by nrEngine::ScriptConnector::~ScriptConnector().

void nrEngine::EventActor::_noticeConnected ( EventChannel channel  )  [protected]

This function will be called from the channel, to notice the actor, that he is got now a new connection.

Definition at line 124 of file EventActor.cpp.

References nrEngine::EventChannel::getName(), isConnected(), and mChannel.

Referenced by nrEngine::EventChannel::add().

void nrEngine::EventActor::_noticeDisconnected ( EventChannel channel  )  [protected]

Notice an actor that he is disconnected now.

Definition at line 133 of file EventActor.cpp.

References nrEngine::EventChannel::getName(), isConnected(), and mChannel.

Referenced by nrEngine::EventChannel::del().


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