Crazy Eddie's GUI System  0.8.3
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
EventSet.h
1 /***********************************************************************
2  filename: CEGUIEventSet.h
3  created: 21/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines class for a named collection of Event objects
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIEventSet_h_
31 #define _CEGUIEventSet_h_
32 
33 #include "CEGUI/Base.h"
34 #include "CEGUI/String.h"
35 #include "CEGUI/Event.h"
36 #include "CEGUI/IteratorBase.h"
37 #include <map>
38 
39 #if defined (_MSC_VER)
40 # pragma warning(push)
41 # pragma warning(disable : 4251)
42 #endif
43 
44 // Start of CEGUI namespace section
45 namespace CEGUI
46 {
65 class CEGUIEXPORT EventSet
66 {
67 public:
72  EventSet();
73 
78  virtual ~EventSet(void);
79 
92  void addEvent(const String& name);
93 
109  void addEvent(Event& event);
110 
120  void removeEvent(const String& name);
121 
131  void removeEvent(Event& event);
132 
138  void removeAllEvents(void);
139 
149  bool isEventPresent(const String& name);
150 
166  virtual Event::Connection subscribeEvent(const String& name,
167  Event::Subscriber subscriber);
168 
188  virtual Event::Connection subscribeEvent(const String& name,
189  Event::Group group,
190  Event::Subscriber subscriber);
191 
197  template<typename Arg1, typename Arg2>
198  inline Event::Connection subscribeEvent(const String& name, Arg1 arg1, Arg2 arg2)
199  {
200  return subscribeEvent(name, Event::Subscriber(arg1, arg2));
201  }
202 
208  template<typename Arg1, typename Arg2>
209  inline Event::Connection subscribeEvent(const String& name, Event::Group group, Arg1 arg1, Arg2 arg2)
210  {
211  return subscribeEvent(name, group, Event::Subscriber(arg1, arg2));
212  }
213 
229  virtual Event::Connection subscribeScriptedEvent(const String& name,
230  const String& subscriber_name);
231 
251  virtual Event::Connection subscribeScriptedEvent(const String& name,
252  Event::Group group,
253  const String& subscriber_name);
254 
273  virtual void fireEvent(const String& name, EventArgs& args,
274  const String& eventNamespace = "");
275 
276 
287  bool isMuted(void) const;
288 
299  void setMutedState(bool setting);
300 
320  Event* getEventObject(const String& name, bool autoAdd = false);
321 
322 protected:
324  void fireEvent_impl(const String& name, EventArgs& args);
326  ScriptModule* getScriptModule() const;
327 
328  // Do not allow copying, assignment, or any other usage than simple creation.
329  EventSet(EventSet&) {}
330  EventSet& operator=(EventSet&)
331  {
332  return *this;
333  }
334 
335  typedef std::map<String, Event*, StringFastLessCompare
336  CEGUI_MAP_ALLOC(String, Event*)> EventMap;
337  EventMap d_events;
338 
339  bool d_muted;
340 
341 public:
342  /*************************************************************************
343  Iterator stuff
344  *************************************************************************/
346 
352  EventIterator getEventIterator(void) const;
353 };
354 
355 } // End of CEGUI namespace section
356 
357 
358 #if defined(_MSC_VER)
359 # pragma warning(pop)
360 #endif
361 
362 #endif // end of guard _CEGUIEventSet_h_
363