Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
orxonox::NotificationManager Class Reference

The Singleton NotificationManager is a NotificationListener and functions as a gateway between Notifications and NotificationQueues. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/modules/notifications/NotificationManager.h>

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

Public Member Functions

 NotificationManager ()
 Constructor. More...
 
virtual ~NotificationManager ()
 Destructor. More...
 
virtual bool executeCommand (NotificationCommand command, const std::string &sender) override
 Executes the input command from the input sender. More...
 
void getNewestNotifications (NotificationQueue *queue, std::multimap< std::time_t, Notification * > *map, int numberOfNotifications)
 Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map. More...
 
void getNotifications (NotificationQueue *queue, std::multimap< std::time_t, Notification * > *map, const std::time_t &timeFrameStart, const std::time_t &timeFrameEnd)
 Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map. More...
 
void getNotifications (NotificationQueue *queue, std::multimap< std::time_t, Notification * > *map, int timeDelay)
 Fetches the Notifications for a specific NotificationQueue in a timeframe from (now-timeDelay) to now and stores them in the input map. More...
 
NotificationQueuegetQueue (const std::string &name)
 Get the NotificationQueue with the input name. More...
 
void loadQueues (void)
 Loads all the NotificationQueues that should exist. More...
 
virtual void preDestroy (void) override
 Is called before the object is destroyed. More...
 
virtual bool registerNotification (const std::string &message, const std::string &sender, NotificationMessageType type) override
 Creates and registers a Notification with the input message from the input sender. More...
 
bool registerNotification (Notification *notification)
 Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender. More...
 
bool registerQueue (NotificationQueue *queue)
 Registers a NotificationQueue. More...
 
void unregisterNotification (Notification *notification, NotificationQueue *queue)
 Unregisters a Notification within the NotificationManager for a given NotificationQueue. More...
 
void unregisterQueue (NotificationQueue *queue)
 Unregisters a NotificationQueue. More...
 
- Public Member Functions inherited from orxonox::NotificationListener
 NotificationListener ()
 
virtual ~NotificationListener ()
 
- 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 NotificationManagergetInstance ()
 Get the instance of the NotificationManager Singleton. More...
 
- Static Public Member Functions inherited from orxonox::Singleton< NotificationManager >
static bool exists ()
 Tells whether the singleton has been created. More...
 
static NotificationManagergetInstance ()
 Returns a reference to the singleton instance. More...
 
- Static Public Member Functions inherited from orxonox::NotificationListener
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...
 

Private Member Functions

bool commandClear (const std::string &sender)
 The clear command. More...
 
bool removeNotification (Notification *notification, std::multimap< std::time_t, Notification * > &map)
 Helper method that removes an input Notification form an input map. More...
 

Private Attributes

std::multimap< std::time_t, Notification * > allNotificationsList_
 Container where all Notifications are stored. More...
 
std::map< const std::string, std::multimap< std::time_t, Notification * > * > notificationLists_
 Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored. More...
 
std::map< const std::string, NotificationQueue * > queues_
 The list of NotificationQueues created by the NotificationManager. More...
 

Static Private Attributes

static NotificationManagersingletonPtr_s
 

Friends

class Singleton< NotificationManager >
 

Additional Inherited Members

- Static Public Attributes inherited from orxonox::NotificationListener
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...
 
- Protected Member Functions inherited from orxonox::Singleton< NotificationManager >
 Singleton ()
 Constructor sets the singleton instance pointer. More...
 
virtual ~Singleton ()
 Destructor resets the singleton instance pointer. More...
 
- Static Protected Member Functions inherited from orxonox::NotificationListener
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...
 

Detailed Description

The Singleton NotificationManager is a NotificationListener and functions as a gateway between Notifications and NotificationQueues.

It receives, organizes Notifications and the redistributes them to the specific NotificationQueues. It also works as a liaison between the NotificationQueues and the GUI that displays notification, called NotificationLayer.

Author
Damian 'Mozork' Frick

Constructor & Destructor Documentation

orxonox::NotificationManager::NotificationManager ( )

Constructor.

Registers the Object.

orxonox::NotificationManager::~NotificationManager ( )
virtual

Destructor.

Member Function Documentation

bool orxonox::NotificationManager::commandClear ( const std::string &  sender)
private

The clear command.

Clears all NotificationQueues that have its sender as a target.

Parameters
senderThe sender of the clear command.
Returns
Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed.
bool orxonox::NotificationManager::executeCommand ( NotificationCommand  command,
const std::string &  sender 
)
overridevirtual

Executes the input command from the input sender.

This is called by the NotificationListener, whenever a new command arrives.

Parameters
commandThe command to be executed,
senderThe The name of the entity (of the collective) that sent the command.
Returns
Returns true if the command was successfully executed.

Reimplemented from orxonox::NotificationListener.

static NotificationManager& orxonox::NotificationManager::getInstance ( )
inlinestatic

Get the instance of the NotificationManager Singleton.

Returns
Returns a reference to the NotificationManager.
void orxonox::NotificationManager::getNewestNotifications ( NotificationQueue queue,
std::multimap< std::time_t, Notification * > *  map,
int  numberOfNotifications 
)

Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map.

Parameters
queueThe NotificationQueue the Notifications are fetched for.
mapA pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
numberOfNotificationsThe number of newest Notifications to be got.
Returns
Returns true if successful.
void orxonox::NotificationManager::getNotifications ( NotificationQueue queue,
std::multimap< std::time_t, Notification * > *  map,
const std::time_t &  timeFrameStart,
const std::time_t &  timeFrameEnd 
)

Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map.

Parameters
queueThe NotificationQueue the Notifications are fetched for.
mapA pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
timeFrameStartThe start time of the timeframe.
timeFrameEndThe end time of the timeframe.
Returns
Returns true if successful.
void orxonox::NotificationManager::getNotifications ( NotificationQueue queue,
std::multimap< std::time_t, Notification * > *  map,
int  timeDelay 
)
inline

Fetches the Notifications for a specific NotificationQueue in a timeframe from (now-timeDelay) to now and stores them in the input map.

Parameters
queueThe NotificationQueue the Notifications are fetched for.
mapA pointer to a multimap, in which the notifications are stored. The map needs to have been allocated.
timeDelayThe timespan.
Returns
Returns true if successful.
NotificationQueue * orxonox::NotificationManager::getQueue ( const std::string &  name)

Get the NotificationQueue with the input name.

Parameters
nameThe name of the NotificationQueue.
Returns
Returns a pointer to the NotificationQueue with the input name. Returns nullptr if no NotificationQueue with such a name exists.
void orxonox::NotificationManager::loadQueues ( void  )

Loads all the NotificationQueues that should exist.

void orxonox::NotificationManager::preDestroy ( void  )
overridevirtual

Is called before the object is destroyed.

Reimplemented from orxonox::Destroyable.

bool orxonox::NotificationManager::registerNotification ( const std::string &  message,
const std::string &  sender,
NotificationMessageType  type 
)
overridevirtual

Creates and registers a Notification with the input message from the input sender.

This is called by the NotificationListener, whenever a new notification arrives.

Parameters
messageThe message of the new Notification.
senderThe name of the entity (of the collective) that sent the new Notification.
typeThe type of the new Notification.
Returns
Returns true if successful.

Reimplemented from orxonox::NotificationListener.

bool orxonox::NotificationManager::registerNotification ( Notification notification)

Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender.

Parameters
notificationThe Notification to be registered.
Returns
Returns true if successful.
bool orxonox::NotificationManager::registerQueue ( NotificationQueue queue)

Registers a NotificationQueue.

This makes sure that the NotificationQueue can be accessed through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.

Parameters
queueA pointer to the NotificationQueue to be registered.
Returns
Returns true if successful. If e.g. the a NotificationQueue with that name already exists this returns false.
bool orxonox::NotificationManager::removeNotification ( Notification notification,
std::multimap< std::time_t, Notification * > &  map 
)
private

Helper method that removes an input Notification form an input map.

Parameters
notificationA pointer to the Notification to be removed.
mapThe map the Notification should be removed from.
Returns
Returns true if successful.
void orxonox::NotificationManager::unregisterNotification ( Notification notification,
NotificationQueue queue 
)

Unregisters a Notification within the NotificationManager for a given NotificationQueue.

Parameters
notificationA pointer to the Notification to be unregistered.
queueA pointer to the NotificationQueue the Notification is unregistered for.
void orxonox::NotificationManager::unregisterQueue ( NotificationQueue queue)

Unregisters a NotificationQueue.

Parameters
queueA pointer to the NotificationQueue to be unregistered.

Friends And Related Function Documentation

friend class Singleton< NotificationManager >
friend

Member Data Documentation

std::multimap<std::time_t, Notification*> orxonox::NotificationManager::allNotificationsList_
private

Container where all Notifications are stored.

std::map<const std::string, std::multimap<std::time_t, Notification*>*> orxonox::NotificationManager::notificationLists_
private

Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.

std::map<const std::string, NotificationQueue*> orxonox::NotificationManager::queues_
private

The list of NotificationQueues created by the NotificationManager.

NotificationManager* orxonox::NotificationManager::singletonPtr_s
staticprivate

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