Changeset 5619 for code/branches/libraries
- Timestamp:
- Aug 11, 2009, 12:33:16 AM (15 years ago)
- Location:
- code/branches/libraries/src/orxonox
- Files:
-
- 3 added
- 9 edited
- 4 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/libraries/src/orxonox/OrxonoxPrereqs.h
r5613 r5619 223 223 class Pong; 224 224 225 class Scores;226 class CreateLines;227 class Scoreboard;228 class Stats;229 230 225 // collision 231 226 class CollisionShape; … … 257 252 class InGameConsole; 258 253 class Notification; 254 class NotificationListener; 259 255 class NotificationManager; 260 256 class NotificationOverlay; … … 268 264 class KillMessage; 269 265 class DeathMessage; 266 class Map; 267 270 268 class CreateLines; 271 269 class Scoreboard; 272 class Map;270 class Stats; 273 271 274 272 //sound -
code/branches/libraries/src/orxonox/gamestates/GSLevel.cc
r3370 r5619 48 48 #include "objects/Radar.h" 49 49 #include "objects/quest/QuestManager.h" 50 #include "o verlays/notifications/NotificationManager.h"50 #include "objects/quest/notifications/NotificationManager.h" 51 51 #include "CameraManager.h" 52 52 #include "LevelManager.h" -
code/branches/libraries/src/orxonox/interfaces/InterfaceCompilation.cc
r3327 r5619 40 40 #include "Tickable.h" 41 41 #include "TimeFactorListener.h" 42 #include "NotificationListener.h" 42 43 43 44 #include "core/CoreIncludes.h" … … 108 109 RegisterObject(Rewardable); 109 110 } 111 112 //---------------------------- 113 // NotificationListener 114 //---------------------------- 115 NotificationListener::NotificationListener() 116 { 117 RegisterObject(NotificationListener); 118 } 110 119 } -
code/branches/libraries/src/orxonox/objects/quest/CMakeLists.txt
r3196 r5619 18 18 QuestNotification.cc 19 19 ) 20 21 ADD_SUBDIRECTORY(notifications) -
code/branches/libraries/src/orxonox/objects/quest/QuestNotification.h
r3196 r5619 26 26 * 27 27 */ 28 28 29 29 #ifndef _QuestNotification_H__ 30 30 #define _QuestNotification_H__ … … 33 33 34 34 #include <string> 35 #include " overlays/notifications/Notification.h"35 #include "notifications/Notification.h" 36 36 37 37 namespace orxonox { … … 39 39 /** 40 40 @brief 41 41 42 42 @author 43 43 Damian 'Mozork' Frick … … 49 49 QuestNotification(const std::string & message); 50 50 virtual ~QuestNotification(); 51 51 52 52 bool send(void); 53 53 54 54 private: 55 55 static const std::string SENDER; 56 56 57 57 void initialize(void); 58 58 59 59 }; 60 60 -
code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.cc
r5616 r5619 38 38 #include "core/CoreIncludes.h" 39 39 #include "Notification.h" 40 #include " NotificationQueue.h"40 #include "interfaces/NotificationListener.h" 41 41 42 42 namespace orxonox … … 69 69 /** 70 70 @brief 71 Registers a Notification within the NotificationManager and makes sure that the Notification is displayed in all the NotificationQueues associated with its sender.71 Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender. 72 72 @param notification 73 73 The Notification to be registered. … … 77 77 bool NotificationManager::registerNotification(Notification* notification) 78 78 { 79 79 80 80 if(notification == NULL) //!< A NULL-Notification cannot be registered. 81 81 return false; 82 82 83 83 std::time_t time = std::time(0); //TDO: Doesn't this expire? //!< Get current time. 84 84 85 85 this->allNotificationsList_.insert(std::pair<std::time_t,Notification*>(time,notification)); 86 86 87 87 if(notification->getSender() == NONE) //!< If the sender has no specific name, then the Notification is only added to the list of all Notifications. 88 88 return true; 89 89 90 90 bool all = false; 91 if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every Notification Queue.91 if(notification->getSender() == ALL) //!< If all are the sender, then the Notifications is added to every NotificationListener. 92 92 all = true; 93 94 //!< Insert the notification in all queues that have its sender as target.95 for(std::map<Notification Queue*,int>::iterator it = this->queueList_.begin(); it != this->queueList_.end(); it++) //!< Iterate through all queues.93 94 //!< Insert the notification in all listeners that have its sender as target. 95 for(std::map<NotificationListener*,int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) //!< Iterate through all listeners. 96 96 { 97 97 std::set<std::string> set = it->first->getTargetsSet(); 98 98 if(all || set.find(notification->getSender()) != set.end() || set.find(ALL) != set.end()) //TDO: Make sure this works. 99 99 { 100 this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current Notification Queue.101 it->first->update(notification, time); //!< Update the queue.100 this->notificationLists_[it->second]->insert(std::pair<std::time_t,Notification*>(time,notification)); //!< Insert the Notification in the Notifications list of the current NotificationListener. 101 it->first->update(notification, time); //!< Update the listener. 102 102 } 103 103 } 104 104 105 105 COUT(3) << "Notification registered with the NotificationManager." << std::endl; 106 106 107 107 return true; 108 108 } 109 109 110 110 /** 111 111 @brief 112 Registers a Notification Queuewithin the NotificationManager.113 @param queue114 The Notification Queueto be registered.112 Registers a NotificationListener within the NotificationManager. 113 @param listener 114 The NotificationListener to be registered. 115 115 @return 116 116 Returns true if successful. 117 117 */ 118 bool NotificationManager::register Queue(NotificationQueue* queue)118 bool NotificationManager::registerListener(NotificationListener* listener) 119 119 { 120 120 this->highestIndex_ += 1; 121 121 int index = this->highestIndex_; 122 123 this-> queueList_[queue] = index; //!< Add the NotificationQueue to the list of queues.124 125 std::set<std::string> set = queue->getTargetsSet(); //TDO: Works this?126 127 //! If all senders are the target of the queue, then the list of notification for that specific queueis te same as the list of all Notifications.122 123 this->listenerList_[listener] = index; //!< Add the NotificationListener to the list of listeners. 124 125 std::set<std::string> set = listener->getTargetsSet(); //TDO: Works this? 126 127 //! 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. 128 128 if(set.find(ALL) != set.end()) 129 129 { 130 130 this->notificationLists_[index] = &this->allNotificationsList_; 131 COUT(3) << "Notification Queueregistered with the NotificationManager." << std::endl;131 COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl; 132 132 return true; 133 133 } 134 134 135 135 this->notificationLists_[index] = new std::multimap<std::time_t,Notification*>; 136 136 std::multimap<std::time_t,Notification*> map = *this->notificationLists_[index]; 137 138 //! Iterate through all Notifications to determine whether any of them should belong to the newly registered Notification Queue.137 138 //! Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener. 139 139 for(std::multimap<std::time_t,Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++) 140 140 { … … 144 144 } 145 145 } 146 147 queue->update(); //!< Update the queue.148 146 149 COUT(3) << "NotificationQueue registered with the NotificationManager." << std::endl; 150 147 listener->update(); //!< Update the listener. 148 149 COUT(3) << "NotificationListener registered with the NotificationManager." << std::endl; 150 151 151 return true; 152 152 } 153 153 154 154 /** 155 155 @brief 156 Fetches the Notifications for a specific Notification Queuein a specified timeframe.157 @param queue158 The Notification Queuethe Notifications are fetched for.156 Fetches the Notifications for a specific NotificationListener in a specified timeframe. 157 @param listener 158 The NotificationListener the Notifications are fetched for. 159 159 @param map 160 160 A multimap, in which the notifications are stored. … … 166 166 Returns true if successful. 167 167 */ 168 bool NotificationManager::getNotifications(Notification Queue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)168 bool NotificationManager::getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd) 169 169 { 170 if( queue== NULL || map == NULL)170 if(listener == NULL || map == NULL) 171 171 return false; 172 172 173 std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this-> queueList_[queue]]; //!< The Notifications for the input NotificationQueue.174 173 std::multimap<std::time_t,Notification*>* notifications = this->notificationLists_[this->listenerList_[listener]]; //!< The Notifications for the input NotificationListener. 174 175 175 if(notifications == NULL) //!< Returns NULL, if there are no Notifications. 176 176 return true; 177 177 178 178 std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest; 179 179 itLowest = notifications->lower_bound(timeFrameStart); 180 180 itHighest = notifications->upper_bound(timeFrameStart); 181 181 182 182 for(it = itLowest; it != itHighest; it++) //!< Iterate through the Notifications from the start of the time Frame to the end of it. 183 183 { 184 184 map->insert(std::pair<std::time_t,Notification*>(it->first,it->second)); //!< Add the found Notifications to the map. 185 185 } 186 186 187 187 return true; 188 188 } -
code/branches/libraries/src/orxonox/objects/quest/notifications/NotificationManager.h
r5616 r5619 49 49 /** 50 50 @brief 51 The Singleton NotificationManager functions as a gateway between Notifications and Notification Queues.52 It receives, organizes Notifications and the redistributes them to the specific Notification Queues.51 The Singleton NotificationManager functions as a gateway between Notifications and NotificationListeners. 52 It receives, organizes Notifications and the redistributes them to the specific NotificationListeners. 53 53 @author 54 54 Damian 'Mozork' Frick … … 65 65 66 66 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. 67 bool register Queue(NotificationQueue* queue); //!< Registers a NotificationQueuewithin the NotificationManager.67 bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. 68 68 69 bool getNotifications(Notification Queue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Returns the Notifications for a specific NotificationQueuein a specified timeframe.69 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. 70 70 71 71 /** 72 @brief Fetches the Notifications for a specific Notification Queuestarting at a specified time.73 @param queue The NotificationQueuethe Notifications are fetched for.72 @brief Fetches the Notifications for a specific NotificationListener starting at a specified time. 73 @param listener The NotificationListener the Notifications are fetched for. 74 74 @param map A multimap, in which the notifications are stored. 75 75 @param timeFrameStart The start time the Notifications are fetched from. 76 76 @return Returns true if successful. 77 77 */ 78 bool getNotifications(Notification Queue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart)79 { return this->getNotifications( queue, map, timeFrameStart, std::time(0)); }78 bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart) 79 { return this->getNotifications(listener, map, timeFrameStart, std::time(0)); } 80 80 /** 81 @brief Fetches the Notifications for a specific Notification Queuestarting at a specified timespan before now.82 @param queue The NotificationQueuethe Notifications are fetched for.81 @brief Fetches the Notifications for a specific NotificationListener starting at a specified timespan before now. 82 @param listener The NotificationListener the Notifications are fetched for. 83 83 @param map A multimap, in which the notifications are stored. 84 84 @param timeDelay The timespan. 85 85 @return Returns true if successful. 86 86 */ 87 bool getNotifications(Notification Queue* queue, std::multimap<std::time_t,Notification*>* map, int timeDelay)88 { return this->getNotifications( queue, map, std::time(0)-timeDelay, std::time(0)); }87 bool getNotifications(NotificationListener* listener, std::multimap<std::time_t,Notification*>* map, int timeDelay) 88 { return this->getNotifications(listener, map, std::time(0)-timeDelay, std::time(0)); } 89 89 90 90 private: … … 94 94 95 95 std::multimap<std::time_t,Notification*> allNotificationsList_; //!< Container where all notifications are stored (together with their respecive timestamps). 96 std::map<Notification Queue*,int> queueList_; //!< Container where all NotificationQueues are stored with a number as identifier.97 std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a Notification Queue), are stored.96 std::map<NotificationListener*,int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. 97 std::map<int,std::multimap<std::time_t,Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. 98 98 99 99 -
code/branches/libraries/src/orxonox/overlays/notifications/CMakeLists.txt
r2911 r5619 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 Notification.cc3 NotificationManager.cc4 2 NotificationOverlay.cc 5 3 NotificationQueue.cc -
code/branches/libraries/src/orxonox/overlays/notifications/NotificationOverlay.cc
r3301 r5619 36 36 #include "util/Exception.h" 37 37 #include "core/CoreIncludes.h" 38 #include " Notification.h"38 #include "objects/quest/notifications/Notification.h" 39 39 #include "NotificationQueue.h" 40 40 … … 65 65 { 66 66 this->initialize(); 67 67 68 68 if(notification == NULL || queue == NULL) //!> If either notification or queue are not given an Exception is thrown. 69 69 { … … 73 73 this->queue_ = queue; 74 74 this->defineOverlay(); 75 75 76 76 this->processNotification(notification); 77 77 } 78 78 79 79 /** 80 80 @brief … … 85 85 this->queue_ = NULL; 86 86 } 87 87 88 88 /** 89 89 @brief -
code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.cc
r3301 r5619 39 39 #include "core/XMLPort.h" 40 40 #include "NotificationOverlay.h" 41 #include " NotificationManager.h"41 #include "objects/quest/notifications/NotificationManager.h" 42 42 43 43 namespace orxonox … … 80 80 this->tickTime_ = 0.0; 81 81 82 NotificationManager::getInstance().register Queue(this);82 NotificationManager::getInstance().registerListener(this); 83 83 } 84 84 -
code/branches/libraries/src/orxonox/overlays/notifications/NotificationQueue.h
r3196 r5619 45 45 #include "interfaces/Tickable.h" 46 46 #include "overlays/OverlayGroup.h" 47 #include "interfaces/NotificationListener.h" 47 48 48 49 namespace orxonox … … 57 58 std::string name; //!< The name of the overlay. 58 59 }; 59 60 60 61 //! Struct to allow ordering of NotificationOverlayContainers. 61 62 struct NotificationOverlayContainerCompare { … … 84 85 */ 85 86 86 class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable 87 class _OrxonoxExport NotificationQueue : public OverlayGroup, public Tickable, public NotificationListener 87 88 { 88 89 89 90 public: 90 91 NotificationQueue(BaseObject* creator); 91 92 virtual ~NotificationQueue(); 92 93 93 94 virtual void XMLPort(Element& xmlElement, XMLPort::Mode mode); //!< Method for creating a NotificationQueue object through XML. 94 95 95 96 virtual void tick(float dt); //!< To update from time to time. 96 97 97 98 void update(void); //!< Updates the queue. 98 99 void update(Notification* notification, const std::time_t & time); //!< Adds a Notification to the queue. 99 100 100 101 /** 101 102 @brief Returns the maximum number of Notifications displayed. … … 140 141 inline const std::string & getFont() const 141 142 { return this->font_; } 142 143 143 144 /** 144 145 @brief Returns the targets of this queue, reps. the senders which Notifications are displayed in this queue. … … 148 149 { return this->targets_; } 149 150 bool getTargets(std::string* string) const; //!< Returns a string consisting of the concatination of the targets. 150 151 151 152 /** 152 153 @brief Sets the position of the NotificationQueue. 153 154 @param pos The position. 154 155 */ 155 inline void setPosition(Vector2 pos) 156 inline void setPosition(Vector2 pos) 156 157 { this->position_ = pos; this->positionChanged(); } 157 158 158 159 void scroll(const Vector2 pos); //!< Scrolls the NotificationQueue, meaning all NotificationOverlays are moved the input vector. 159 160 160 161 private: 161 162 static const int DEFAULT_SIZE = 5; //!< The default maximum number of Notifications displayed. … … 166 167 static const std::string DEFAULT_FONT; //!< The default font. 167 168 static const Vector2 DEFAULT_POSITION; //!< the default position. 168 169 169 170 int maxSize_; //!< The maximal number of Notifications displayed. 170 171 int size_; //!< The number of Notifications displayed. … … 172 173 int displayTime_; //!< The time a Notification is displayed. 173 174 Vector2 position_; //!< The position of the NotificationQueue. 174 175 175 176 std::set<std::string> targets_; //!< The targets the Queue displays Notifications of. 176 177 177 178 float fontSize_; //!< The font size. 178 179 std::string font_; //!< The font. 179 180 180 181 std::multiset<NotificationOverlayContainer*, NotificationOverlayContainerCompare> containers_; //!< Multiset, because the ordering is based on, not necessarily unique, timestamps. 181 182 std::map<Notification*, NotificationOverlayContainer*> overlays_; //!< Mapping notifications to their corresponding overlay containers, for easier association and finding. 182 183 183 184 float tickTime_; //!< Helper variable, to not have to check for overlays that have been displayed too long, every tick. 184 185 NotificationOverlayContainer timeLimit_; //!< Helper object to check against to determine whether Notifications have expired. 185 186 186 187 void initialize(void); //!< Initializes the object. 187 188 void setDefaults(void); //!< Helper method to set the default values. 188 189 189 190 bool setMaxSize(int size); //!< Sets the maximum number of displayed Notifications. 190 191 bool setNotificationLength(int length); //!< Sets the maximum number of characters a Notification message displayed by this queue is allowed to have. 191 192 bool setDisplayTime(int time); //!< Sets the maximum number of seconds a Notification is displayed. 192 193 193 194 bool setTargets(const std::string & targets); //!< Set the targets of this queue. 194 195 195 196 bool setFontSize(float size); //!< Set the font size. 196 197 bool setFont(const std::string & font); //!< Set the font. 197 198 198 199 void positionChanged(void); //!< Aligns all the Notifications to the position of the NotificationQueue. 199 200 200 201 void addNotification(Notification* notification, const std::time_t & time); //!< Add a notification to the queue. 201 202 bool removeContainer(NotificationOverlayContainer* container); //!< Remove a container from the queue. 202 203 203 204 void clear(void); //!< Clear the queue. 204 205 205 206 }; 206 207
Note: See TracChangeset
for help on using the changeset viewer.