Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/overlays/notifications/Notification.cc @ 3086

Last change on this file since 3086 was 2994, checked in by dafrick, 16 years ago

Small correction in Notifications

  • Property svn:eol-style set to native
File size: 3.5 KB
RevLine 
[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 thes
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/**
30    @file Notification.cc
31    @brief Implementation of the Notification class.
32*/
33
[2280]34#include "OrxonoxStableHeaders.h"
35#include "Notification.h"
36
37#include "core/CoreIncludes.h"
[2911]38#include "util/Exception.h"
[2280]39
40#include "NotificationManager.h"
41
[2435]42namespace orxonox
43{
[2911]44
45    /**
46    @brief
47        Default constructor. Initializes the object.
48    */
[2280]49    Notification::Notification(BaseObject* creator) : BaseObject(creator)
50    {
[2911]51        this->initialize();
[2280]52    }
53   
[2911]54    /**
55    @brief
56        Constructor. Creates a Notification with the input message.
57    @param message
58        The message of the Notification.
59    */
[2994]60    Notification::Notification(const std::string & message) : BaseObject(NULL)
[2280]61    {
62        this->message_ = message;
63    }
64   
[2911]65    /**
66    @brief
67        Destructor.
68    */
[2280]69    Notification::~Notification()
70    {
71    }
72   
[2911]73    /**
74    @brief
75        Registers the object and sets some default values.
76    */
[2280]77    void Notification::initialize(void)
78    {
79        RegisterObject(Notification);
80       
81        this->message_ = "";
[2911]82        this->sender_ = NotificationManager::NONE;
[2280]83        this->sent_ = false;
84    }
85   
[2911]86    /**
87    @brief
88        Sends the Notification to the Notificationmanager, with sender NetificationManager::NONE.
89    @return
90        Returns true if successful.
91    */
[2280]92    bool Notification::send(void)
93    {
[2911]94        return this->send(NotificationManager::NONE);
[2280]95    }
96   
[2911]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)
[2280]106    {
[2911]107        this->sender_ = sender;
108        bool successful = NotificationManager::getInstance().registerNotification(this);
109        if(!successful)
[2280]110            return false;
[2911]111        this->sent_ = true;
112       
113        COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
114       
[2435]115        return true;
[2280]116    }
117   
[2911]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    */
[2280]126    bool Notification::setMessage(const std::string & message)
127    {
[2911]128        if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
[2280]129            return false;
[2435]130        this->message_ = message;
131        return true;
[2280]132    }
[2911]133
[2280]134}
Note: See TracBrowser for help on using the repository browser.