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 | /** |
---|
30 | @file NotificationDispatcher.h |
---|
31 | @brief Definition of the NotificationDispatcher class. |
---|
32 | @ingroup Notifications |
---|
33 | */ |
---|
34 | |
---|
35 | #ifndef _NotificationDispatcher_H__ |
---|
36 | #define _NotificationDispatcher_H__ |
---|
37 | |
---|
38 | #include "notifications/NotificationsPrereqs.h" |
---|
39 | |
---|
40 | #include <string> |
---|
41 | #include "core/BaseObject.h" |
---|
42 | #include "network/synchronisable/Synchronisable.h" |
---|
43 | |
---|
44 | namespace orxonox |
---|
45 | { |
---|
46 | |
---|
47 | /** |
---|
48 | @brief |
---|
49 | A NotificationDispatcher is an entity that, upon being triggered, dispatches (or sends) a specified Notification. |
---|
50 | @author |
---|
51 | Damian 'Mozork' Frick |
---|
52 | */ |
---|
53 | class _NotificationsExport NotificationDispatcher : public BaseObject, public Synchronisable |
---|
54 | { |
---|
55 | public: |
---|
56 | NotificationDispatcher(BaseObject* creator); //!< Default constructor. Initializes the object. |
---|
57 | virtual ~NotificationDispatcher(); //!< Destructor. |
---|
58 | |
---|
59 | virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); //!< Method for creating a NotificationDispatcher object through XML. |
---|
60 | virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode); |
---|
61 | |
---|
62 | /** |
---|
63 | @brief Get the sender of the Notification dispatched by this NotificationDispatcher. |
---|
64 | @return Returns the name of the sender. |
---|
65 | */ |
---|
66 | const std::string& getSender(void) |
---|
67 | { return this->sender_; } |
---|
68 | |
---|
69 | void dispatch(unsigned int clientId); //!< Dispatches a specific Notification. |
---|
70 | bool trigger(bool triggered, BaseObject* trigger); //!< Is called when the NotificationDispatcher is triggered. |
---|
71 | |
---|
72 | protected: |
---|
73 | std::string sender_; //!< The name of the sender of the Notification dispatched by this NotificationDispatcher. |
---|
74 | |
---|
75 | void registerVariables(void); |
---|
76 | |
---|
77 | /** |
---|
78 | @brief Set the sender of the Notification dispatched by this NotificationDispatcher. |
---|
79 | @param sender The name of the sender. |
---|
80 | */ |
---|
81 | void setSender(const std::string& sender) |
---|
82 | { this->sender_ = sender; } |
---|
83 | |
---|
84 | /** |
---|
85 | @brief Creates the notification message that should be sent upon the NotificationDispatcher triggering. |
---|
86 | This method can be overloaded to customize the NotificationDispatcher. |
---|
87 | @return Returns the notification message. |
---|
88 | */ |
---|
89 | virtual const std::string& createNotificationMessage(void) |
---|
90 | { return *(new std::string("")); } |
---|
91 | |
---|
92 | }; |
---|
93 | |
---|
94 | } |
---|
95 | |
---|
96 | #endif /* _NotificationDispatcher_H__ */ |
---|