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