- Timestamp:
- May 20, 2010, 10:36:48 PM (14 years ago)
- Location:
- code/branches/presentation3/src/modules/questsystem/notifications
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/modules/questsystem/notifications/Notification.cc
r6417 r6945 40 40 { 41 41 42 CreateUnloadableFactory(Notification); 43 42 44 /** 43 45 @brief … … 56 58 The message of the Notification. 57 59 */ 58 Notification::Notification( const std::string & message) : BaseObject(NULL)60 Notification::Notification(BaseObject* creator, const std::string & message) : BaseObject(creator) 59 61 { 60 62 this->message_ = message; … … 67 69 Notification::~Notification() 68 70 { 71 69 72 } 70 73 -
code/branches/presentation3/src/modules/questsystem/notifications/Notification.h
r5781 r6945 53 53 public: 54 54 Notification(BaseObject* creator); 55 Notification( const std::string & message);55 Notification(BaseObject* creator, const std::string & message); 56 56 virtual ~Notification(); 57 57 -
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; -
code/branches/presentation3/src/modules/questsystem/notifications/NotificationManager.h
r6944 r6945 60 60 virtual ~NotificationManager(); 61 61 62 static const std::string ALL; 63 static const std::string NONE; 62 static const std::string ALL; //!< Static string to indicate a sender that sends to all NotificationListeners. 63 static const std::string NONE; //!< Static string to indicare a sender that sends to no specific NotificationListener. 64 64 65 65 bool registerNotification(Notification* notification); //!< Registers a Notification within the NotificationManager. … … 99 99 std::map<Notification*, unsigned int> listenerCounter_; //!< A container to store the number of NotificationListeners a Notification is registered with. 100 100 101 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); 102 101 bool removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map); //!< Helper method that removes an input notification form an input map. 103 102 104 103 }; -
code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.cc
r6944 r6945 124 124 XMLPortParam(NotificationQueue, "position", setPosition, getPosition, xmlElement, mode); 125 125 126 COUT(3) << "NotificationQueue created." << std::endl;126 COUT(3) << "NotificationQueue '" << this->getName() << "' created." << std::endl; 127 127 } 128 128 … … 179 179 delete notifications; 180 180 181 COUT( 3) << "NotificationQueueupdated." << std::endl;181 COUT(4) << "NotificationQueue '" << this->getName() << "' updated." << std::endl; 182 182 } 183 183 … … 202 202 } 203 203 204 COUT( 3) << "NotificationQueueupdated. A new Notifications has been added." << std::endl;204 COUT(4) << "NotificationQueue '" << this->getName() << "' updated. A new Notifications has been added." << std::endl; 205 205 } 206 206 … … 429 429 return false; 430 430 431 // Unregister the NotificationQueue with the NotificationManager. 431 432 NotificationManager::getInstance().unregisterNotification(container->notification, this); 432 433 -
code/branches/presentation3/src/modules/questsystem/notifications/NotificationQueue.h
r6944 r6945 71 71 72 72 Creating a NotificationQueue through XML goes as follows: 73 Be aware that the NotificationQueue must be inside the <Level></Level> tags or bad things will happen. 73 74 <NotificationQueue 74 75 name = "SuperQueue" //Name of your OverlayQueue.
Note: See TracChangeset
for help on using the changeset viewer.