Changeset 11071 for code/trunk/src/modules/notifications
- Timestamp:
- Jan 17, 2016, 10:29:21 PM (9 years ago)
- Location:
- code/trunk
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/notifications/NotificationDispatcher.cc
r10624 r11071 113 113 // TODO: Needed? 114 114 const std::string message = this->createNotificationMessage(); 115 NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::local);115 NotificationListener::sendNotification(message, this->getSender(), NotificationMessageType::info, NotificationSendMode::local); 116 116 117 117 // Broadcast … … 144 144 const std::string message = this->createNotificationMessage(); 145 145 // TODO: Make the type configurable. 146 NotificationListener::sendNotification(message, this->getSender(), notificationMessageType::info, notificationSendMode::network, clientId);146 NotificationListener::sendNotification(message, this->getSender(), NotificationMessageType::info, NotificationSendMode::network, clientId); 147 147 } 148 148 else if(GameMode::isServer()) … … 177 177 178 178 PlayerTrigger* pTrigger = orxonox_cast<PlayerTrigger*>(trigger); 179 PlayerInfo* player = NULL;179 PlayerInfo* player = nullptr; 180 180 181 181 // If the trigger is a PlayerTrigger. 182 if(pTrigger != NULL)182 if(pTrigger != nullptr) 183 183 { 184 184 if(!pTrigger->isForPlayer()) // The PlayerTrigger is not exclusively for Pawns which means we cannot extract one. … … 190 190 return false; 191 191 192 if(player == NULL)192 if(player == nullptr) 193 193 { 194 194 orxout(verbose, context::notifications) << "The NotificationDispatcher was triggered by an entity other than a Pawn. (" << trigger->getIdentifier()->getName() << ")" << endl; -
code/trunk/src/modules/notifications/NotificationDispatcher.h
r9667 r11071 79 79 virtual ~NotificationDispatcher(); //!< Destructor. 80 80 81 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ; //!< Method for creating a NotificationDispatcher object through XML.82 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) ;81 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a NotificationDispatcher object through XML. 82 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override; 83 83 84 84 /** -
code/trunk/src/modules/notifications/NotificationManager.cc
r10624 r11071 69 69 { 70 70 // Destroys all Notifications. 71 for( std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++)72 it->second->destroy();71 for(const auto& mapEntry : this->allNotificationsList_) 72 mapEntry.second->destroy(); 73 73 this->allNotificationsList_.clear(); 74 74 … … 106 106 Returns true if successful. 107 107 */ 108 bool NotificationManager::registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type)108 bool NotificationManager::registerNotification(const std::string& message, const std::string& sender, NotificationMessageType type) 109 109 { 110 110 // TODO: Do something with the type. … … 124 124 Returns true if the command was successfully executed. 125 125 */ 126 bool NotificationManager::executeCommand( notificationCommand::Valuecommand, const std::string& sender)126 bool NotificationManager::executeCommand(NotificationCommand command, const std::string& sender) 127 127 { 128 128 bool commandExecuted = false; 129 if(command == notificationCommand::clear)129 if(command == NotificationCommand::clear) 130 130 { 131 131 if(this->commandClear(sender)) … … 152 152 bool executed = false; 153 153 // Clear all NotificationQueues that have the input sender as target. 154 for( std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.155 { 156 const std::set<std::string>& set = it->second->getTargetsSet();154 for(const auto& mapEntry : this->queues_) // Iterate through all NotificationQueues. 155 { 156 const std::set<std::string>& set = mapEntry.second->getTargetsSet(); 157 157 // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target. 158 158 if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end()) 159 executed = it->second->tidy() || executed;159 executed = mapEntry.second->tidy() || executed; 160 160 } 161 161 … … 187 187 188 188 // Insert the Notification in all NotificationQueues that have its sender as target. 189 for( std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues.190 { 191 const std::set<std::string>& set = it->second->getTargetsSet();189 for(const auto& mapEntry : this->queues_) // Iterate through all NotificationQueues. 190 { 191 const std::set<std::string>& set = mapEntry.second->getTargetsSet(); 192 192 bool bAll = set.find(NotificationListener::ALL) != set.end(); 193 193 // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target. … … 195 195 { 196 196 if(!bAll) 197 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.198 it->second->update(notification, time); // Update the NotificationQueue.197 this->notificationLists_[mapEntry.second->getName()]->insert(std::pair<std::time_t, Notification*>(time, notification)); // Insert the Notification in the notifications list of the current NotificationQueue. 198 mapEntry.second->update(notification, time); // Update the NotificationQueue. 199 199 } 200 200 } … … 334 334 // 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. 335 335 bool bAll = set.find(NotificationListener::ALL) != set.end(); 336 std::multimap<std::time_t, Notification*>* map = NULL;336 std::multimap<std::time_t, Notification*>* map = nullptr; 337 337 if(bAll) 338 338 this->notificationLists_[queue->getName()] = &this->allNotificationsList_; … … 345 345 346 346 // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue. 347 for( std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++)348 { 349 if(!bAll && set.find( it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target.350 map->insert(std::pair<std::time_t, Notification*>( it->first, it->second));347 for(const auto& mapEntry : this->allNotificationsList_) 348 { 349 if(!bAll && set.find(mapEntry.second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target. 350 map->insert(std::pair<std::time_t, Notification*>(mapEntry.first, mapEntry.second)); 351 351 } 352 352 … … 395 395 The name of the NotificationQueue. 396 396 @return 397 Returns a pointer to the NotificationQueue with the input name. Returns NULLif no NotificationQueue with such a name exists.397 Returns a pointer to the NotificationQueue with the input name. Returns nullptr if no NotificationQueue with such a name exists. 398 398 */ 399 399 NotificationQueue* NotificationManager::getQueue(const std::string & name) 400 400 { 401 401 std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.find(name); 402 // Returns NULLif no such NotificationQueue exists.402 // Returns nullptr if no such NotificationQueue exists. 403 403 if(it == this->queues_.end()) 404 return NULL;404 return nullptr; 405 405 406 406 return (*it).second; … … 437 437 438 438 */ 439 Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type)439 Notification::Notification(const std::string& message, const std::string& sender, NotificationMessageType type) 440 440 { 441 441 this->initialize(); -
code/trunk/src/modules/notifications/NotificationManager.h
r9667 r11071 62 62 { 63 63 public: 64 Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type);64 Notification(const std::string& message, const std::string& sender, NotificationMessageType type); 65 65 virtual ~Notification(); 66 66 … … 89 89 @return Returns an enum with the type of the Notification. 90 90 */ 91 inline notificationMessageType::Value getType(void) const91 inline NotificationMessageType getType(void) const 92 92 { return this->type_; } 93 93 … … 95 95 std::string message_; //!< The Notification message. 96 96 std::string sender_; //!< The sender of the notification. 97 notificationMessageType::Value type_; //!< The type of the notification.97 NotificationMessageType type_; //!< The type of the notification. 98 98 99 99 void initialize(void); //!< Registers the object and sets some default values. … … 120 120 virtual ~NotificationManager(); 121 121 122 virtual void preDestroy(void) ; // Is called before the object is destroyed.122 virtual void preDestroy(void) override; // Is called before the object is destroyed. 123 123 124 124 /** … … 128 128 static NotificationManager& getInstance() { return Singleton<NotificationManager>::getInstance(); } // tolua_export 129 129 130 virtual bool registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type);131 virtual bool executeCommand( notificationCommand::Value command, const std::string& sender);130 virtual bool registerNotification(const std::string& message, const std::string& sender, NotificationMessageType type) override; 131 virtual bool executeCommand(NotificationCommand command, const std::string& sender) override; 132 132 133 133 bool registerNotification(Notification* notification); // Registers a Notification within the NotificationManager. -
code/trunk/src/modules/notifications/NotificationQueue.cc
r9667 r11071 206 206 { 207 207 // Add all Notifications that have been created after this NotificationQueue was created. 208 for( std::multimap<std::time_t, Notification*>::iterator it = notifications->begin(); it != notifications->end(); it++)208 for(const auto& mapEntry : *notifications) 209 209 { 210 if( it->first >= this->creationTime_)211 this->push( it->second, it->first);210 if(mapEntry.first >= this->creationTime_) 211 this->push(mapEntry.second, mapEntry.first); 212 212 } 213 213 } … … 336 336 this->ordering_.clear(); 337 337 // Delete all NotificationContainers in the list. 338 for( std::vector<NotificationContainer*>::iterator it = this->notifications_.begin(); it != this->notifications_.end(); it++)339 delete *it;338 for(NotificationContainer* notification : this->notifications_) 339 delete notification; 340 340 341 341 this->notifications_.clear(); … … 426 426 bool first = true; 427 427 // Iterate through the set of targets. 428 for( std::set<std::string>::const_iterator it = this->targets_.begin(); it != this->targets_.end(); it++)428 for(const std::string& target : this->targets_) 429 429 { 430 430 if(!first) … … 432 432 else 433 433 first = false; 434 stream << *it;434 stream << target; 435 435 } 436 436 -
code/trunk/src/modules/notifications/NotificationQueue.h
r9667 r11071 97 97 virtual ~NotificationQueue(); 98 98 99 virtual void tick(float dt) ; // To update from time to time.100 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;101 102 virtual void changedName(void) ;99 virtual void tick(float dt) override; // To update from time to time. 100 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 101 102 virtual void changedName(void) override; 103 103 104 104 void update(void); // Updates the NotificationQueue. -
code/trunk/src/modules/notifications/NotificationQueueCEGUI.cc
r10258 r11071 290 290 The name of the NotificationQueueCEGUI to be got. 291 291 @return 292 Returns a pointer to the NotificationQueueCEGUI, or NULLif it doesn't exist.292 Returns a pointer to the NotificationQueueCEGUI, or nullptr if it doesn't exist. 293 293 */ 294 294 /*static*/ NotificationQueueCEGUI* NotificationQueueCEGUI::getQueue(const std::string& name) 295 295 { 296 296 NotificationQueue* queue = NotificationManager::getInstance().getQueue(name); 297 if(queue == NULL|| !queue->isA(Class(NotificationQueueCEGUI)))298 return NULL;297 if(queue == nullptr || !queue->isA(Class(NotificationQueueCEGUI))) 298 return nullptr; 299 299 return static_cast<NotificationQueueCEGUI*>(queue); 300 300 } -
code/trunk/src/modules/notifications/NotificationQueueCEGUI.h
r9667 r11071 73 73 virtual ~NotificationQueueCEGUI(); 74 74 75 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) ;75 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; 76 76 77 virtual void changedName(void) ;77 virtual void changedName(void) override; 78 78 79 79 void destroy(bool noGraphics = false); // Destroys the NotificationQueue. … … 136 136 void registerVariables(); 137 137 138 virtual void create(void) ; // Creates the NotificationQueue in lua.138 virtual void create(void) override; // Creates the NotificationQueue in lua. 139 139 140 virtual void notificationPushed(Notification* notification) ; // Is called by the NotificationQueue when a Notification was pushed141 virtual void notificationPopped(void) ; // Is called by the NotificationQueue when a Notification was popped.142 virtual void notificationRemoved(unsigned int index) ; // Is called when a Notification was removed.140 virtual void notificationPushed(Notification* notification) override; // Is called by the NotificationQueue when a Notification was pushed 141 virtual void notificationPopped(void) override; // Is called by the NotificationQueue when a Notification was popped. 142 virtual void notificationRemoved(unsigned int index) override; // Is called when a Notification was removed. 143 143 144 virtual void clear(bool noGraphics = false) ; // Clears the NotificationQueue by removing all NotificationContainers.144 virtual void clear(bool noGraphics = false) override; // Clears the NotificationQueue by removing all NotificationContainers. 145 145 146 146 protected:
Note: See TracChangeset
for help on using the changeset viewer.