Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

Doing some documentation.

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