1 | /************************************************************************
|
---|
2 | filename: CEGUIGlobalEventSet.h
|
---|
3 | created: 16/1/2005
|
---|
4 | author: Paul D Turner
|
---|
5 | *************************************************************************/
|
---|
6 | /*************************************************************************
|
---|
7 | Crazy Eddie's GUI System (http:www.cegui.org.uk)
|
---|
8 | Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2.1 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public
|
---|
21 | License along with this library; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | *************************************************************************/
|
---|
24 | #ifndef _CEGUIGlobalEventSet_h_
|
---|
25 | #define _CEGUIGlobalEventSet_h_
|
---|
26 |
|
---|
27 | #include "CEGUIEventSet.h"
|
---|
28 | #include "CEGUISingleton.h"
|
---|
29 |
|
---|
30 |
|
---|
31 | #if defined(_MSC_VER)
|
---|
32 | # pragma warning(push)
|
---|
33 | # pragma warning(disable : 4275)
|
---|
34 | #endif
|
---|
35 |
|
---|
36 | // Start of CEGUI namespace section
|
---|
37 | namespace CEGUI
|
---|
38 | {
|
---|
39 | /*!
|
---|
40 | \brief
|
---|
41 | The GlobalEventSet singleton allows you to subscribe to an event for all
|
---|
42 | instances of a class. The GlobalEventSet effectively supports "late binding"
|
---|
43 | to events; which means you can subscribe to some event that does not actually
|
---|
44 | exist (yet).
|
---|
45 | */
|
---|
46 | class CEGUIEXPORT GlobalEventSet : public EventSet, public Singleton<GlobalEventSet>
|
---|
47 | {
|
---|
48 | public:
|
---|
49 | GlobalEventSet();
|
---|
50 | ~GlobalEventSet();
|
---|
51 |
|
---|
52 |
|
---|
53 | /*!
|
---|
54 | \brief
|
---|
55 | Return singleton System object
|
---|
56 |
|
---|
57 | \return
|
---|
58 | Singleton System object
|
---|
59 | */
|
---|
60 | static GlobalEventSet& getSingleton(void);
|
---|
61 |
|
---|
62 |
|
---|
63 | /*!
|
---|
64 | \brief
|
---|
65 | Return pointer to singleton System object
|
---|
66 |
|
---|
67 | \return
|
---|
68 | Pointer to singleton System object
|
---|
69 | */
|
---|
70 | static GlobalEventSet* getSingletonPtr(void);
|
---|
71 |
|
---|
72 |
|
---|
73 | /*!
|
---|
74 | \brief
|
---|
75 | Subscribes the the named Event.
|
---|
76 |
|
---|
77 | \note
|
---|
78 | If the named event does not exist it is added.
|
---|
79 |
|
---|
80 | \param name
|
---|
81 | String object containing the name of the Event to subscribe to.
|
---|
82 |
|
---|
83 | \param subscriber
|
---|
84 | Function or object that is to be subscribed to the Event.
|
---|
85 |
|
---|
86 | \return
|
---|
87 | Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
|
---|
88 | */
|
---|
89 | virtual Event::Connection subscribeEvent(const String& name, Event::Subscriber subscriber);
|
---|
90 |
|
---|
91 |
|
---|
92 | /*!
|
---|
93 | \brief
|
---|
94 | Subscribes the the specified group of the named Event.
|
---|
95 |
|
---|
96 | /note
|
---|
97 | If the named event does not exist it is added.
|
---|
98 |
|
---|
99 | \param name
|
---|
100 | String object containing the name of the Event to subscribe to.
|
---|
101 |
|
---|
102 | \param group
|
---|
103 | Group which is to be subscribed to. Subscription groups are called in ascending order.
|
---|
104 |
|
---|
105 | \param subscriber
|
---|
106 | Function or object that is to be subscribed to the Event.
|
---|
107 |
|
---|
108 | \return
|
---|
109 | Connection object that can be used to check the status of the Event connection and to disconnect (unsubscribe) from the Event.
|
---|
110 | */
|
---|
111 | virtual Event::Connection subscribeEvent(const String& name, Event::Group group, Event::Subscriber subscriber);
|
---|
112 |
|
---|
113 |
|
---|
114 | /*!
|
---|
115 | \brief
|
---|
116 | Fires the named event passing the given EventArgs object.
|
---|
117 |
|
---|
118 | \param name
|
---|
119 | String object holding the name of the Event that is to be fired (triggered)
|
---|
120 |
|
---|
121 | \param args
|
---|
122 | The EventArgs (or derived) object that is to be bassed to each subscriber of the Event. Once all subscribers
|
---|
123 | have been called the 'handled' field of the event is updated appropriately.
|
---|
124 |
|
---|
125 | \param eventNamespace
|
---|
126 | String object describing the namespace prefix to use when firing the global event.
|
---|
127 |
|
---|
128 | \return
|
---|
129 | Nothing.
|
---|
130 | */
|
---|
131 | virtual void fireEvent(const String& name, EventArgs& args, const String& eventNamespace = "");
|
---|
132 | };
|
---|
133 |
|
---|
134 | } // End of CEGUI namespace section
|
---|
135 |
|
---|
136 |
|
---|
137 | #if defined(_MSC_VER)
|
---|
138 | # pragma warning(pop)
|
---|
139 | #endif
|
---|
140 |
|
---|
141 | #endif // end of guard _CEGUIGlobalEventSet_h_
|
---|