Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/modules/notifications/NotificationDispatcher.h @ 11663

Last change on this file since 11663 was 11099, checked in by muemart, 9 years ago

Fix loads of doxygen warnings and other documentation issues

  • Property svn:eol-style set to native
File size: 5.8 KB
RevLine 
[7193]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 the
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/**
[7456]30    @file NotificationDispatcher.h
[7193]31    @brief Definition of the NotificationDispatcher class.
[7456]32    @ingroup Notifications
[7193]33*/
34
35#ifndef _NotificationDispatcher_H__
36#define _NotificationDispatcher_H__
37
38#include "notifications/NotificationsPrereqs.h"
39
40#include <string>
[7552]41
[7193]42#include "core/BaseObject.h"
[7474]43#include "network/synchronisable/Synchronisable.h"
[7193]44
45namespace orxonox
46{
47
48    /**
49    @brief
[7484]50        A NotificationDispatcher is an entity that, upon being triggered, dispatches (or sends) a specified @ref orxonox::Notification "Notification".
51
[8891]52        There are two parameter to be set:
53        - The @b sender . The sender specifies the part of Orxonox the sent @ref orxonox::Notification "Notification" comes from. The default value is set by the classes implementing NotificationDispatcher.
54        - The @b broadcast . Specifies whether messages are broadcast (i.e. sent to all clients) or just sent to a specific player.
[7488]55
[7484]56        Its standard usage is:
57        @code
[7488]58        <NotificationDispatcher sender="me">
[7484]59            <events>
60                <trigger>
61                    <PlayerTrigger />
62                </trigger>
63            </event>
64        </NotificationDispatcher>
65        @endcode
[8891]66        But keep in mind, that NotificationDispatcher is an abstract class.
67        Also in this example @ref orxonox::PlayerTrigger "PlayerTrigger" stands for any event that is caused by a @ref orxonox::PlayerTrigger "PlayerTrigger", so instead of @ref orxonox::PlayerTrigger "PlayerTrigger", there could be a @ref orxonox::DistanceTrigger "DistanceTrigger", or a @ref orxonox::DistanceMultiTrigger "DistanceMutliTrigger", or even an @ref orxonox::EventListener "EventListener" that waits for an event coming from any kind of @ref orxonox::PlayerTrigger "PlayerTrigger".
68        If the NotificationDispatcher is not set to broadcast only events caused by @ref orxonox::PlayerTrigger "PlayerTriggers" trigger a message since the information obtained by the @ref orxonox::PlayerTrigger "PlayerTrigger" is used to identify the client to which the message should be sent.
[7552]69
[7193]70    @author
71        Damian 'Mozork' Frick
[7552]72
73    @ingroup Notifications
[7193]74    */
[7474]75    class _NotificationsExport NotificationDispatcher : public BaseObject, public Synchronisable
[7193]76    {
77        public:
[9667]78            NotificationDispatcher(Context* context); //!< Default constructor. Initializes the object.
[7193]79            virtual ~NotificationDispatcher(); //!< Destructor.
80
[11071]81            virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode) override; //!< Method for creating a NotificationDispatcher object through XML.
82            virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
[7193]83
84            /**
85            @brief Get the sender of the Notification dispatched by this NotificationDispatcher.
86            @return Returns the name of the sender.
87            */
[7488]88            const std::string& getSender(void) const
[7193]89                { return this->sender_; }
[8891]90            /**
[7488]91            @brief Set the sender of the Notification dispatched by this NotificationDispatcher.
92            @param sender The name of the sender.
93            */
94            void setSender(const std::string& sender)
95                { this->sender_ = sender; }
[7193]96
[8891]97            /**
98            @brief Check whether the NotificationDispatcher is set to broadcast.
99            @return Returns true if the NotificationDispatcher is set to broadcast.
100            */
101            bool isBroadcasting(void) const
102                { return this->bBroadcast_; }
103            /**
104            @brief Set the NotificationDispatcher to broadcast.
[11099]105            @param v Whether the NotificationDispatcher is set to broadcast or singlecast.
[8891]106            */
107            void setBroadcasting(bool v)
108                { this->bBroadcast_ = v; }
109
110            void broadcast(void); //!< Broadcasts a specific Notification.
111            void broadcastHelper(void); //!< Helper function for broadcast.
112            void dispatch(unsigned int clientId); //!< Dispatches a specific Notification to a given client.
[7403]113            bool trigger(bool triggered, BaseObject* trigger); //!< Is called when the NotificationDispatcher is triggered.
[7193]114
115        protected:
116            std::string sender_; //!< The name of the sender of the Notification dispatched by this NotificationDispatcher.
[8891]117            bool bBroadcast_; //!< Whether the NotificationDispatcher is broadcasting.
[7193]118
[7484]119            void registerVariables(void); //!< Register some variables for synchronisation.
[7474]120
[7193]121            /**
122            @brief Creates the notification message that should be sent upon the NotificationDispatcher triggering.
123                   This method can be overloaded to customize the NotificationDispatcher.
124            @return Returns the notification message.
125            */
126            virtual const std::string& createNotificationMessage(void)
[8891]127                { return BLANKSTRING; }
[7193]128
129    };
130
131}
132
133#endif /* _NotificationDispatcher_H__ */
Note: See TracBrowser for help on using the repository browser.