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