Orxonox
0.0.5 Codename: Arcturus
|
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>
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... | |
NotificationQueue * | getQueue (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... | |
Context * | getContext () 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 void * | getDerivedPointer (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... | |
Identifier * | getIdentifier () 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 NotificationManager & | getInstance () |
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 NotificationManager & | getInstance () |
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 NotificationManager * | singletonPtr_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... | |
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.
orxonox::NotificationManager::NotificationManager | ( | ) |
Constructor.
Registers the Object.
|
virtual |
Destructor.
|
private |
The clear command.
Clears all NotificationQueues that have its sender as a target.
sender | The sender of the clear command. |
|
overridevirtual |
Executes the input command from the input sender.
This is called by the NotificationListener, whenever a new command arrives.
command | The command to be executed, |
sender | The The name of the entity (of the collective) that sent the command. |
Reimplemented from orxonox::NotificationListener.
|
inlinestatic |
Get the instance of the NotificationManager Singleton.
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.
queue | The NotificationQueue the Notifications are fetched for. |
map | A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. |
numberOfNotifications | The number of newest Notifications to be got. |
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.
queue | The NotificationQueue the Notifications are fetched for. |
map | A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. |
timeFrameStart | The start time of the timeframe. |
timeFrameEnd | The end time of the timeframe. |
|
inline |
Fetches the Notifications for a specific NotificationQueue in a timeframe from (now-timeDelay) to now and stores them in the input map.
queue | The NotificationQueue the Notifications are fetched for. |
map | A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. |
timeDelay | The timespan. |
NotificationQueue * orxonox::NotificationManager::getQueue | ( | const std::string & | name | ) |
Get the NotificationQueue with the input name.
name | The name of the NotificationQueue. |
Loads all the NotificationQueues that should exist.
Is called before the object is destroyed.
Reimplemented from orxonox::Destroyable.
|
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.
message | The message of the new Notification. |
sender | The name of the entity (of the collective) that sent the new Notification. |
type | The type of the new Notification. |
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.
notification | The Notification to be registered. |
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.
queue | A pointer to the NotificationQueue to be registered. |
|
private |
Helper method that removes an input Notification form an input map.
notification | A pointer to the Notification to be removed. |
map | The map the Notification should be removed from. |
void orxonox::NotificationManager::unregisterNotification | ( | Notification * | notification, |
NotificationQueue * | queue | ||
) |
Unregisters a Notification within the NotificationManager for a given NotificationQueue.
notification | A pointer to the Notification to be unregistered. |
queue | A pointer to the NotificationQueue the Notification is unregistered for. |
void orxonox::NotificationManager::unregisterQueue | ( | NotificationQueue * | queue | ) |
Unregisters a NotificationQueue.
queue | A pointer to the NotificationQueue to be unregistered. |
|
friend |
|
private |
Container where all Notifications are stored.
|
private |
Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.
|
private |
The list of NotificationQueues created by the NotificationManager.
|
staticprivate |