Changeset 8374 for code/branches/tutoriallevel2/src
- Timestamp:
- May 2, 2011, 10:20:45 AM (14 years ago)
- Location:
- code/branches/tutoriallevel2/src
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/tutoriallevel2/src/modules/notifications/Notification.cc
r7489 r8374 35 35 36 36 #include "core/CoreIncludes.h" 37 #include " NotificationManager.h"37 #include "interfaces/NotificationListener.h" 38 38 39 39 namespace orxonox … … 72 72 { 73 73 this->message_.clear(); 74 this->sender_ = Notification Manager::NONE;74 this->sender_ = NotificationListener::NONE; 75 75 } 76 76 -
code/branches/tutoriallevel2/src/modules/notifications/Notification.h
r7655 r8374 80 80 81 81 void initialize(void); //!< Registers the object and sets some default values. 82 void registerVariables(void) {}83 82 84 83 }; -
code/branches/tutoriallevel2/src/modules/notifications/NotificationDispatcher.cc
r7552 r8374 41 41 42 42 #include "infos/PlayerInfo.h" 43 #include "interfaces/NotificationListener.h" 43 44 #include "interfaces/PlayerTrigger.h" 44 45 #include "worldentities/pawns/Pawn.h" 45 46 #include "NotificationManager.h"47 46 48 47 namespace orxonox … … 61 60 RegisterObject(NotificationDispatcher); 62 61 63 this->sender_ = Notification Manager::NONE;62 this->sender_ = NotificationListener::NONE; 64 63 this->registerVariables(); 65 64 } … … 114 113 { 115 114 const std::string message = this->createNotificationMessage(); 116 Notification Manager::sendNotification(message, clientId, this->getSender());115 NotificationListener::sendNotification(message, clientId, this->getSender()); 117 116 } 118 117 else if(GameMode::isServer()) -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.cc
r8371 r8374 36 36 #include "core/command/ConsoleCommand.h" 37 37 #include "core/CoreIncludes.h" 38 #include "core/GameMode.h" 38 39 #include "core/GUIManager.h" 39 40 #include "core/LuaState.h" 40 #include "network/Host.h"41 #include "network/NetworkFunction.h"42 41 #include "util/Convert.h" 43 42 #include "util/ScopedSingletonManager.h" … … 53 52 { 54 53 55 const std::string NotificationManager::ALL("all");56 const std::string NotificationManager::NONE("none");57 58 54 // Register tolua_open function when loading the library. 59 55 DeclareToluaInterface(Notifications); … … 64 60 SetConsoleCommand("enterEditMode", &NotificationManager::enterEditMode); 65 61 66 registerStaticNetworkFunction(NotificationManager::sendNotification);67 68 62 /** 69 63 @brief … … 73 67 { 74 68 RegisterRootObject(NotificationManager); 75 76 this->highestIndex_ = 0;77 69 78 70 ModifyConsoleCommand("enterEditMode").setObject(this); … … 113 105 this->queues_.clear(); 114 106 } 115 116 /** 117 @brief 118 Sends a Notification with the specified message to the specified client from the specified sender. 119 @param message 120 The message that should be sent. 121 @param clientId 122 The id of the client the notification should be sent to. 123 @param sender 124 The sender that sent the notification. 125 @param isLocal 126 If this is set to true (false is default), then the Notification is sent to the client where this function is executed, meaning the Notification is sent locally. 127 */ 128 /*static*/ void NotificationManager::sendNotification(const std::string& message, unsigned int clientId, const std::string& sender, bool isLocal) 129 { 130 // If we're in standalone mode or we're already no the right client we create and send the Notification. 131 if(GameMode::isStandalone() || isLocal || Host::getPlayerID() == clientId) 132 { 133 Notification* notification = new Notification(message, sender); 134 if(NotificationManager::getInstance().registerNotification(notification)) 135 COUT(3) << "Notification \"" << notification->getMessage() << "\" sent." << std::endl; 136 } 137 // If we're on the server (and the server is not the intended recipient of the Notification) we send it over the network. 138 else if(GameMode::isServer()) 139 { 140 callStaticNetworkFunction(NotificationManager::sendNotification, clientId, message, clientId, sender); 141 } 142 } 143 144 /** 145 @brief 146 Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationListeners associated with its sender. 107 108 bool NotificationManager::registerNotification(const std::string& message, const std::string& sender) 109 { 110 Notification* notification = new Notification(message, sender); 111 return this->registerNotification(notification); 112 } 113 114 /** 115 @brief 116 Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender. 147 117 @param notification 148 118 The Notification to be registered. … … 159 129 this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification)); 160 130 161 if(notification->getSender() == Notification Manager::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications.131 if(notification->getSender() == NotificationListener::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications. 162 132 return true; 163 133 164 134 bool all = false; 165 if(notification->getSender() == Notification Manager::ALL) // If all are the sender, then the Notifications is added to every NotificationListener.135 if(notification->getSender() == NotificationListener::ALL) // If all are the sender, then the Notifications is added to every NotificationQueue. 166 136 all = true; 167 137 168 // Insert the Notification in all Notification Listeners that have its sender as target.169 for(std::map< NotificationListener*, unsigned int>::iterator it = this->listenerList_.begin(); it != this->listenerList_.end(); it++) // Iterate through all NotificationListeners.170 { 171 const std::set<std::string>& set = it-> first->getTargetsSet();172 bool bAll = set.find(Notification Manager::ALL) != set.end();173 // If either the Notification has as sender 'all', the Notification Listener displays all Notifications or the NotificationListenerhas the sender of the Notification as target.138 // Insert the Notification in all NotificationQueues that have its sender as target. 139 for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues. 140 { 141 const std::set<std::string>& set = it->second->getTargetsSet(); 142 bool bAll = set.find(NotificationListener::ALL) != set.end(); 143 // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target. 174 144 if(all || bAll || set.find(notification->getSender()) != set.end()) 175 145 { 176 146 if(!bAll) 177 this->notificationLists_[it->second ]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationListener.178 it-> first->update(notification, time); // Update the NotificationListener.147 this->notificationLists_[it->second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue. 148 it->second->update(notification, time); // Update the NotificationQueue. 179 149 } 180 150 } … … 187 157 /** 188 158 @brief 189 Unregisters a Notification within the NotificationManager for a given Notification Listener.159 Unregisters a Notification within the NotificationManager for a given NotificationQueue. 190 160 @param notification 191 161 A pointer to the Notification to be unregistered. 192 @param listener193 A pointer to the Notification Listenerthe Notification is unregistered for.194 */ 195 void NotificationManager::unregisterNotification(Notification* notification, Notification Listener* listener)162 @param queue 163 A pointer to the NotificationQueue the Notification is unregistered for. 164 */ 165 void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue) 196 166 { 197 167 assert(notification); 198 assert( listener);199 200 // Remove the Notification from the list of Notifications of the input Notification Listener.201 this->removeNotification(notification, *(this->notificationLists_.find( this->listenerList_.find(listener)->second)->second));202 203 COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from listener (&" << listener << ")" << std::endl;168 assert(queue); 169 170 // Remove the Notification from the list of Notifications of the input NotificationQueue. 171 this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second)); 172 173 COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl; 204 174 } 205 175 … … 231 201 /** 232 202 @brief 233 Registers a NotificationListener within the NotificationManager. 234 @param listener 235 The NotificationListener to be registered. 236 @return 237 Returns true if successful. Fales if the NotificationListener is already registered. 238 */ 239 bool NotificationManager::registerListener(NotificationListener* listener) 240 { 241 assert(listener); 242 243 // If the NotificationListener is already registered. 244 if(this->listenerList_.find(listener) != this->listenerList_.end()) 245 return false; 246 247 this->highestIndex_ += 1; 248 unsigned int index = this->highestIndex_; // An identifier that identifies each registered NotificationListener uniquely. 249 250 this->listenerList_[listener] = index; // Add the NotificationListener to the list of NotificationListeners. 251 252 const std::set<std::string>& set = listener->getTargetsSet(); 253 254 // If all senders are the target of the NotificationListener, then the list of Notifications for that specific NotificationListener is the same as the list of all Notifications. 255 bool bAll = set.find(NotificationManager::ALL) != set.end(); 256 std::multimap<std::time_t, Notification*>* map = NULL; 257 if(bAll) 258 this->notificationLists_[index] = &this->allNotificationsList_; 259 // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationListeners. 260 else 261 { 262 this->notificationLists_[index] = new std::multimap<std::time_t, Notification*>; 263 map = this->notificationLists_[index]; 264 } 265 266 // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationListener. 267 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++) 268 { 269 if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target. 270 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); 271 } 272 273 listener->update(); // Update the listener. 274 275 COUT(4) << "NotificationListener registered with the NotificationManager." << std::endl; 276 277 return true; 278 } 279 280 /** 281 @brief 282 Unregisters a NotificationListener within the NotificationManager. 283 @param listener 284 The NotificationListener to be unregistered. 285 */ 286 void NotificationManager::unregisterListener(NotificationListener* listener) 287 { 288 assert(listener); 289 290 unsigned int identifier = this->listenerList_.find(listener)->second; 291 std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(identifier)->second; 292 293 // If the map is not the map of all Notifications, make sure all Notifications are unregistered. 294 std::multimap<std::time_t, Notification*>::iterator it = map->begin(); 295 if(map != &this->allNotificationsList_) 296 { 297 while(it != map->end()) 298 { 299 this->unregisterNotification(it->second, listener); 300 it = map->begin(); 301 } 302 delete map; 303 } 304 305 COUT(4) << "NotificationListener '" << identifier << "' unregistered with the NotificationManager." << std::endl; 306 307 // Remove the NotificationListener from the list of NotificationListeners. 308 this->listenerList_.erase(listener); 309 // Remove the Notifications list that was associated with the input NotificationListener. 310 this->notificationLists_.erase(identifier); 311 } 312 313 /** 314 @brief 315 Fetches the Notifications for a specific NotificationListener in a specified timeframe and stores them in the input map. 316 @param listener 317 The NotificationListener the Notifications are fetched for. 203 Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map. 204 @param queue 205 The NotificationQueue the Notifications are fetched for. 318 206 @param map 319 207 A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. … … 325 213 Returns true if successful. 326 214 */ 327 void NotificationManager::getNotifications(Notification Listener* listener, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd)328 { 329 assert( listener);215 void NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd) 216 { 217 assert(queue); 330 218 assert(map); 331 219 332 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[ this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.220 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue. 333 221 334 222 std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest; … … 343 231 /** 344 232 @brief 345 Fetches the newest Notifications for a specific Notification Listenerand stores them in the input map.346 @param listener347 The Notification Listenerthe Notifications are fetched for.233 Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map. 234 @param queue 235 The NotificationQueue the Notifications are fetched for. 348 236 @param map 349 237 A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. … … 353 241 Returns true if successful. 354 242 */ 355 void NotificationManager::getNewestNotifications(Notification Listener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications)356 { 357 assert( listener);243 void NotificationManager::getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications) 244 { 245 assert(queue); 358 246 assert(map); 359 247 360 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[ this->listenerList_[listener]]; // All the Notifications for the input NotificationListener.248 std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue. 361 249 362 250 if(!notifications->empty()) // If the list of Notifications is not empty. … … 390 278 @brief 391 279 Registers a NotificationQueue. 392 This makes sure that the NotificationQueue can be a ttained through lua by name. It also makes sure that the NotificationQueue is destroyed upon destruction of the NotificationManager.280 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. 393 281 @param queue 394 282 A pointer to the NotificationQueue to be registered. … … 398 286 bool NotificationManager::registerQueue(NotificationQueue* queue) 399 287 { 288 assert(queue); 289 290 // If the NotificationQueue is already registered. 291 if(this->queues_.find(queue->getName()) != this->queues_.end()) 292 return false; 293 294 this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)); // Add the NotificationQueue to the list of NotificationQueues. 295 296 const std::set<std::string>& set = queue->getTargetsSet(); 297 298 // If all senders are the target of the NotificationQueue, then the list of Notifications for that specific NotificationQueue is the same as the list of all Notifications. 299 bool bAll = set.find(NotificationListener::ALL) != set.end(); 300 std::multimap<std::time_t, Notification*>* map = NULL; 301 if(bAll) 302 this->notificationLists_[queue->getName()] = &this->allNotificationsList_; 303 // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationQueues. 304 else 305 { 306 this->notificationLists_[queue->getName()] = new std::multimap<std::time_t, Notification*>; 307 map = this->notificationLists_[queue->getName()]; 308 } 309 310 // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue. 311 for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++) 312 { 313 if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target. 314 map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); 315 } 316 317 queue->update(); // Update the queue. 318 400 319 COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl; 401 return t his->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)).second;320 return true; 402 321 } 403 322 … … 410 329 void NotificationManager::unregisterQueue(NotificationQueue* queue) 411 330 { 331 assert(queue); 332 333 std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(queue->getName())->second; 334 335 // If the map is not the map of all Notifications, make sure all Notifications are unregistered. 336 std::multimap<std::time_t, Notification*>::iterator it = map->begin(); 337 if(map != &this->allNotificationsList_) 338 { 339 while(it != map->end()) 340 { 341 this->unregisterNotification(it->second, queue); 342 it = map->begin(); 343 } 344 delete map; 345 } 346 347 // Remove the NotificationQueue from the list of NotificationQueues. 348 this->queues_.erase(queue->getName()); 349 // Remove the Notifications list that was associated with the input NotificationQueue. 350 this->notificationLists_.erase(queue->getName()); 351 412 352 COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl; 413 this->queues_.erase(queue->getName());414 353 } 415 354 … … 424 363 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.moveQueue(\"all\", 0, 10, 0.3, 0)"); 425 364 426 NotificationQueue* infoQueue = new NotificationQueue("info", Notification Manager::ALL, 1, -1);365 NotificationQueue* infoQueue = new NotificationQueue("info", NotificationListener::ALL, 1, -1); 427 366 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.changeQueueFont(\"info\", 24, \"FFFFFF00\")"); 428 367 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.resizeQueue(\"info\", 0.6, 0, " + multi_cast<std::string>(infoQueue->getMaxSize()) + ")"); -
code/branches/tutoriallevel2/src/modules/notifications/NotificationManager.h
r8371 r8374 43 43 44 44 #include "util/Singleton.h" 45 #include " core/OrxonoxClass.h"45 #include "interfaces/NotificationListener.h" 46 46 47 47 namespace orxonox // tolua_export … … 60 60 */ 61 61 class _NotificationsExport NotificationManager // tolua_export 62 : public Singleton<NotificationManager>, public OrxonoxClass62 : public Singleton<NotificationManager>, public NotificationListener 63 63 { // tolua_export 64 64 friend class Singleton<NotificationManager>; … … 75 75 static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export 76 76 77 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. 78 static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener. 79 80 //! Sends a Notification with the specified message to the specified client from the specified sender. 81 static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationManager::NONE, bool isLocal = false); 77 virtual bool registerNotification(const std::string& message, const std::string& sender); 82 78 83 79 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. 84 void unregisterNotification(Notification* notification, NotificationListener* listener); //!< Unregisters a Notification within the NotificationManager for a given NotificationListener. 85 bool registerListener(NotificationListener* listener); //!< Registers a NotificationListener within the NotificationManager. 86 void unregisterListener(NotificationListener* listener); //!< Unregisters a NotificationListener withing the NotificationManager. 80 void unregisterNotification(Notification* notification, NotificationQueue* queue); //!< Unregisters a Notification within the NotificationManager for a given NotificationQueue. 87 81 88 void getNotifications(Notification Listener* listener, std::multimap<std::time_t, Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd); //!< Fetches the Notifications for a specific NotificationListenerin a specified timeframe and stores them in the input map.82 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. 89 83 90 84 /** 91 @brief Fetches the Notifications for a specific Notification Listenerin a timeframe from now-timeDelay to now and stores them in the input map.92 @param listener The Notification Listenerthe Notifications are fetched for.85 @brief Fetches the Notifications for a specific NotificationQueue in a timeframe from now-timeDelay to now and stores them in the input map. 86 @param listener The NotificationQueue the Notifications are fetched for. 93 87 @param map A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. 94 88 @param timeDelay The timespan. 95 89 @return Returns true if successful. 96 90 */ 97 void getNotifications(Notification Listener* listener, std::multimap<std::time_t, Notification*>* map, int timeDelay)98 { this->getNotifications( listener, map, std::time(0)-timeDelay, std::time(0)); }91 void getNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int timeDelay) 92 { this->getNotifications(queue, map, std::time(0)-timeDelay, std::time(0)); } 99 93 100 void getNewestNotifications(Notification Listener* listener, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications); //!< Fetches the newest Notifications for a specific NotificationListenerand stores them in the input map.94 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. 101 95 102 96 void enterEditMode(void); //!< Enters the edit mode of the NotificationLayer. … … 114 108 static NotificationManager* singletonPtr_s; 115 109 116 unsigned int highestIndex_; //!< This variable holds the highest index (resp. key) in notificationLists_s, to secure that no key appears twice.117 118 110 std::multimap<std::time_t, Notification*> allNotificationsList_; //!< Container where all Notifications are stored. 119 std::map<NotificationListener*, unsigned int> listenerList_; //!< Container where all NotificationListeners are stored with a number as identifier. 120 std::map<int,std::multimap<std::time_t, Notification*>*> notificationLists_; //!< Container where all Notifications, for each identifier (associated with a NotificationListener), are stored. 111 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. 121 112 122 113 std::map<const std::string, NotificationQueue*> queues_; //!< The list of NotificationQueues created by the NotificationManager. -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.cc
r8371 r8374 90 90 this->create(); // Creates the NotificationQueue in lua. 91 91 92 // Register the NotificationQueue as NotificationListener with the NotificationManager.93 bool listenerRegistered = NotificationManager::getInstance().registerListener(this);94 if(!listenerRegistered) // If the registration has failed.95 {96 this->registered_ = false;97 // Remove the NotificationQueue in lua.98 if(GameMode::showsGraphics())99 GUIManager::getInstance().getLuaState()->doString("NotificationLayer.removeQueue(\"" + this->getName() + "\")");100 NotificationManager::getInstance().unregisterQueue(this);101 COUT(1) << "Error: NotificationQueue '" << this->getName() << "' could not be registered." << std::endl;102 return;103 }104 105 92 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 106 93 } … … 119 106 120 107 // Unregister with the NotificationManager. 121 NotificationManager::getInstance().unregisterListener(this);122 108 NotificationManager::getInstance().unregisterQueue(this); 123 109 } … … 181 167 Updates the NotificationQueue. 182 168 Updates by clearing the queue and requesting all relevant Notifications from the NotificationManager and inserting them into the queue. 169 This is called by the NotificationManager when the Notifications have changed so much, that the NotificationQueue may have to re-initialize his operations. 183 170 */ 184 171 void NotificationQueue::update(void) … … 418 405 this->targets_.insert(string[i]); 419 406 407 // TODO: Why? 420 408 if(this->registered_) 421 409 { 422 NotificationManager::getInstance().unregister Listener(this);423 NotificationManager::getInstance().register Listener(this);410 NotificationManager::getInstance().unregisterQueue(this); 411 NotificationManager::getInstance().registerQueue(this); 424 412 } 425 413 } -
code/branches/tutoriallevel2/src/modules/notifications/NotificationQueue.h
r8371 r8374 46 46 47 47 #include "tools/interfaces/Tickable.h" 48 #include "interfaces/NotificationListener.h"49 48 50 49 namespace orxonox // tolua_export … … 90 89 */ 91 90 class _NotificationsExport NotificationQueue // tolua_export 92 : public Tickable , public NotificationListener91 : public Tickable 93 92 { // tolua_export 94 93 -
code/branches/tutoriallevel2/src/modules/questsystem/QuestDescription.cc
r7474 r8374 40 40 #include "infos/PlayerInfo.h" 41 41 42 #include " notifications/NotificationManager.h"42 #include "interfaces/NotificationListener.h" 43 43 44 44 namespace orxonox … … 119 119 } 120 120 121 Notification Manager::sendNotification(message, player->getClientID(), QuestDescription::SENDER);121 NotificationListener::sendNotification(message, player->getClientID(), QuestDescription::SENDER); 122 122 return true; 123 123 } -
code/branches/tutoriallevel2/src/orxonox/interfaces/CMakeLists.txt
r7504 r8374 1 1 ADD_SOURCE_FILES(ORXONOX_SRC_FILES 2 2 InterfaceCompilation.cc 3 NotificationListener.cc 3 4 Pickupable.cc 4 5 PickupCarrier.cc -
code/branches/tutoriallevel2/src/orxonox/interfaces/InterfaceCompilation.cc
r7606 r8374 86 86 RegisterRootObject(Rewardable); 87 87 } 88 89 //----------------------------90 // NotificationListener91 //----------------------------92 NotificationListener::NotificationListener()93 {94 RegisterRootObject(NotificationListener);95 }96 88 } -
code/branches/tutoriallevel2/src/orxonox/interfaces/NotificationListener.h
r7552 r8374 67 67 NotificationListener(); 68 68 virtual ~NotificationListener() {} 69 70 /** 71 @brief Get the senders that are targets of this NotificationListener. 72 @return Returns the set of senders that are targets of this NotificationListener. 73 */ 74 virtual const std::set<std::string> & getTargetsSet(void) = 0; 75 76 /** 77 @brief Updates the whole NotificationListener. 78 This is called by the @ref orxonox::NotificationManager "NotificationManager" when the @ref orxonox::Notification "Notifications" have changed so much, that the NotificationListener may have to re-initialize his operations. 79 */ 80 virtual void update(void) = 0; 81 /** 82 @brief Updates the NotificationListener, when a new Notification has come in at the specified time. 83 @param notification A pointer to the @ref orxonox::Notification "Notification". 84 @param time The time the @ref orxonox::Notification "Notification" has come in. 85 */ 86 virtual void update(Notification* notification, const std::time_t & time) = 0; 69 70 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. 71 static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener. 72 73 static void sendNotification(const std::string& message, unsigned int clientId, const std::string& sender = NotificationListener::NONE, bool isLocal = false); 74 75 virtual bool registerNotification(const std::string& message, const std::string& sender) 76 { return false; } 87 77 }; 88 78 }
Note: See TracChangeset
for help on using the changeset viewer.