Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Static Public Member Functions | Static Public Attributes | Static Protected Member Functions | List of all members
orxonox::NotificationListener Class Reference

NotificationListener interface. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/orxonox/interfaces/NotificationListener.h>

Inheritance diagram for orxonox::NotificationListener:
orxonox::OrxonoxInterface orxonox::Configurable orxonox::Destroyable orxonox::Listable orxonox::Identifiable orxonox::NotificationManager

Public Member Functions

 NotificationListener ()
 
virtual ~NotificationListener ()
 
virtual bool executeCommand (NotificationCommand command, const std::string &sender)
 Executes a command with the NotificationListener This needs to be overloaded by each class inheriting from NotificationListener. More...
 
virtual bool registerNotification (const std::string &message, const std::string &sender, NotificationMessageType type)
 Registers a notification with the NotificationListener. More...
 
- Public Member Functions inherited from orxonox::OrxonoxInterface
 OrxonoxInterface ()
 
- Public Member Functions inherited from orxonox::Configurable
 Configurable ()
 
void setConfigValues ()
 Function to collect the SetConfigValue-macro calls. More...
 
- Public Member Functions inherited from orxonox::Listable
 Listable ()
 Constructor: Allocates space in the element list. More...
 
 Listable (Context *context)
 Constructor: Allocates space in the element list and assigns the context. More...
 
virtual ~Listable ()
 Destructor: Removes the object from the object-lists. More...
 
ContextgetContext () const
 
void setContext (Context *context)
 Changes the context. More...
 
void unregisterObject ()
 Removes this object from the object-lists. More...
 
- Public Member Functions inherited from orxonox::Identifiable
 Identifiable ()
 Constructor: Sets the default values. More...
 
virtual ~Identifiable ()
 
ORX_FORCEINLINE voidgetDerivedPointer (unsigned int classID)
 Returns a valid pointer of any derived type that is registered in the class hierarchy. More...
 
template<class T >
ORX_FORCEINLINE T * getDerivedPointer (unsigned int classID)
 Version of getDerivedPointer with template. More...
 
template<class T >
ORX_FORCEINLINE const T * getDerivedPointer (unsigned int classID) const
 Const version of getDerivedPointer with template. More...
 
IdentifiergetIdentifier () const
 Returns the Identifier of the object. More...
 
bool isA (const Identifier *identifier)
 Returns true if the object's class is of the given type or a derivative. More...
 
template<class B >
bool isA (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is of the given type or a derivative. More...
 
bool isA (const Identifiable *object)
 Returns true if the object's class is of the given type or a derivative. More...
 
bool isChildOf (const Identifier *identifier)
 Returns true if the object's class is a child of the given type. More...
 
template<class B >
bool isChildOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a child of the given type. More...
 
bool isChildOf (const Identifiable *object)
 Returns true if the object's class is a child of the given type. More...
 
bool isDirectChildOf (const Identifier *identifier)
 Returns true if the object's class is a direct child of the given type. More...
 
template<class B >
bool isDirectChildOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a direct child of the given type. More...
 
bool isDirectChildOf (const Identifiable *object)
 Returns true if the object's class is a direct child of the given type. More...
 
bool isDirectParentOf (const Identifier *identifier)
 Returns true if the object's class is a direct parent of the given type. More...
 
template<class B >
bool isDirectParentOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a direct parent of the given type. More...
 
bool isDirectParentOf (const Identifiable *object)
 Returns true if the object's class is a direct child of the given type. More...
 
bool isExactlyA (const Identifier *identifier)
 Returns true if the object's class is exactly of the given type. More...
 
template<class B >
bool isExactlyA (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is exactly of the given type. More...
 
bool isExactlyA (const Identifiable *object)
 Returns true if the object's class is exactly of the given type. More...
 
bool isParentOf (const Identifier *identifier)
 Returns true if the object's class is a parent of the given type. More...
 
template<class B >
bool isParentOf (const SubclassIdentifier< B > *identifier)
 Returns true if the object's class is a parent of the given type. More...
 
bool isParentOf (const Identifiable *object)
 Returns true if the object's class is a parent of the given type. More...
 
- Public Member Functions inherited from orxonox::Destroyable
 Destroyable ()
 Constructor: Sets the default values. More...
 
virtual ~Destroyable ()
 Destructor: Notifies all DestructionListener (for example weak pointers) that this object is being deleted. More...
 
void destroy ()
 Deletes the object if no strong pointers point to this object. More...
 
void destroyLater ()
 Works like destroy() but doesn't destroy the object until the current tick has ended. More...
 
unsigned int getReferenceCount () const
 Returns the number of strong pointers that point to this object. More...
 

Static Public Member Functions

static void sendCommand (const std::string &command, const std::string &sender=NotificationListener::NONE, NotificationSendMode sendMode=NotificationSendMode::local, unsigned int clientId=0)
 Sends a specified command to the specified client from the specified sender. More...
 
static void sendHelper (const std::string &message, const std::string &sender, bool isCommand, NotificationMessageType type)
 Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network. More...
 
static void sendNotification (const std::string &message, const std::string &sender=NotificationListener::NONE, NotificationMessageType messageType=NotificationMessageType::info, NotificationSendMode sendMode=NotificationSendMode::local, unsigned int clientId=0)
 Sends a Notification with the specified message to the specified client from the specified sender. More...
 

Static Public Attributes

static const std::string ALL
 Static string to indicate a sender that sends to all NotificationQueues. More...
 
static const std::string COMMAND_CLEAR
 Commands. More...
 
static const std::string COMMAND_NONE
 
static const std::string NONE
 Static string to indicate a sender that sends to no specific NotificationQueues. More...
 

Static Protected Member Functions

static const std::string & command2Str (NotificationCommand command)
 Helper method. More...
 
static void sendNetworkHelper (const std::string &message, const std::string &sender, NotificationSendMode sendMode, unsigned int clientId, bool isCommand=false, NotificationMessageType messageType=NotificationMessageType::info)
 Helper method to send both notifications and commands over the network. More...
 
static NotificationCommand str2Command (const std::string &string)
 Helper method. More...
 

Additional Inherited Members

- Protected Member Functions inherited from orxonox::Destroyable
virtual void preDestroy ()
 This virtual function is called if destroy() is called and no StrongPtr points to this object. More...
 

Detailed Description

NotificationListener interface.

The NotificationListener interface (or more precisely abstract class) presents a means of being informed when a new Notification is sent. The NotificationListener can be used to send a new notification message (with NotificationListener::sendNotification() ) or a new notification command (with NotificationListener::sendCommand() ). Each NotificationListener is then informed about the new Notification and can take appropriate action. Currently the only NotificationListener ist the NotificationManager singleton.

When inheriting from a NotificationListener it is important to provide an appropriate implementation of registerNotification() and executeCommand().

Author
Damian 'Mozork' Frick
Todo:
Consistent terminology between message, notification and command.

Constructor & Destructor Documentation

orxonox::NotificationListener::NotificationListener ( )
virtual orxonox::NotificationListener::~NotificationListener ( )
inlinevirtual

Member Function Documentation

const std::string & orxonox::NotificationListener::command2Str ( NotificationCommand  command)
staticprotected

Helper method.

Converts a command enum into its corresponding string.

Parameters
commandThe command to be converted.
Returns
Returns the corresponding string.
virtual bool orxonox::NotificationListener::executeCommand ( NotificationCommand  command,
const std::string &  sender 
)
inlinevirtual

Executes a command with the NotificationListener This needs to be overloaded by each class inheriting from NotificationListener.

Parameters
commandThe command to be executed.
senderThe sender of the command.
Returns
Returns true if the command was successfully executed, false if not.

Reimplemented in orxonox::NotificationManager.

virtual bool orxonox::NotificationListener::registerNotification ( const std::string &  message,
const std::string &  sender,
NotificationMessageType  type 
)
inlinevirtual

Registers a notification with the NotificationListener.

This needs to be overloaded by each class inheriting from NotificationListener.

Parameters
messageThe notification's message.
senderThe sender of the notification.
typeThe type of the notification.
Returns
Returns true if the notification was successfully registered, false if not.

Reimplemented in orxonox::NotificationManager.

static void orxonox::NotificationListener::sendCommand ( const std::string &  command,
const std::string &  sender = NotificationListener::NONE,
NotificationSendMode  sendMode = NotificationSendMode::local,
unsigned int  clientId = 0 
)
inlinestatic

Sends a specified command to the specified client from the specified sender.

Parameters
commandThe command that should be sent (and later executed).
senderThe sender that sent the notification. Default is 'none'.
sendModeThe mode in which the command is sent, can be 'local' to send the command to the client where this function is executed, 'network' if the command is to be sent to the client with the specified clientID, or 'broadcast' if the command should be sent to all hosts. Default is NotificationSendMode::local.
clientIdThe id of the client the command should be sent to. Default is 0.
void orxonox::NotificationListener::sendHelper ( const std::string &  message,
const std::string &  sender,
bool  isCommand,
NotificationMessageType  type 
)
static

Helper method to register a notification/execute a command with all NotificationListeners after it has been sent over the network.

Parameters
messageThe notification/command to be sent/executed.
senderThe sender that sent the notification/command.
isCommandWhether the message is a command or a notification.
typeThe type of the notification.
void orxonox::NotificationListener::sendNetworkHelper ( const std::string &  message,
const std::string &  sender,
NotificationSendMode  sendMode,
unsigned int  clientId,
bool  isCommand = false,
NotificationMessageType  messageType = NotificationMessageType::info 
)
staticprotected

Helper method to send both notifications and commands over the network.

Parameters
messageThe message/command that should be sent.
senderThe sender that sent the notification/command.
sendModeThe mode in which the notification/command is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts.
clientIdThe id of the client the notification/command should be sent to.
isCommandWhether the message is a notification or a command.
messageTypeThe type of the notification, can be either 'info' or 'important'.
static void orxonox::NotificationListener::sendNotification ( const std::string &  message,
const std::string &  sender = NotificationListener::NONE,
NotificationMessageType  messageType = NotificationMessageType::info,
NotificationSendMode  sendMode = NotificationSendMode::local,
unsigned int  clientId = 0 
)
inlinestatic

Sends a Notification with the specified message to the specified client from the specified sender.

Parameters
messageThe message that should be sent.
senderThe sender that sent the notification. Default is 'none'.
messageTypeThe type of the message, can be either 'info' or 'important'. Default is 'info'.
sendModeThe mode in which the notification is sent, can be 'local' to send the notification to the client where this function is executed, 'network' if the notification is to be sent to the client with the specified clientID, or 'broadcast' if the notification should be sent to all hosts. Default is NotificationSendMode::local.
clientIdThe id of the client the notification should be sent to. Default is 0.
NotificationCommand orxonox::NotificationListener::str2Command ( const std::string &  string)
staticprotected

Helper method.

Converts a string into the enum for a command.

Parameters
stringThe string to be converted.
Returns
Returns the corresponding enum, NotificationCommand::none if the command doesn't exist.

Member Data Documentation

const std::string orxonox::NotificationListener::ALL
static

Static string to indicate a sender that sends to all NotificationQueues.

const std::string orxonox::NotificationListener::COMMAND_CLEAR
static

Commands.

const std::string orxonox::NotificationListener::COMMAND_NONE
static
const std::string orxonox::NotificationListener::NONE
static

Static string to indicate a sender that sends to no specific NotificationQueues.


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