Crazy Eddie's GUI System  0.8.7
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 4521 4522)
41 #endif
42 
43 // Start of CEGUI namespace section
44 namespace CEGUI
45 {
166 class CEGUIEXPORT EventSet
167 {
168 public:
173  EventSet();
174 
179  virtual ~EventSet(void);
180 
193  void addEvent(const String& name);
194 
210  void addEvent(Event& event);
211 
221  void removeEvent(const String& name);
222 
232  void removeEvent(Event& event);
233 
239  void removeAllEvents(void);
240 
250  bool isEventPresent(const String& name);
251 
267  virtual Event::Connection subscribeEvent(const String& name,
268  Event::Subscriber subscriber);
269 
289  virtual Event::Connection subscribeEvent(const String& name,
290  Event::Group group,
291  Event::Subscriber subscriber);
292 
298  template<typename Arg1, typename Arg2>
299  inline Event::Connection subscribeEvent(const String& name, Arg1 arg1, Arg2 arg2)
300  {
301  return subscribeEvent(name, Event::Subscriber(arg1, arg2));
302  }
303 
309  template<typename Arg1, typename Arg2>
310  inline Event::Connection subscribeEvent(const String& name, Event::Group group, Arg1 arg1, Arg2 arg2)
311  {
312  return subscribeEvent(name, group, Event::Subscriber(arg1, arg2));
313  }
314 
330  virtual Event::Connection subscribeScriptedEvent(const String& name,
331  const String& subscriber_name);
332 
352  virtual Event::Connection subscribeScriptedEvent(const String& name,
353  Event::Group group,
354  const String& subscriber_name);
355 
374  virtual void fireEvent(const String& name, EventArgs& args,
375  const String& eventNamespace = "");
376 
377 
388  bool isMuted(void) const;
389 
400  void setMutedState(bool setting);
401 
421  Event* getEventObject(const String& name, bool autoAdd = false);
422 
423 protected:
425  void fireEvent_impl(const String& name, EventArgs& args);
427  ScriptModule* getScriptModule() const;
428 
429  // Do not allow copying, assignment, or any other usage than simple creation.
430  EventSet(EventSet&) {}
431  EventSet(const EventSet&) {}
432  EventSet& operator=(EventSet&) { return *this; }
433  EventSet& operator=(const EventSet&) { return *this; }
434 
435  typedef std::map<String, Event*, StringFastLessCompare
436  CEGUI_MAP_ALLOC(String, Event*)> EventMap;
437  EventMap d_events;
438 
439  bool d_muted;
440 
441 public:
442  /*************************************************************************
443  Iterator stuff
444  *************************************************************************/
446 
452  EventIterator getEventIterator(void) const;
453 };
454 
455 } // End of CEGUI namespace section
456 
457 
458 #if defined(_MSC_VER)
459 # pragma warning(pop)
460 #endif
461 
462 #endif // end of guard _CEGUIEventSet_h_
Abstract interface required for all scripting support modules to be used with the CEGUI system...
Definition: ScriptModule.h:45
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5579
EventSet(const EventSet &)
Definition: EventSet.h:431
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Base class used as the argument to all subscribers Event object.
Definition: EventArgs.h:49
SubscriberSlot class which is used when subscribing to events.
Definition: SubscriberSlot.h:51
bool d_muted
true if events for this EventSet have been muted.
Definition: EventSet.h:439
EventSet & operator=(const EventSet &)
Definition: EventSet.h:433
Interface providing event signaling and handling.
Definition: EventSet.h:166
iterator class for maps
Definition: IteratorBase.h:196
Event::Connection subscribeEvent(const String &name, Event::Group group, Arg1 arg1, Arg2 arg2)
Subscribes a handler to the named Event. If the named Event is not yet present in the EventSet...
Definition: EventSet.h:310
Defines an 'event' which can be subscribed to by interested parties.
Definition: Event.h:57
unsigned int Group
Type for a subscriber group. You can use the subscriber group to order calls to multiple subscribers...
Definition: Event.h:84
Event::Connection subscribeEvent(const String &name, Arg1 arg1, Arg2 arg2)
Subscribes a handler to the named Event. If the named Event is not yet present in the EventSet...
Definition: EventSet.h:299
String class used within the GUI system.
Definition: String.h:62