- Timestamp:
- Apr 8, 2009, 1:07:27 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk/src/orxonox/overlays/notifications/Notification.cc
r2662 r2909 27 27 */ 28 28 29 /** 30 @file Notification.cc 31 @brief Implementation of the Notification class. 32 */ 33 29 34 #include "OrxonoxStableHeaders.h" 30 35 #include "Notification.h" 31 36 32 37 #include "core/CoreIncludes.h" 38 #include "util/Exception.h" 33 39 34 40 #include "NotificationManager.h" … … 36 42 namespace orxonox 37 43 { 44 45 /** 46 @brief 47 Default constructor. Initializes the object. 48 */ 38 49 Notification::Notification(BaseObject* creator) : BaseObject(creator) 39 50 { 40 RegisterObject(Notification);51 this->initialize(); 41 52 } 42 53 43 Notification::Notification(BaseObject* creator, const std::string & message, const std::string & title, float time) : BaseObject(creator) 54 /** 55 @brief 56 Constructor. Creates a Notification with the input message. 57 @param message 58 The message of the Notification. 59 */ 60 Notification::Notification(const std::string & message) : BaseObject(this) 44 61 { 45 this->title_ = title;46 62 this->message_ = message; 47 if(time > 0)48 this->displayTime_ = time;49 63 } 50 64 65 /** 66 @brief 67 Destructor. 68 */ 51 69 Notification::~Notification() 52 70 { 53 71 } 54 72 73 /** 74 @brief 75 Registers the object and sets some default values. 76 */ 55 77 void Notification::initialize(void) 56 78 { 57 79 RegisterObject(Notification); 58 80 59 this->title_ = "";60 81 this->message_ = ""; 61 this-> displayTime_ = NOTIFICATION_DISPLAY_TIME;82 this->sender_ = NotificationManager::NONE; 62 83 this->sent_ = false; 63 84 } 64 85 86 /** 87 @brief 88 Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE. 89 @return 90 Returns true if successful. 91 */ 65 92 bool Notification::send(void) 66 93 { 67 bool successful = NotificationManager::insertNotification(this); 68 if(successful) 69 this->sent_ = true; 70 return successful; 94 return this->send(NotificationManager::NONE); 71 95 } 72 96 73 bool Notification::setTitle(const std::string & title) 97 /** 98 @brief 99 Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues. 100 @param sender 101 The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues. 102 @return 103 Returns true if successful. 104 */ 105 bool Notification::send(const std::string & sender) 74 106 { 75 if(this->isSent()) 107 this->sender_ = sender; 108 bool successful = NotificationManager::getInstance().registerNotification(this); 109 if(!successful) 76 110 return false; 77 this->title_ = title; 111 this->sent_ = true; 112 113 COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl; 114 78 115 return true; 79 116 } 80 117 118 /** 119 @brief 120 Sets the message of the notification. 121 @param message 122 The message to be set. 123 @return 124 Returns true if successful. 125 */ 81 126 bool Notification::setMessage(const std::string & message) 82 127 { 83 if(this->isSent()) 128 if(this->isSent()) //!< The message cannot be changed if the message has already been sent. 84 129 return false; 85 130 this->message_ = message; 86 131 return true; 87 132 } 88 89 bool Notification::setDisplayTime(float time) 90 { 91 if(this->isSent()) 92 { 93 return false; 94 } 95 if(time > 0) 96 { 97 this->displayTime_ = time; 98 return true; 99 } 100 return false; 101 } 133 102 134 }
Note: See TracChangeset
for help on using the changeset viewer.