[Orxonox-commit 896] r5619 - in code/branches/libraries/src/orxonox: . gamestates interfaces objects/quest objects/quest/notifications overlays/notifications
landauf at orxonox.net
landauf at orxonox.net
Tue Aug 11 00:33:16 CEST 2009
Author: landauf
Date: 2009-08-11 00:33:16 +0200 (Tue, 11 Aug 2009)
New Revision: 5619
Added:
code/branches/libraries/src/orxonox/interfaces/NotificationListener.h
code/branches/libraries/src/orxonox/objects/quest/notifications/
code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt
code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.cc
code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h
code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc
code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h
Removed:
code/branches/libraries/src/orxonox/overlays/notifications/Notification.cc
code/branches/libraries/src/orxonox/overlays/notifications/Notification.h
code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.cc
code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.h
Modified:
code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
code/branches/libraries/src/orxonox/gamestates/GSLevel.cc
code/branches/libraries/src/orxonox/interfaces/InterfaceCompilation.cc
code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt
code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h
code/branches/libraries/src/orxonox/overlays/notifications/CMakeLists.txt
code/branches/libraries/src/orxonox/overlays/notifications/NotificationOverlay.cc
code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.cc
code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h
Log:
Moved Notification and NotificationManger from overlays to the quest objects (NotificationOverlay and NotificationQueue remain with the other overlays).
Added a new interface NotificationListener. The NotificationManager sends notifications to all listeners. NotificationQueue is such a listener (through inheritance). This removes another dependency between orxonox and overlays.
Modified: code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
===================================================================
--- code/branches/libraries/src/orxonox/OrxonoxPrereqs.h 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/OrxonoxPrereqs.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -222,11 +222,6 @@
class UnderAttack;
class Pong;
- class Scores;
- class CreateLines;
- class Scoreboard;
- class Stats;
-
// collision
class CollisionShape;
class SphereCollisionShape;
@@ -256,6 +251,7 @@
class HUDTimer;
class InGameConsole;
class Notification;
+ class NotificationListener;
class NotificationManager;
class NotificationOverlay;
class NotificationQueue;
@@ -267,9 +263,11 @@
class AnnounceMessage;
class KillMessage;
class DeathMessage;
+ class Map;
+
class CreateLines;
class Scoreboard;
- class Map;
+ class Stats;
//sound
class SoundBase;
Modified: code/branches/libraries/src/orxonox/gamestates/GSLevel.cc
===================================================================
--- code/branches/libraries/src/orxonox/gamestates/GSLevel.cc 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/gamestates/GSLevel.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -47,7 +47,7 @@
#include "interfaces/Tickable.h"
#include "objects/Radar.h"
#include "objects/quest/QuestManager.h"
-#include "overlays/notifications/NotificationManager.h"
+#include "objects/quest/notifications/NotificationManager.h"
#include "CameraManager.h"
#include "LevelManager.h"
#include "PlayerManager.h"
Modified: code/branches/libraries/src/orxonox/interfaces/InterfaceCompilation.cc
===================================================================
--- code/branches/libraries/src/orxonox/interfaces/InterfaceCompilation.cc 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/interfaces/InterfaceCompilation.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -39,6 +39,7 @@
#include "TeamColourable.h"
#include "Tickable.h"
#include "TimeFactorListener.h"
+#include "NotificationListener.h"
#include "core/CoreIncludes.h"
@@ -107,4 +108,12 @@
{
RegisterObject(Rewardable);
}
+
+ //----------------------------
+ // NotificationListener
+ //----------------------------
+ NotificationListener::NotificationListener()
+ {
+ RegisterObject(NotificationListener);
+ }
}
Added: code/branches/libraries/src/orxonox/interfaces/NotificationListener.h
===================================================================
--- code/branches/libraries/src/orxonox/interfaces/NotificationListener.h (rev 0)
+++ code/branches/libraries/src/orxonox/interfaces/NotificationListener.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -0,0 +1,59 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the NotificationListener class.
+*/
+
+#ifndef _NotificationListener_H__
+#define _NotificationListener_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <ctime>
+#include <set>
+#include <string>
+
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+ class _OrxonoxExport NotificationListener : virtual public OrxonoxClass
+ {
+ public:
+ NotificationListener();
+ virtual ~NotificationListener() {}
+
+ virtual const std::set<std::string> & getTargetsSet() = 0;
+ virtual void update(void) = 0;
+ virtual void update(Notification* notification, const std::time_t & time) = 0;
+ };
+}
+
+#endif /* _NotificationListener_H__ */
Modified: code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt 2009-08-10 22:33:16 UTC (rev 5619)
@@ -17,3 +17,5 @@
QuestManager.cc
QuestNotification.cc
)
+
+ADD_SUBDIRECTORY(notifications)
Modified: code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -25,20 +25,20 @@
* ...
*
*/
-
+
#ifndef _QuestNotification_H__
#define _QuestNotification_H__
#include "OrxonoxPrereqs.h"
#include <string>
-#include "overlays/notifications/Notification.h"
+#include "notifications/Notification.h"
namespace orxonox {
/**
@brief
-
+
@author
Damian 'Mozork' Frick
*/
@@ -48,14 +48,14 @@
QuestNotification(BaseObject* creator);
QuestNotification(const std::string & message);
virtual ~QuestNotification();
-
+
bool send(void);
-
+
private:
static const std::string SENDER;
-
+
void initialize(void);
-
+
};
}
Added: code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt (rev 0)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/CMakeLists.txt 2009-08-10 22:33:16 UTC (rev 5619)
@@ -0,0 +1,4 @@
+ADD_SOURCE_FILES(ORXONOX_SRC_FILES
+ Notification.cc
+ NotificationManager.cc
+)
Copied: code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.cc (from rev 5616, code/branches/libraries/src/orxonox/overlays/notifications/Notification.cc)
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.cc (rev 0)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -0,0 +1,130 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thes
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the Notification class.
+*/
+
+#include "Notification.h"
+
+#include "core/CoreIncludes.h"
+#include "NotificationManager.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ Default constructor. Initializes the object.
+ */
+ Notification::Notification(BaseObject* creator) : BaseObject(creator)
+ {
+ RegisterObject(Notification);
+ this->initialize();
+ }
+
+ /**
+ @brief
+ Constructor. Creates a Notification with the input message.
+ @param message
+ The message of the Notification.
+ */
+ Notification::Notification(const std::string & message) : BaseObject(NULL)
+ {
+ this->message_ = message;
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ Notification::~Notification()
+ {
+ }
+
+ /**
+ @brief
+ Registers the object and sets some default values.
+ */
+ void Notification::initialize(void)
+ {
+ this->message_ = "";
+ this->sender_ = NotificationManager::NONE;
+ this->sent_ = false;
+ }
+
+ /**
+ @brief
+ Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
+ @return
+ Returns true if successful.
+ */
+ bool Notification::send(void)
+ {
+ return this->send(NotificationManager::NONE);
+ }
+
+ /**
+ @brief
+ Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
+ @param sender
+ The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.
+ @return
+ Returns true if successful.
+ */
+ bool Notification::send(const std::string & sender)
+ {
+ this->sender_ = sender;
+ bool successful = NotificationManager::getInstance().registerNotification(this);
+ if(!successful)
+ return false;
+ this->sent_ = true;
+
+ COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Sets the message of the notification.
+ @param message
+ The message to be set.
+ @return
+ Returns true if successful.
+ */
+ bool Notification::setMessage(const std::string & message)
+ {
+ if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
+ return false;
+ this->message_ = message;
+ return true;
+ }
+
+}
Copied: code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h (from rev 5616, code/branches/libraries/src/orxonox/overlays/notifications/Notification.h)
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h (rev 0)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/Notification.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -0,0 +1,90 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the Notification class.
+*/
+
+#ifndef _Notification_H__
+#define _Notification_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include "core/BaseObject.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ A Notification is a short message used to inform the player about something that just happened. A Notification can be sent from any part of orxonox and is then displayed in the proper NotificationQueue (depending on which senders the specific NotificationQueue accepts).
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _OrxonoxExport Notification : public BaseObject
+ {
+ public:
+ Notification(BaseObject* creator);
+ Notification(const std::string & message);
+ virtual ~Notification();
+
+ bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE;
+ bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager.
+
+ /**
+ @brief Checks whether the Notification was sent.
+ @return Returns true if the Notification was sent already.
+ */
+ inline bool isSent(void) const
+ { return this->sent_; }
+ /**
+ @brief Returns the message of the Notification.
+ @return Returns the message of the Notification.
+ */
+ inline const std::string & getMessage(void) const
+ { return this->message_; }
+
+ inline const std::string & getSender(void) const
+ { return this->sender_; }
+
+ bool setMessage(const std::string & message); //!< Sets the message of the notification.
+
+ private:
+ std::string message_; //!< The Notification message.
+ std::string sender_; //!< The sender of the notification.
+ bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.
+
+ void initialize(void);
+
+ };
+
+}
+
+#endif /* _Notification_H__ */
Copied: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc (from rev 5616, code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.cc)
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc (rev 0)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -0,0 +1,190 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Implementation of the NotificationManager class.
+*/
+
+#include "NotificationManager.h"
+
+#include <set>
+
+#include "core/CoreIncludes.h"
+#include "Notification.h"
+#include "interfaces/NotificationListener.h"
+
+namespace orxonox
+{
+
+ const std::string NotificationManager::ALL = "all";
+ const std::string NotificationManager::NONE = "none";
+
+ NotificationManager* NotificationManager::singletonPtr_s = NULL;
+
+ /**
+ @brief
+ Constructor. Registers the Object.
+ */
+ NotificationManager::NotificationManager()
+ {
+ RegisterRootObject(NotificationManager);
+
+ this->highestIndex_ = 0;
+ }
+
+ /**
+ @brief
+ Destructor.
+ */
+ NotificationManager::~NotificationManager()
+ {
+ }
+
+ /**
+ @brief
+ Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender.
+ @param notification
+ The Notification to be registered.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationManager::registerNotification(Notification* notification)
+ {
+
+ if(notification == NULL) //!< A NULL-Notification cannot be registered.
+ return false;
+
+ std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time.
+
+ this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification));
+
+ if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications.
+ return true;
+
+ bool all = false;
+ if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationListener.
+ all = true;
+
+ //!< Insert the notification in all listeners that have its sender as target.
+ for(std::map<NotificationListener*,int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) //!< Iterate through all listeners.
+ {
+ std::set<std::string> set = it->first->getTargetsSet();
+ if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works.
+ {
+ this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener.
+ it->first->update(notification, time); //!< Update the listener.
+ }
+ }
+
+ COUT(3) << "Notification registered with the NotificationManager." << std::endl;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Registers a NotificationListener within the NotificationManager.
+ @param listener
+ The NotificationListener to be registered.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationManager::registerListener(NotificationListener* listener)
+ {
+ this->highestIndex_ += 1;
+ int index = this->highestIndex_;
+
+ this->listenerList_[listener] = index; //!< Add the NotificationListener to the list of listeners.
+
+ std::set<std::string> set = listener->getTargetsSet(); //TDO: Works this?
+
+ //! If all senders are the target of the listener, then the list of notification for that specific listener is te same as the list of all Notifications.
+ if(set.find(ALL) != set.end())
+ {
+ this->notificationLists_[index] = &this->allNotificationsList_;
+ COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
+ return true;
+ }
+
+ this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>;
+ std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index];
+
+ //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener.
+ for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
+ {
+ if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target.
+ {
+ map.insert(std::pair<std::time_t,Notification*>(it->first, it->second));
+ }
+ }
+
+ listener->update(); //!< Update the listener.
+
+ COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl;
+
+ return true;
+ }
+
+ /**
+ @brief
+ Fetches the Notifications for a specific NotificationListener in a specified timeframe.
+ @param listener
+ The NotificationListener the Notifications are fetched for.
+ @param map
+ A multimap, in which the notifications are stored.
+ @param timeFrameStart
+ The start time of the timeframe.
+ @param timeFrameEnd
+ The end time of the timeframe.
+ @return
+ Returns true if successful.
+ */
+ bool NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
+ {
+ if(listener == NULL || map == NULL)
+ return false;
+
+ std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; //!< The Notifications for the input NotificationListener.
+
+ if(notifications == NULL) //!< Returns NULL, if there are no Notifications.
+ return true;
+
+ std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
+ itLowest = notifications->lower_bound(timeFrameStart);
+ itHighest = notifications->upper_bound(timeFrameStart);
+
+ for(it = itLowest; it != itHighest; it++) //!< Iterate through the Notifications from the start of the time Frame to the end of it.
+ {
+ map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); //!< Add the found Notifications to the map.
+ }
+
+ return true;
+ }
+
+}
Copied: code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h (from rev 5616, code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.h)
===================================================================
--- code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h (rev 0)
+++ code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -0,0 +1,104 @@
+/*
+ * ORXONOX - the hottest 3D action shooter ever to exist
+ * > www.orxonox.net <
+ *
+ *
+ * License notice:
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Author:
+ * Damian 'Mozork' Frick
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+ @file
+ @brief Definition of the NotificationManager class.
+*/
+
+#ifndef _NotificationManager_H__
+#define _NotificationManager_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <ctime>
+#include <map>
+#include <string>
+
+#include "util/Singleton.h"
+#include "core/OrxonoxClass.h"
+
+namespace orxonox
+{
+
+ /**
+ @brief
+ The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners.
+ It receives, organizes Notifications and the redistributes them to the specific NotificationListeners.
+ @author
+ Damian 'Mozork' Frick
+ */
+ class _OrxonoxExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
+ {
+ friend class Singleton<NotificationManager>;
+ public:
+ NotificationManager();
+ virtual ~NotificationManager();
+
+ static const std::string ALL;
+ static const std::string NONE;
+
+ bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
+ bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager.
+
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationListener in a specified timeframe.
+
+ /**
+ @brief Fetches the Notifications for a specific NotificationListener starting at a specified time.
+ @param listener The NotificationListener the Notifications are fetched for.
+ @param map A multimap, in which the notifications are stored.
+ @param timeFrameStart The start time the Notifications are fetched from.
+ @return Returns true if successful.
+ */
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)
+ { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); }
+ /**
+ @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now.
+ @param listener The NotificationListener the Notifications are fetched for.
+ @param map A multimap, in which the notifications are stored.
+ @param timeDelay The timespan.
+ @return Returns true if successful.
+ */
+ bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay)
+ { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); }
+
+ private:
+ static NotificationManager* singletonPtr_s;
+
+ int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
+
+ std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps).
+ std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier.
+ std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored.
+
+
+ };
+
+}
+
+#endif /* _NotificationManager_H__ */
Modified: code/branches/libraries/src/orxonox/overlays/notifications/CMakeLists.txt
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/CMakeLists.txt 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/CMakeLists.txt 2009-08-10 22:33:16 UTC (rev 5619)
@@ -1,6 +1,4 @@
ADD_SOURCE_FILES(ORXONOX_SRC_FILES
- Notification.cc
- NotificationManager.cc
NotificationOverlay.cc
NotificationQueue.cc
)
Deleted: code/branches/libraries/src/orxonox/overlays/notifications/Notification.cc
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/Notification.cc 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/Notification.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -1,130 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See thes
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the Notification class.
-*/
-
-#include "Notification.h"
-
-#include "core/CoreIncludes.h"
-#include "NotificationManager.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- Default constructor. Initializes the object.
- */
- Notification::Notification(BaseObject* creator) : BaseObject(creator)
- {
- RegisterObject(Notification);
- this->initialize();
- }
-
- /**
- @brief
- Constructor. Creates a Notification with the input message.
- @param message
- The message of the Notification.
- */
- Notification::Notification(const std::string & message) : BaseObject(NULL)
- {
- this->message_ = message;
- }
-
- /**
- @brief
- Destructor.
- */
- Notification::~Notification()
- {
- }
-
- /**
- @brief
- Registers the object and sets some default values.
- */
- void Notification::initialize(void)
- {
- this->message_ = "";
- this->sender_ = NotificationManager::NONE;
- this->sent_ = false;
- }
-
- /**
- @brief
- Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
- @return
- Returns true if successful.
- */
- bool Notification::send(void)
- {
- return this->send(NotificationManager::NONE);
- }
-
- /**
- @brief
- Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
- @param sender
- The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.
- @return
- Returns true if successful.
- */
- bool Notification::send(const std::string & sender)
- {
- this->sender_ = sender;
- bool successful = NotificationManager::getInstance().registerNotification(this);
- if(!successful)
- return false;
- this->sent_ = true;
-
- COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
-
- return true;
- }
-
- /**
- @brief
- Sets the message of the notification.
- @param message
- The message to be set.
- @return
- Returns true if successful.
- */
- bool Notification::setMessage(const std::string & message)
- {
- if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
- return false;
- this->message_ = message;
- return true;
- }
-
-}
Deleted: code/branches/libraries/src/orxonox/overlays/notifications/Notification.h
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/Notification.h 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/Notification.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -1,90 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the Notification class.
-*/
-
-#ifndef _Notification_H__
-#define _Notification_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <string>
-#include "core/BaseObject.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- A Notification is a short message used to inform the player about something that just happened. A Notification can be sent from any part of orxonox and is then displayed in the proper NotificationQueue (depending on which senders the specific NotificationQueue accepts).
- @author
- Damian 'Mozork' Frick
- */
- class _OrxonoxExport Notification : public BaseObject
- {
- public:
- Notification(BaseObject* creator);
- Notification(const std::string & message);
- virtual ~Notification();
-
- bool send(void); //!< Sends the Notification to the Notificationmanager, with sender NotificationManager::NONE;
- bool send(const std::string & sender); //!< Sends the Notification to the Notificationmanager.
-
- /**
- @brief Checks whether the Notification was sent.
- @return Returns true if the Notification was sent already.
- */
- inline bool isSent(void) const
- { return this->sent_; }
- /**
- @brief Returns the message of the Notification.
- @return Returns the message of the Notification.
- */
- inline const std::string & getMessage(void) const
- { return this->message_; }
-
- inline const std::string & getSender(void) const
- { return this->sender_; }
-
- bool setMessage(const std::string & message); //!< Sets the message of the notification.
-
- private:
- std::string message_; //!< The Notification message.
- std::string sender_; //!< The sender of the notification.
- bool sent_; //!< Whether Notification has been sent, if so it cannot be changed.
-
- void initialize(void);
-
- };
-
-}
-
-#endif /* _Notification_H__ */
Deleted: code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.cc
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.cc 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -1,190 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Implementation of the NotificationManager class.
-*/
-
-#include "NotificationManager.h"
-
-#include <set>
-
-#include "core/CoreIncludes.h"
-#include "Notification.h"
-#include "NotificationQueue.h"
-
-namespace orxonox
-{
-
- const std::string NotificationManager::ALL = "all";
- const std::string NotificationManager::NONE = "none";
-
- NotificationManager* NotificationManager::singletonPtr_s = NULL;
-
- /**
- @brief
- Constructor. Registers the Object.
- */
- NotificationManager::NotificationManager()
- {
- RegisterRootObject(NotificationManager);
-
- this->highestIndex_ = 0;
- }
-
- /**
- @brief
- Destructor.
- */
- NotificationManager::~NotificationManager()
- {
- }
-
- /**
- @brief
- Registers a Notification within the NotificationManager and makes sure that the Notification is displayed in all the NotificationQueues associated with its sender.
- @param notification
- The Notification to be registered.
- @return
- Returns true if successful.
- */
- bool NotificationManager::registerNotification(Notification* notification)
- {
-
- if(notification == NULL) //!< A NULL-Notification cannot be registered.
- return false;
-
- std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time.
-
- this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification));
-
- if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications.
- return true;
-
- bool all = false;
- if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationQueue.
- all = true;
-
- //!< Insert the notification in all queues that have its sender as target.
- for(std::map<NotificationQueue*,int>::iterator it = this->queueList_.begin(); it != this->queueList_.end(); it++) //!< Iterate through all queues.
- {
- std::set<std::string> set = it->first->getTargetsSet();
- if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works.
- {
- this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationQueue.
- it->first->update(notification, time); //!< Update the queue.
- }
- }
-
- COUT(3) << "Notification registered with the NotificationManager." << std::endl;
-
- return true;
- }
-
- /**
- @brief
- Registers a NotificationQueue within the NotificationManager.
- @param queue
- The NotificationQueue to be registered.
- @return
- Returns true if successful.
- */
- bool NotificationManager::registerQueue(NotificationQueue* queue)
- {
- this->highestIndex_ += 1;
- int index = this->highestIndex_;
-
- this->queueList_[queue] = index; //!< Add the NotificationQueue to the list of queues.
-
- std::set<std::string> set = queue->getTargetsSet(); //TDO: Works this?
-
- //! If all senders are the target of the queue, then the list of notification for that specific queue is te same as the list of all Notifications.
- if(set.find(ALL) != set.end())
- {
- this->notificationLists_[index] = &this->allNotificationsList_;
- COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl;
- return true;
- }
-
- this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>;
- std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index];
-
- //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue.
- for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)
- {
- if(set.find(it->second->getSender()) != set.end()) //!< Checks whether the overlay has the sender of the current notification as target.
- {
- map.insert(std::pair<std::time_t,Notification*>(it->first, it->second));
- }
- }
-
- queue->update(); //!< Update the queue.
-
- COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl;
-
- return true;
- }
-
- /**
- @brief
- Fetches the Notifications for a specific NotificationQueue in a specified timeframe.
- @param queue
- The NotificationQueue the Notifications are fetched for.
- @param map
- A multimap, in which the notifications are stored.
- @param timeFrameStart
- The start time of the timeframe.
- @param timeFrameEnd
- The end time of the timeframe.
- @return
- Returns true if successful.
- */
- bool NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)
- {
- if(queue == NULL || map == NULL)
- return false;
-
- std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->queueList_[queue]]; //!< The Notifications for the input NotificationQueue.
-
- if(notifications == NULL) //!< Returns NULL, if there are no Notifications.
- return true;
-
- std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest;
- itLowest = notifications->lower_bound(timeFrameStart);
- itHighest = notifications->upper_bound(timeFrameStart);
-
- for(it = itLowest; it != itHighest; it++) //!< Iterate through the Notifications from the start of the time Frame to the end of it.
- {
- map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); //!< Add the found Notifications to the map.
- }
-
- return true;
- }
-
-}
Deleted: code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.h
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.h 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/NotificationManager.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -1,104 +0,0 @@
-/*
- * ORXONOX - the hottest 3D action shooter ever to exist
- * > www.orxonox.net <
- *
- *
- * License notice:
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Author:
- * Damian 'Mozork' Frick
- * Co-authors:
- * ...
- *
- */
-
-/**
- @file
- @brief Definition of the NotificationManager class.
-*/
-
-#ifndef _NotificationManager_H__
-#define _NotificationManager_H__
-
-#include "OrxonoxPrereqs.h"
-
-#include <ctime>
-#include <map>
-#include <string>
-
-#include "util/Singleton.h"
-#include "core/OrxonoxClass.h"
-
-namespace orxonox
-{
-
- /**
- @brief
- The Singleton NotificationManager functions as a gateway between Notifications and NotificationQueues.
- It receives, organizes Notifications and the redistributes them to the specific NotificationQueues.
- @author
- Damian 'Mozork' Frick
- */
- class _OrxonoxExport NotificationManager : public Singleton<NotificationManager>, public OrxonoxClass
- {
- friend class Singleton<NotificationManager>;
- public:
- NotificationManager();
- virtual ~NotificationManager();
-
- static const std::string ALL;
- static const std::string NONE;
-
- bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager.
- bool registerQueue(NotificationQueue* queue); //!< Registers a NotificationQueue within the NotificationManager.
-
- bool getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationQueue in a specified timeframe.
-
- /**
- @brief Fetches the Notifications for a specific NotificationQueue starting at a specified time.
- @param queue The NotificationQueue the Notifications are fetched for.
- @param map A multimap, in which the notifications are stored.
- @param timeFrameStart The start time the Notifications are fetched from.
- @return Returns true if successful.
- */
- bool getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)
- { return this->getNotifications(queue, map, timeFrameStart, std::time(0)); }
- /**
- @brief Fetches the Notifications for a specific NotificationQueue starting at a specified timespan before now.
- @param queue The NotificationQueue the Notifications are fetched for.
- @param map A multimap, in which the notifications are stored.
- @param timeDelay The timespan.
- @return Returns true if successful.
- */
- bool getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, int timeDelay)
- { return this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); }
-
- private:
- static NotificationManager* singletonPtr_s;
-
- int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.
-
- std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps).
- std::map<NotificationQueue*,int> queueList_; //!< Container where all NotificationQueues are stored with a number as identifier.
- std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationQueue), are stored.
-
-
- };
-
-}
-
-#endif /* _NotificationManager_H__ */
Modified: code/branches/libraries/src/orxonox/overlays/notifications/NotificationOverlay.cc
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/NotificationOverlay.cc 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/NotificationOverlay.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -35,7 +35,7 @@
#include "util/Exception.h"
#include "core/CoreIncludes.h"
-#include "Notification.h"
+#include "objects/quest/notifications/Notification.h"
#include "NotificationQueue.h"
namespace orxonox
@@ -64,7 +64,7 @@
NotificationOverlay::NotificationOverlay(NotificationQueue* queue, Notification* notification) : OverlayText(NULL)
{
this->initialize();
-
+
if(notification == NULL || queue == NULL) //!> If either notification or queue are not given an Exception is thrown.
{
ThrowException(Argument, "There were NULL-Pointer arguments in NotificationOverlay creation.");
@@ -72,10 +72,10 @@
this->queue_ = queue;
this->defineOverlay();
-
+
this->processNotification(notification);
}
-
+
/**
@brief
Initializes and Registers the object.
@@ -84,7 +84,7 @@
{
this->queue_ = NULL;
}
-
+
/**
@brief
Set some Overlay-specific values.
Modified: code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.cc
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.cc 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.cc 2009-08-10 22:33:16 UTC (rev 5619)
@@ -38,7 +38,7 @@
#include "core/CoreIncludes.h"
#include "core/XMLPort.h"
#include "NotificationOverlay.h"
-#include "NotificationManager.h"
+#include "objects/quest/notifications/NotificationManager.h"
namespace orxonox
{
@@ -79,7 +79,7 @@
this->size_ = 0;
this->tickTime_ = 0.0;
- NotificationManager::getInstance().registerQueue(this);
+ NotificationManager::getInstance().registerListener(this);
}
/**
Modified: code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h
===================================================================
--- code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h 2009-08-10 22:29:27 UTC (rev 5618)
+++ code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h 2009-08-10 22:33:16 UTC (rev 5619)
@@ -44,6 +44,7 @@
#include "util/Math.h"
#include "interfaces/Tickable.h"
#include "overlays/OverlayGroup.h"
+#include "interfaces/NotificationListener.h"
namespace orxonox
{
@@ -56,7 +57,7 @@
time_t time; //!< The time the Notification was sent and thus first displayed.
std::string name; //!< The name of the overlay.
};
-
+
//! Struct to allow ordering of NotificationOverlayContainers.
struct NotificationOverlayContainerCompare {
bool operator() (const NotificationOverlayContainer* const & a, const NotificationOverlayContainer* const & b) const
@@ -83,20 +84,20 @@
Damian 'Mozork' Frick
*/
- class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable
+ class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener
{
-
+
public:
NotificationQueue(BaseObject* creator);
virtual ~NotificationQueue();
-
+
virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML.
-
+
virtual void tick(float dt); //!< To update from time to time.
-
+
void update(void); //!< Updates the queue.
void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue.
-
+
/**
@brief Returns the maximum number of Notifications displayed.
@return Returns maximum size.
@@ -139,7 +140,7 @@
*/
inline const std::string & getFont() const
{ return this->font_; }
-
+
/**
@brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue.
@return Retuns a set of string holding the different targets.
@@ -147,16 +148,16 @@
inline const std::set<std::string> & getTargetsSet()
{ return this->targets_; }
bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets.
-
+
/**
@brief Sets the position of the NotificationQueue.
@param pos The position.
*/
- inline void setPosition(Vector2 pos)
+ inline void setPosition(Vector2 pos)
{ this->position_ = pos; this->positionChanged(); }
void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector.
-
+
private:
static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed.
static const int DEFAULT_LENGTH = 64; //!< The default maximum number of Notifications displayed.
@@ -165,43 +166,43 @@
static const std::string DEFAULT_FONT; //!< The default font.
static const Vector2 DEFAULT_POSITION; //!< the default position.
-
+
int maxSize_; //!< The maximal number of Notifications displayed.
int size_; //!< The number of Notifications displayed.
int notificationLength_; //!< The maximal number of characters a Notification-message is allowed to have.
int displayTime_; //!< The time a Notification is displayed.
Vector2 position_; //!< The position of the NotificationQueue.
-
+
std::set<std::string> targets_; //!< The targets the Queue displays Notifications of.
-
+
float fontSize_; //!< The font size.
std::string font_; //!< The font.
-
+
std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps.
std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding.
-
+
float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick.
NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired.
-
+
void initialize(void); //!< Initializes the object.
void setDefaults(void); //!< Helper method to set the default values.
-
+
bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications.
bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have.
bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed.
-
+
bool setTargets(const std::string & targets); //!< Set the targets of this queue.
-
+
bool setFontSize(float size); //!< Set the font size.
bool setFont(const std::string & font); //!< Set the font.
void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue.
-
+
void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue.
bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue.
-
+
void clear(void); //!< Clear the queue.
-
+
};
}
More information about the Orxonox-commit
mailing list