Changeset 6945 for code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc
- Timestamp:
- May 20, 2010, 10:36:48 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.cc
r6944 r6945 118 118 @brief 119 119 Unregisters a Notification within the NotificationManager. 120 @param notification 121 A pointer to the Notification to be unregistered. 122 @param listener 123 A pointer to the NotificationListener the Notification is unregistered for. 120 124 */ 121 125 void NotificationManager::unregisterNotification(Notification* notification, NotificationListener* listener) … … 124 128 assert(listener); 125 129 130 // If the Notification was removed from the list of Notifications of the input NotificationListener, the counter for the Notification of the number of NotificationListeners it is present in is decremented. 126 131 if(this->removeNotification(notification, *(this->notificationLists_.find(this->listenerList_.find(listener)->second)->second))) 127 132 this->listenerCounter_[notification] = this->listenerCounter_[notification] - 1; 133 134 // If the Notification is no longer present in any of the NotificationListeners it can be removed from the map of all Notifications and be destroyed. 128 135 if(this->listenerCounter_[notification] == (unsigned int) 0) 129 136 { 130 137 this->removeNotification(notification, this->allNotificationsList_); 138 this->listenerCounter_.erase(notification); 131 139 notification->destroy(); 132 140 } … … 138 146 @brief 139 147 Helper method that removes an input notification form an input map. 148 @param notification 149 A pointer to the notification to be removed. 150 @param map 151 The map the notification should be removed from. 152 @return 153 Returns true if successful. 140 154 */ 141 155 bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map) 142 156 { 157 // Iterates through all items in the map until the Notification is found. 158 //TODO: Do more efficiently? 143 159 for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++) 144 160 { … … 222 238 this->listenerList_.erase(listener); 223 239 this->notificationLists_.erase(identifier); 224 delete map; 240 241 // If the map is not the map of all notifications, delete it. 242 if(map != &this->allNotificationsList_) 243 delete map; 225 244 226 245 COUT(4) << "NotificationListener unregistered with the NotificationManager." << std::endl;
Note: See TracChangeset
for help on using the changeset viewer.