[2280] | 1 | /* |
---|
| 2 | * ORXONOX - the hottest 3D action shooter ever to exist |
---|
| 3 | * > www.orxonox.net < |
---|
| 4 | * |
---|
| 5 | * |
---|
| 6 | * License notice: |
---|
| 7 | * |
---|
| 8 | * This program is free software; you can redistribute it and/or |
---|
| 9 | * modify it under the terms of the GNU General Public License |
---|
| 10 | * as published by the Free Software Foundation; either version 2 |
---|
| 11 | * of the License, or (at your option) any later version. |
---|
| 12 | * |
---|
| 13 | * This program is distributed in the hope that it will be useful, |
---|
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 16 | * GNU General Public License for more details. |
---|
| 17 | * |
---|
| 18 | * You should have received a copy of the GNU General Public License |
---|
| 19 | * along with this program; if not, write to the Free Software |
---|
| 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
---|
| 21 | * |
---|
| 22 | * Author: |
---|
| 23 | * Damian 'Mozork' Frick |
---|
| 24 | * Co-authors: |
---|
| 25 | * ... |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
[2911] | 29 | /** |
---|
[7403] | 30 | @file NotificationManager.cc |
---|
[2911] | 31 | @brief Implementation of the NotificationManager class. |
---|
| 32 | */ |
---|
| 33 | |
---|
[2280] | 34 | #include "NotificationManager.h" |
---|
| 35 | |
---|
[7403] | 36 | #include "core/command/ConsoleCommand.h" |
---|
| 37 | #include "core/CoreIncludes.h" |
---|
| 38 | #include "core/LuaState.h" |
---|
| 39 | #include "util/ScopedSingletonManager.h" |
---|
[2911] | 40 | |
---|
[5619] | 41 | #include "interfaces/NotificationListener.h" |
---|
[2280] | 42 | |
---|
[7403] | 43 | #include "NotificationQueue.h" |
---|
[8446] | 44 | #include "NotificationQueueCEGUI.h" |
---|
[7403] | 45 | |
---|
[2435] | 46 | namespace orxonox |
---|
| 47 | { |
---|
[2280] | 48 | |
---|
[7488] | 49 | ManageScopedSingleton(NotificationManager, ScopeID::Root, false); |
---|
[7403] | 50 | |
---|
[2911] | 51 | /** |
---|
| 52 | @brief |
---|
| 53 | Constructor. Registers the Object. |
---|
| 54 | */ |
---|
| 55 | NotificationManager::NotificationManager() |
---|
[2280] | 56 | { |
---|
[2911] | 57 | RegisterRootObject(NotificationManager); |
---|
| 58 | |
---|
[7403] | 59 | COUT(3) << "NotificatioManager created." << std::endl; |
---|
[2280] | 60 | } |
---|
| 61 | |
---|
[2911] | 62 | /** |
---|
| 63 | @brief |
---|
| 64 | Destructor. |
---|
| 65 | */ |
---|
[2280] | 66 | NotificationManager::~NotificationManager() |
---|
| 67 | { |
---|
[7488] | 68 | // Destroys all Notifications. |
---|
| 69 | for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it!= this->allNotificationsList_.end(); it++) |
---|
| 70 | it->second->destroy(); |
---|
| 71 | this->allNotificationsList_.clear(); |
---|
| 72 | |
---|
[7403] | 73 | COUT(3) << "NotificationManager destroyed." << std::endl; |
---|
[2280] | 74 | } |
---|
[2501] | 75 | |
---|
[2911] | 76 | /** |
---|
| 77 | @brief |
---|
[7403] | 78 | Is called before the object is destroyed. |
---|
| 79 | */ |
---|
| 80 | void NotificationManager::preDestroy(void) |
---|
| 81 | { |
---|
| 82 | // Destroys all NotificationQueues that have been registered with the NotificationManager. |
---|
[8079] | 83 | std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); |
---|
| 84 | while(it != this->queues_.end()) |
---|
| 85 | { |
---|
[8446] | 86 | it->second->destroy(); |
---|
[8079] | 87 | it = this->queues_.begin(); |
---|
| 88 | } |
---|
[7489] | 89 | |
---|
[7403] | 90 | this->queues_.clear(); |
---|
| 91 | } |
---|
[8445] | 92 | |
---|
| 93 | /** |
---|
| 94 | @brief |
---|
| 95 | Creates and registers a Notification with the input message from the input sender. |
---|
| 96 | This is called by the NotificationListener, whenever a new notification arrives. |
---|
| 97 | @param message |
---|
| 98 | The message of the new Notification. |
---|
| 99 | @param sender |
---|
| 100 | The name of the entity (of the collective) that sent the new Notification. |
---|
[8448] | 101 | @param type |
---|
| 102 | The type of the new Notification. |
---|
[8445] | 103 | @return |
---|
| 104 | Returns true if successful. |
---|
| 105 | */ |
---|
| 106 | bool NotificationManager::registerNotification(const std::string& message, const std::string& sender, notificationMessageType::Value type) |
---|
[7474] | 107 | { |
---|
[8445] | 108 | // TODO: Do something with the type. |
---|
| 109 | Notification* notification = new Notification(message, sender, type); |
---|
[8374] | 110 | return this->registerNotification(notification); |
---|
[7474] | 111 | } |
---|
| 112 | |
---|
[7403] | 113 | /** |
---|
| 114 | @brief |
---|
[8445] | 115 | Executes the input command from the input sender. |
---|
| 116 | This is called by the NotificationListener, whenever a new command arrives. |
---|
| 117 | @param command |
---|
| 118 | The command to be executed, |
---|
| 119 | @param sender |
---|
| 120 | The The name of the entity (of the collective) that sent the command. |
---|
[8448] | 121 | @return |
---|
| 122 | Returns true if the command was successfully executed. |
---|
[8445] | 123 | */ |
---|
| 124 | bool NotificationManager::executeCommand(notificationCommand::Value command, const std::string& sender) |
---|
| 125 | { |
---|
[8448] | 126 | bool commandExecuted = false; |
---|
[8445] | 127 | if(command == notificationCommand::clear) |
---|
| 128 | { |
---|
[8448] | 129 | if(this->commandClear(sender)) |
---|
| 130 | commandExecuted = true; |
---|
[8445] | 131 | } |
---|
| 132 | |
---|
[8448] | 133 | if(commandExecuted) |
---|
| 134 | COUT(3) << "Notification command \"" << NotificationListener::command2Str(command) << "\" executed." << endl; |
---|
| 135 | |
---|
| 136 | return commandExecuted; |
---|
[8445] | 137 | } |
---|
| 138 | |
---|
| 139 | /** |
---|
| 140 | @brief |
---|
| 141 | The clear command. Clears all NotificationQueues that have its sender as a target. |
---|
| 142 | @param sender |
---|
| 143 | The sender of the clear command. |
---|
[8448] | 144 | @return |
---|
| 145 | Returns true if the command was successfully executed by at least one NotificationQueue, false if it was not executed. |
---|
[8445] | 146 | */ |
---|
[8448] | 147 | bool NotificationManager::commandClear(const std::string& sender) |
---|
[8445] | 148 | { |
---|
| 149 | bool all = (sender == NotificationListener::ALL); |
---|
[8448] | 150 | bool executed = false; |
---|
[8445] | 151 | // Clear all NotificationQueues that have the input sender as target. |
---|
| 152 | for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues. |
---|
| 153 | { |
---|
| 154 | const std::set<std::string>& set = it->second->getTargetsSet(); |
---|
| 155 | // If either the sender is 'all', the NotificationQueue has as target all or the NotificationQueue has the input sender as a target. |
---|
| 156 | if(all || set.find(NotificationListener::ALL) != set.end() || set.find(sender) != set.end()) |
---|
[8448] | 157 | executed = it->second->tidy() || executed; |
---|
[8445] | 158 | } |
---|
[8448] | 159 | |
---|
| 160 | return executed; |
---|
[8445] | 161 | } |
---|
| 162 | |
---|
| 163 | /** |
---|
| 164 | @brief |
---|
[8374] | 165 | Registers a Notification within the NotificationManager and makes sure that the Notification is sent to all the NotificationQueues associated with its sender. |
---|
[2911] | 166 | @param notification |
---|
| 167 | The Notification to be registered. |
---|
| 168 | @return |
---|
| 169 | Returns true if successful. |
---|
| 170 | */ |
---|
| 171 | bool NotificationManager::registerNotification(Notification* notification) |
---|
| 172 | { |
---|
[7403] | 173 | assert(notification); |
---|
[5619] | 174 | |
---|
[7552] | 175 | std::time_t time = std::time(0); // Get current time. |
---|
[5619] | 176 | |
---|
[7403] | 177 | // Add the Notification to the list that holds all Notifications. |
---|
| 178 | this->allNotificationsList_.insert(std::pair<std::time_t, Notification*>(time, notification)); |
---|
[5619] | 179 | |
---|
[8374] | 180 | if(notification->getSender() == NotificationListener::NONE) // If the sender has no specific name, then the Notification is only added to the list of all Notifications. |
---|
[2911] | 181 | return true; |
---|
[5619] | 182 | |
---|
[8445] | 183 | // If all are the sender, then the Notifications is added to every NotificationQueue. |
---|
| 184 | bool all = (notification->getSender() == NotificationListener::ALL); |
---|
[5619] | 185 | |
---|
[8374] | 186 | // Insert the Notification in all NotificationQueues that have its sender as target. |
---|
| 187 | for(std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.begin(); it != this->queues_.end(); it++) // Iterate through all NotificationQueues. |
---|
[2435] | 188 | { |
---|
[8374] | 189 | const std::set<std::string>& set = it->second->getTargetsSet(); |
---|
| 190 | bool bAll = set.find(NotificationListener::ALL) != set.end(); |
---|
| 191 | // If either the Notification has as sender 'all', the NotificationQueue displays all Notifications or the NotificationQueue has the sender of the Notification as target. |
---|
[7403] | 192 | if(all || bAll || set.find(notification->getSender()) != set.end()) |
---|
[2280] | 193 | { |
---|
[7403] | 194 | if(!bAll) |
---|
[8374] | 195 | 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. |
---|
| 196 | it->second->update(notification, time); // Update the NotificationQueue. |
---|
[2435] | 197 | } |
---|
| 198 | } |
---|
[5619] | 199 | |
---|
[7403] | 200 | COUT(4) << "Notification (&" << notification << ") registered with the NotificationManager." << std::endl; |
---|
[5619] | 201 | |
---|
[2280] | 202 | return true; |
---|
| 203 | } |
---|
[5619] | 204 | |
---|
[2911] | 205 | /** |
---|
| 206 | @brief |
---|
[8374] | 207 | Unregisters a Notification within the NotificationManager for a given NotificationQueue. |
---|
[7163] | 208 | @param notification |
---|
| 209 | A pointer to the Notification to be unregistered. |
---|
[8374] | 210 | @param queue |
---|
| 211 | A pointer to the NotificationQueue the Notification is unregistered for. |
---|
[7163] | 212 | */ |
---|
[8374] | 213 | void NotificationManager::unregisterNotification(Notification* notification, NotificationQueue* queue) |
---|
[7163] | 214 | { |
---|
| 215 | assert(notification); |
---|
[8374] | 216 | assert(queue); |
---|
[7163] | 217 | |
---|
[8374] | 218 | // Remove the Notification from the list of Notifications of the input NotificationQueue. |
---|
| 219 | this->removeNotification(notification, *(this->notificationLists_.find(queue->getName())->second)); |
---|
[7163] | 220 | |
---|
[8374] | 221 | COUT(4) << "Notification (&" << notification << ") unregistered with the NotificationManager from NotificationQueue " << queue->getName() << "." << std::endl; |
---|
[7163] | 222 | } |
---|
| 223 | |
---|
| 224 | /** |
---|
| 225 | @brief |
---|
[7403] | 226 | Helper method that removes an input Notification form an input map. |
---|
[7163] | 227 | @param notification |
---|
[7403] | 228 | A pointer to the Notification to be removed. |
---|
[7163] | 229 | @param map |
---|
[7403] | 230 | The map the Notification should be removed from. |
---|
[7163] | 231 | @return |
---|
| 232 | Returns true if successful. |
---|
| 233 | */ |
---|
| 234 | bool NotificationManager::removeNotification(Notification* notification, std::multimap<std::time_t, Notification*>& map) |
---|
| 235 | { |
---|
| 236 | // Iterates through all items in the map until the Notification is found. |
---|
| 237 | //TODO: Do more efficiently? |
---|
| 238 | for(std::multimap<std::time_t, Notification*>::iterator it = map.begin(); it != map.end(); it++) |
---|
| 239 | { |
---|
| 240 | if(it->second == notification) |
---|
| 241 | { |
---|
| 242 | map.erase(it); |
---|
| 243 | return true; |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | return false; |
---|
| 247 | } |
---|
| 248 | |
---|
| 249 | /** |
---|
| 250 | @brief |
---|
[8374] | 251 | Fetches the Notifications for a specific NotificationQueue in a specified timeframe and stores them in the input map. |
---|
| 252 | @param queue |
---|
| 253 | The NotificationQueue the Notifications are fetched for. |
---|
[2911] | 254 | @param map |
---|
[7403] | 255 | A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. |
---|
[2911] | 256 | @param timeFrameStart |
---|
| 257 | The start time of the timeframe. |
---|
| 258 | @param timeFrameEnd |
---|
| 259 | The end time of the timeframe. |
---|
| 260 | @return |
---|
| 261 | Returns true if successful. |
---|
| 262 | */ |
---|
[8374] | 263 | void NotificationManager::getNotifications(NotificationQueue* queue, std::multimap<std::time_t,Notification*>* map, const std::time_t & timeFrameStart, const std::time_t & timeFrameEnd) |
---|
[2346] | 264 | { |
---|
[8374] | 265 | assert(queue); |
---|
[7403] | 266 | assert(map); |
---|
[2501] | 267 | |
---|
[8374] | 268 | std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue. |
---|
[5619] | 269 | |
---|
[2911] | 270 | std::multimap<std::time_t,Notification*>::iterator it, itLowest, itHighest; |
---|
[7403] | 271 | // Iterators pointing to the bounds specified by the specified start and end times of the time frame. |
---|
[2911] | 272 | itLowest = notifications->lower_bound(timeFrameStart); |
---|
[7403] | 273 | itHighest = notifications->upper_bound(timeFrameEnd); |
---|
[5619] | 274 | |
---|
[7403] | 275 | for(it = itLowest; it != itHighest; it++) // Iterate through the Notifications from the start of the time frame to the end of it. |
---|
| 276 | map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map. |
---|
| 277 | } |
---|
[5619] | 278 | |
---|
[7403] | 279 | /** |
---|
| 280 | @brief |
---|
[8374] | 281 | Fetches the newest Notifications for a specific NotificationQueue and stores them in the input map. |
---|
| 282 | @param queue |
---|
| 283 | The NotificationQueue the Notifications are fetched for. |
---|
[8371] | 284 | @param map |
---|
| 285 | A pointer to a multimap, in which the notifications are stored. The map needs to have been allocated. |
---|
| 286 | @param numberOfNotifications |
---|
| 287 | The number of newest Notifications to be got. |
---|
| 288 | @return |
---|
| 289 | Returns true if successful. |
---|
| 290 | */ |
---|
[8374] | 291 | void NotificationManager::getNewestNotifications(NotificationQueue* queue, std::multimap<std::time_t, Notification*>* map, int numberOfNotifications) |
---|
[8371] | 292 | { |
---|
[8374] | 293 | assert(queue); |
---|
[8371] | 294 | assert(map); |
---|
| 295 | |
---|
[8374] | 296 | std::multimap<std::time_t, Notification*>* notifications = this->notificationLists_[queue->getName()]; // All the Notifications for the input NotificationQueue. |
---|
[8371] | 297 | |
---|
| 298 | if(!notifications->empty()) // If the list of Notifications is not empty. |
---|
| 299 | { |
---|
| 300 | std::multimap<std::time_t,Notification*>::iterator it = notifications->end(); |
---|
| 301 | for(int i = 0; i < numberOfNotifications; i++) // Iterate through the Notifications from the newest until we have the specified number of notifications. |
---|
| 302 | { |
---|
| 303 | it--; |
---|
| 304 | map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); // Add the found Notifications to the map. |
---|
| 305 | if(it == notifications->begin()) |
---|
| 306 | break; |
---|
| 307 | } |
---|
| 308 | } |
---|
| 309 | } |
---|
| 310 | |
---|
| 311 | /** |
---|
| 312 | @brief |
---|
[7403] | 313 | Registers a NotificationQueue. |
---|
[8374] | 314 | 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. |
---|
[7403] | 315 | @param queue |
---|
| 316 | A pointer to the NotificationQueue to be registered. |
---|
| 317 | @return |
---|
| 318 | Returns true if successful. If e.g. the a NotificationQueue with that name already exists this returns false. |
---|
| 319 | */ |
---|
| 320 | bool NotificationManager::registerQueue(NotificationQueue* queue) |
---|
| 321 | { |
---|
[8374] | 322 | assert(queue); |
---|
| 323 | |
---|
| 324 | // If the NotificationQueue is already registered. |
---|
| 325 | if(this->queues_.find(queue->getName()) != this->queues_.end()) |
---|
| 326 | return false; |
---|
| 327 | |
---|
| 328 | this->queues_.insert(std::pair<const std::string, NotificationQueue*>(queue->getName(), queue)); // Add the NotificationQueue to the list of NotificationQueues. |
---|
| 329 | |
---|
| 330 | const std::set<std::string>& set = queue->getTargetsSet(); |
---|
| 331 | |
---|
| 332 | // 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. |
---|
| 333 | bool bAll = set.find(NotificationListener::ALL) != set.end(); |
---|
| 334 | std::multimap<std::time_t, Notification*>* map = NULL; |
---|
| 335 | if(bAll) |
---|
| 336 | this->notificationLists_[queue->getName()] = &this->allNotificationsList_; |
---|
| 337 | // Else a new list (resp. multimap) is created and added to the list of Notification lists for NotificationQueues. |
---|
| 338 | else |
---|
| 339 | { |
---|
| 340 | this->notificationLists_[queue->getName()] = new std::multimap<std::time_t, Notification*>; |
---|
| 341 | map = this->notificationLists_[queue->getName()]; |
---|
| 342 | } |
---|
| 343 | |
---|
| 344 | // Iterate through all Notifications to determine whether any of them should belong to the newly registered NotificationQueue. |
---|
| 345 | for(std::multimap<std::time_t, Notification*>::iterator it = this->allNotificationsList_.begin(); it != this->allNotificationsList_.end(); it++) |
---|
| 346 | { |
---|
| 347 | if(!bAll && set.find(it->second->getSender()) != set.end()) // Checks whether the listener has the sender of the current Notification as target. |
---|
| 348 | map->insert(std::pair<std::time_t, Notification*>(it->first, it->second)); |
---|
| 349 | } |
---|
| 350 | |
---|
| 351 | queue->update(); // Update the queue. |
---|
| 352 | |
---|
[8079] | 353 | COUT(4) << "NotificationQueue '" << queue->getName() << "' registered with the NotificationManager." << std::endl; |
---|
[8374] | 354 | return true; |
---|
[7403] | 355 | } |
---|
| 356 | |
---|
| 357 | /** |
---|
| 358 | @brief |
---|
| 359 | Unregisters a NotificationQueue. |
---|
| 360 | @param queue |
---|
| 361 | A pointer to the NotificationQueue to be unregistered. |
---|
| 362 | */ |
---|
| 363 | void NotificationManager::unregisterQueue(NotificationQueue* queue) |
---|
| 364 | { |
---|
[8374] | 365 | assert(queue); |
---|
| 366 | |
---|
| 367 | std::multimap<std::time_t, Notification*>* map = this->notificationLists_.find(queue->getName())->second; |
---|
| 368 | |
---|
| 369 | // If the map is not the map of all Notifications, make sure all Notifications are unregistered. |
---|
| 370 | std::multimap<std::time_t, Notification*>::iterator it = map->begin(); |
---|
| 371 | if(map != &this->allNotificationsList_) |
---|
| 372 | { |
---|
| 373 | while(it != map->end()) |
---|
| 374 | { |
---|
| 375 | this->unregisterNotification(it->second, queue); |
---|
| 376 | it = map->begin(); |
---|
| 377 | } |
---|
| 378 | delete map; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | // Remove the NotificationQueue from the list of NotificationQueues. |
---|
| 382 | this->queues_.erase(queue->getName()); |
---|
| 383 | // Remove the Notifications list that was associated with the input NotificationQueue. |
---|
| 384 | this->notificationLists_.erase(queue->getName()); |
---|
| 385 | |
---|
[8079] | 386 | COUT(4) << "NotificationQueue '" << queue->getName() << "' unregistered with the NotificationManager." << std::endl; |
---|
[7403] | 387 | } |
---|
| 388 | |
---|
| 389 | /** |
---|
| 390 | @brief |
---|
| 391 | Get the NotificationQueue with the input name. |
---|
| 392 | @param name |
---|
| 393 | The name of the NotificationQueue. |
---|
| 394 | @return |
---|
| 395 | Returns a pointer to the NotificationQueue with the input name. Returns NULL if no NotificationQueue with such a name exists. |
---|
| 396 | */ |
---|
| 397 | NotificationQueue* NotificationManager::getQueue(const std::string & name) |
---|
| 398 | { |
---|
| 399 | std::map<const std::string, NotificationQueue*>::iterator it = this->queues_.find(name); |
---|
| 400 | // Returns NULL if no such NotificationQueue exists. |
---|
| 401 | if(it == this->queues_.end()) |
---|
| 402 | return NULL; |
---|
| 403 | |
---|
| 404 | return (*it).second; |
---|
| 405 | } |
---|
| 406 | |
---|
[8448] | 407 | /** |
---|
| 408 | @brief |
---|
| 409 | Loads all the NotificationQueues that should exist. |
---|
| 410 | */ |
---|
| 411 | void NotificationManager::loadQueues(void) |
---|
| 412 | { |
---|
| 413 | NotificationQueueCEGUI* allQueue = new NotificationQueueCEGUI("all"); |
---|
| 414 | allQueue->setDisplaySize(Vector2(0.5, 0)); |
---|
| 415 | allQueue->setPosition(Vector4(0.0, 10, 0.3, 0)); |
---|
| 416 | |
---|
[8451] | 417 | NotificationQueueCEGUI* infoQueue = new NotificationQueueCEGUI("info", "gameinfo", 1, -1); |
---|
[8448] | 418 | infoQueue->setPosition(Vector4(0.2, 0, 0.8, 0)); |
---|
| 419 | infoQueue->setFontSize(24); |
---|
| 420 | infoQueue->setFontColor(Vector4(1.0, 1.0, 0.0, 0.8)); |
---|
| 421 | infoQueue->setAlignment("HorzCentred"); |
---|
| 422 | infoQueue->setDisplaySize(Vector2(0.6, 0.0)); |
---|
| 423 | } |
---|
| 424 | |
---|
[8449] | 425 | // Notification class |
---|
| 426 | |
---|
| 427 | /** |
---|
| 428 | @brief |
---|
| 429 | Constructor. Creates a Notification with the input message and sender. |
---|
| 430 | @param message |
---|
| 431 | The message of the Notification. |
---|
| 432 | @param sender |
---|
| 433 | The sender of the Notification. |
---|
| 434 | @param type |
---|
| 435 | |
---|
| 436 | */ |
---|
| 437 | Notification::Notification(const std::string& message, const std::string& sender, notificationMessageType::Value type) |
---|
| 438 | { |
---|
| 439 | this->initialize(); |
---|
| 440 | this->message_ = message; |
---|
| 441 | this->sender_ = sender; |
---|
| 442 | this->type_ = type; |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | /** |
---|
| 446 | @brief |
---|
| 447 | Destructor. |
---|
| 448 | */ |
---|
| 449 | Notification::~Notification() |
---|
| 450 | { |
---|
| 451 | |
---|
| 452 | } |
---|
| 453 | |
---|
| 454 | /** |
---|
| 455 | @brief |
---|
| 456 | Registers the object and sets some default values. |
---|
| 457 | */ |
---|
| 458 | void Notification::initialize(void) |
---|
| 459 | { |
---|
| 460 | this->message_.clear(); |
---|
| 461 | this->sender_ = NotificationListener::NONE; |
---|
| 462 | } |
---|
| 463 | |
---|
[2280] | 464 | } |
---|