Inheritance diagram for nrEngine::EventActor:
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. |
Definition at line 41 of file EventActor.h.
nrEngine::EventActor::EventActor | ( | ) |
Create new actor without any name (.
Definition at line 24 of file EventActor.cpp.
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.
channel | Channel from where does this event occurs | |
event | Smart pointer to an event object representing the message |
Implemented in nrEngine::ScriptConnector.
Send a message through all connected channels.
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.
name | Unique name of the channel to connect to. |
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
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().