Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/notifications/Notification.cc @ 7474

Last change on this file since 7474 was 7474, checked in by dafrick, 14 years ago

Synchronizing Notifications.
In the course of that, notifications are not longer sent by creating a Notification and the calling notification.send() bur by letting the NotificationManager handle all this: NotificationManager::getInstance().sendNotification(message)
This made QuestNotification obsolete, thus it was removde.

Also did some work on synchronizing the Script class. It should work properly most of the time, but the current solution is unreliable and unsatisfactory. So this will change as soon as I know how.

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
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
29/**
30    @file Notification.cc
31    @brief Implementation of the Notification class.
32*/
33
34#include "Notification.h"
35
36#include "core/CoreIncludes.h"
37#include "network/NetworkFunction.h"
38#include "network/Host.h"
39#include "NotificationManager.h"
40
41namespace orxonox
42{
43
44    /**
45    @brief
46        Default constructor. Initializes the object.
47    */
48    Notification::Notification()
49    {
50        RegisterRootObject(Notification);
51        this->initialize();
52        this->registerVariables();
53    }
54
55    /**
56    @brief
57        Constructor. Creates a Notification with the input message.
58    @param creator
59        The creator.
60    @param message
61        The message of the Notification.
62    */
63    Notification::Notification(const std::string & message)
64    {
65        RegisterRootObject(Notification);
66        this->initialize();
67        this->message_ = message;
68    }
69
70    /**
71    @brief
72        Destructor.
73    */
74    Notification::~Notification()
75    {
76
77    }
78
79    /**
80    @brief
81        Registers the object and sets some default values.
82    */
83    void Notification::initialize(void)
84    {
85        this->message_.clear();
86        this->sender_ = NotificationManager::NONE;
87        this->sent_ = false;
88    }
89
90    /**
91    @brief
92        Sends the Notification to the Notificationmanager, which then in turn distributes it to the different NotificationQueues.
93    @param sender
94        The sender the Notification was sent by. Used by the NotificationManager to distributes the notification to the correct NotificationQueues.
95    @return
96        Returns true if successful.
97    */
98    bool Notification::send(const std::string & sender)
99    {
100        if(this->isSent()) //TODO: Needed?
101            return false;
102
103        this->sender_ = sender;
104        bool successful = NotificationManager::getInstance().registerNotification(this);
105        if(!successful)
106            return false;
107        this->sent_ = true;
108
109        COUT(3) << "Notification \"" << this->getMessage() << "\" sent." << std::endl;
110
111        return true;
112    }
113
114    /**
115    @brief
116        Sets the message of the notification.
117    @param message
118        The message to be set.
119    @return
120        Returns true if successful.
121    */
122    bool Notification::setMessage(const std::string & message)
123    {
124        if(this->isSent()) //!< The message cannot be changed if the message has already been sent.
125            return false;
126        this->message_ = message;
127        return true;
128    }
129
130}
Note: See TracBrowser for help on using the repository browser.