OpenTwin 0.1
OpenTwin
 
Loading...
Searching...
No Matches
ak::aMessenger Class Reference

Class used to forward messages to receivers This class is used to forward a message to receivers. A message will only be forwared to registered receivers. Receivers will only get messages from the senders and message types they want to be notified. More...

#include "aMessenger.h"

Public Member Functions

 aMessenger ()
 Default constructor.
 
virtual ~aMessenger ()
 Deconstructor.
 
void sendMessage (UID _senderId, eventType _event, int _info1=0, int _info2=0)
 Will forward the message to all registered receivers The sender id will be compared with the registered receivers in the receivers map. If a receivers was found, the message Type will be compared with the registered message types at the found receivers. If also the message type was found, the message will be forwareded to all receivers in the vector at the registered message type map entry.
 
void registerUidReceiver (UID _senderId, aNotifier *_notifier)
 Will register a receiver for a the specified sender If a message is received by this object, only receivers with the matching sender UID.
 
void registerEventTypeReceiver (eventType _eventType, aNotifier *_notifier)
 Will register a receiver for a specified sender.
 
void registerNotifierForAllMessages (aNotifier *_notifier)
 Will register a receiver for every single message send.
 
int uidNotifierCount (UID _senderUID)
 Will return the count of registered notifiers for a specific sender.
 
int eventNotifierCount (eventType _event)
 Will return the count of registered notifiers for a specific sender.
 
void clearAll (void)
 Will remove all notifiers from the messaging system.
 
void enable (void)
 Will enable the messenger.
 
void disable (void)
 Will disable the messenger.
 
void setEnabled (bool _enabled)
 Will set the messengers enabled state.
 
bool isEnabled (void) const
 Will return the current enabled state of the messenger.
 

Detailed Description

Class used to forward messages to receivers This class is used to forward a message to receivers. A message will only be forwared to registered receivers. Receivers will only get messages from the senders and message types they want to be notified.

Constructor & Destructor Documentation

◆ aMessenger()

ak::aMessenger::aMessenger ( )

Default constructor.

◆ ~aMessenger()

ak::aMessenger::~aMessenger ( )
virtual

Deconstructor.

Member Function Documentation

◆ clearAll()

void ak::aMessenger::clearAll ( void )

Will remove all notifiers from the messaging system.

◆ disable()

void ak::aMessenger::disable ( void )
inline

Will disable the messenger.

◆ enable()

void ak::aMessenger::enable ( void )
inline

Will enable the messenger.

◆ eventNotifierCount()

int ak::aMessenger::eventNotifierCount ( eventType _event)

Will return the count of registered notifiers for a specific sender.

Parameters
_eventThe event type

◆ isEnabled()

bool ak::aMessenger::isEnabled ( void ) const
inline

Will return the current enabled state of the messenger.

◆ registerEventTypeReceiver()

void ak::aMessenger::registerEventTypeReceiver ( eventType _eventType,
aNotifier * _notifier )

Will register a receiver for a specified sender.

Parameters
_eventTypeThe event type for what to register this receiver
_notifierThe notifier to register

◆ registerNotifierForAllMessages()

void ak::aMessenger::registerNotifierForAllMessages ( aNotifier * _notifier)

Will register a receiver for every single message send.

Parameters
_notifierThe notifier to register

◆ registerUidReceiver()

void ak::aMessenger::registerUidReceiver ( UID _senderId,
aNotifier * _notifier )

Will register a receiver for a the specified sender If a message is received by this object, only receivers with the matching sender UID.

Parameters
_senderIdThe id of the sender the notifier wants to receive the message from
_messageTypeThe type of the message which the notifier wants to receive
_notifierThe notifier which is receiving the message

◆ sendMessage()

void ak::aMessenger::sendMessage ( UID _senderId,
eventType _event,
int _info1 = 0,
int _info2 = 0 )

Will forward the message to all registered receivers The sender id will be compared with the registered receivers in the receivers map. If a receivers was found, the message Type will be compared with the registered message types at the found receivers. If also the message type was found, the message will be forwareded to all receivers in the vector at the registered message type map entry.

Parameters
_senderIdThe id of the object the message is coming from
_messageTypeThe type of the message which is transmitted
_messageThe message to be transmitted
_info1The massage info 1
_info2The message info 2

◆ setEnabled()

void ak::aMessenger::setEnabled ( bool _enabled)
inline

Will set the messengers enabled state.

Parameters
_enabledThe enabled state to set

◆ uidNotifierCount()

int ak::aMessenger::uidNotifierCount ( UID _senderUID)

Will return the count of registered notifiers for a specific sender.

Parameters
_senderIdThe sender UID

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