Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Apr 8, 2009, 2:58:40 AM (15 years ago)
Author:
landauf
Message:

Merged r1-2096 of questsystem5 back to trunk

I hope there weren't more "hidden merge changes" in r2909 than the one in OverlayGroup (removeElement) (and related to this the adjustments in NotificationQueue).

The corresponding media commit seems not yet to be done, but it doesn't break the build.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/overlays/notifications/Notification.cc

    r2910 r2911  
    2727 */
    2828
     29/**
     30    @file Notification.cc
     31    @brief Implementation of the Notification class.
     32*/
     33
    2934#include "OrxonoxStableHeaders.h"
    3035#include "Notification.h"
    3136
    3237#include "core/CoreIncludes.h"
     38#include "util/Exception.h"
    3339
    3440#include "NotificationManager.h"
     
    3642namespace orxonox
    3743{
     44
     45    /**
     46    @brief
     47        Default constructor. Initializes the object.
     48    */
    3849    Notification::Notification(BaseObject* creator) : BaseObject(creator)
    3950    {
    40         RegisterObject(Notification);
     51        this->initialize();
    4152    }
    4253   
    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)
    4461    {
    45         this->title_ = title;
    4662        this->message_ = message;
    47         if(time > 0)
    48             this->displayTime_ = time;
    4963    }
    5064   
     65    /**
     66    @brief
     67        Destructor.
     68    */
    5169    Notification::~Notification()
    5270    {
    5371    }
    5472   
     73    /**
     74    @brief
     75        Registers the object and sets some default values.
     76    */
    5577    void Notification::initialize(void)
    5678    {
    5779        RegisterObject(Notification);
    5880       
    59         this->title_ = "";
    6081        this->message_ = "";
    61         this->displayTime_ = NOTIFICATION_DISPLAY_TIME;
     82        this->sender_ = NotificationManager::NONE;
    6283        this->sent_ = false;
    6384    }
    6485   
     86    /**
     87    @brief
     88        Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
     89    @return
     90        Returns true if successful.
     91    */
    6592    bool Notification::send(void)
    6693    {
    67         bool successful = NotificationManager::insertNotification(this);
    68         if(successful)
    69             this->sent_ = true;
    70         return successful;
     94        return this->send(NotificationManager::NONE);
    7195    }
    7296   
    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)
    74106    {
    75         if(this->isSent())
     107        this->sender_ = sender;
     108        bool successful = NotificationManager::getInstance().registerNotification(this);
     109        if(!successful)
    76110            return false;
    77         this->title_ = title;
     111        this->sent_ = true;
     112       
     113        COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
     114       
    78115        return true;
    79116    }
    80117   
     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    */
    81126    bool Notification::setMessage(const std::string & message)
    82127    {
    83         if(this->isSent())
     128        if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
    84129            return false;
    85130        this->message_ = message;
    86131        return true;
    87132    }
    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
    102134}
Note: See TracChangeset for help on using the changeset viewer.