Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 1:36:05 AM (15 years ago)
Author:
landauf
Message:

reverted r2909 because there were some unwanted files included

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/orxonox/overlays/notifications/Notification.cc

    r2909 r2910  
    2727 */
    2828
    29 /**
    30     @file Notification.cc
    31     @brief Implementation of the Notification class.
    32 */
    33 
    3429#include "OrxonoxStableHeaders.h"
    3530#include "Notification.h"
    3631
    3732#include "core/CoreIncludes.h"
    38 #include "util/Exception.h"
    3933
    4034#include "NotificationManager.h"
     
    4236namespace orxonox
    4337{
    44 
    45     /**
    46     @brief
    47         Default constructor. Initializes the object.
    48     */
    4938    Notification::Notification(BaseObject* creator) : BaseObject(creator)
    5039    {
    51         this->initialize();
     40        RegisterObject(Notification);
    5241    }
    5342   
    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)
    6144    {
     45        this->title_ = title;
    6246        this->message_ = message;
     47        if(time > 0)
     48            this->displayTime_ = time;
    6349    }
    6450   
    65     /**
    66     @brief
    67         Destructor.
    68     */
    6951    Notification::~Notification()
    7052    {
    7153    }
    7254   
    73     /**
    74     @brief
    75         Registers the object and sets some default values.
    76     */
    7755    void Notification::initialize(void)
    7856    {
    7957        RegisterObject(Notification);
    8058       
     59        this->title_ = "";
    8160        this->message_ = "";
    82         this->sender_ = NotificationManager::NONE;
     61        this->displayTime_ = NOTIFICATION_DISPLAY_TIME;
    8362        this->sent_ = false;
    8463    }
    8564   
    86     /**
    87     @brief
    88         Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
    89     @return
    90         Returns true if successful.
    91     */
    9265    bool Notification::send(void)
    9366    {
    94         return this->send(NotificationManager::NONE);
     67        bool successful = NotificationManager::insertNotification(this);
     68        if(successful)
     69            this->sent_ = true;
     70        return successful;
    9571    }
    9672   
    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)
    10674    {
    107         this->sender_ = sender;
    108         bool successful = NotificationManager::getInstance().registerNotification(this);
    109         if(!successful)
     75        if(this->isSent())
    11076            return false;
    111         this->sent_ = true;
    112        
    113         COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
    114        
     77        this->title_ = title;
    11578        return true;
    11679    }
    11780   
    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     */
    12681    bool Notification::setMessage(const std::string & message)
    12782    {
    128         if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
     83        if(this->isSent())
    12984            return false;
    13085        this->message_ = message;
    13186        return true;
    13287    }
    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    }
    134102}
Note: See TracChangeset for help on using the changeset viewer.