Crazy Eddie's GUI System  0.8.4
EventSet.h
00001 /***********************************************************************
00002     created:    21/2/2004
00003     author:     Paul D Turner
00004 
00005     purpose:    Defines class for a named collection of Event objects
00006 *************************************************************************/
00007 /***************************************************************************
00008  *   Copyright (C) 2004 - 2010 Paul D Turner & The CEGUI Development Team
00009  *
00010  *   Permission is hereby granted, free of charge, to any person obtaining
00011  *   a copy of this software and associated documentation files (the
00012  *   "Software"), to deal in the Software without restriction, including
00013  *   without limitation the rights to use, copy, modify, merge, publish,
00014  *   distribute, sublicense, and/or sell copies of the Software, and to
00015  *   permit persons to whom the Software is furnished to do so, subject to
00016  *   the following conditions:
00017  *
00018  *   The above copyright notice and this permission notice shall be
00019  *   included in all copies or substantial portions of the Software.
00020  *
00021  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00022  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00023  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00024  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00025  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00026  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00027  *   OTHER DEALINGS IN THE SOFTWARE.
00028  ***************************************************************************/
00029 #ifndef _CEGUIEventSet_h_
00030 #define _CEGUIEventSet_h_
00031 
00032 #include "CEGUI/Base.h"
00033 #include "CEGUI/String.h"
00034 #include "CEGUI/Event.h"
00035 #include "CEGUI/IteratorBase.h"
00036 #include <map>
00037 
00038 #if defined (_MSC_VER)
00039 #   pragma warning(push)
00040 #   pragma warning(disable : 4251)
00041 #endif
00042 
00043 // Start of CEGUI namespace section
00044 namespace CEGUI
00045 {
00064 class CEGUIEXPORT EventSet
00065 {
00066 public:
00071     EventSet();
00072 
00077     virtual ~EventSet(void);
00078 
00091     void addEvent(const String& name);
00092 
00108     void addEvent(Event& event);
00109 
00119     void removeEvent(const String& name);
00120 
00130     void removeEvent(Event& event);
00131 
00137     void removeAllEvents(void);
00138 
00148     bool isEventPresent(const String& name);
00149 
00165     virtual Event::Connection subscribeEvent(const String& name,
00166                                              Event::Subscriber subscriber);
00167 
00187     virtual Event::Connection subscribeEvent(const String& name,
00188                                              Event::Group group,
00189                                              Event::Subscriber subscriber);
00190 
00196     template<typename Arg1, typename Arg2>
00197     inline Event::Connection subscribeEvent(const String& name, Arg1 arg1, Arg2 arg2)
00198     {
00199         return subscribeEvent(name, Event::Subscriber(arg1, arg2));
00200     }
00201     
00207     template<typename Arg1, typename Arg2>
00208     inline Event::Connection subscribeEvent(const String& name, Event::Group group, Arg1 arg1, Arg2 arg2)
00209     {
00210         return subscribeEvent(name, group, Event::Subscriber(arg1, arg2));
00211     }
00212     
00228     virtual Event::Connection subscribeScriptedEvent(const String& name,
00229                                                      const String& subscriber_name);
00230 
00250     virtual Event::Connection subscribeScriptedEvent(const String& name,
00251                                                      Event::Group group,
00252                                                      const String& subscriber_name);
00253 
00272     virtual void fireEvent(const String& name, EventArgs& args,
00273                            const String& eventNamespace = "");
00274 
00275 
00286     bool isMuted(void) const;
00287 
00298     void    setMutedState(bool setting);
00299 
00319     Event* getEventObject(const String& name, bool autoAdd = false);
00320 
00321 protected:
00323     void fireEvent_impl(const String& name, EventArgs& args);
00325     ScriptModule* getScriptModule() const;
00326 
00327     // Do not allow copying, assignment, or any other usage than simple creation.
00328     EventSet(EventSet&) {}
00329     EventSet& operator=(EventSet&)
00330     {
00331         return *this;
00332     }
00333 
00334     typedef std::map<String, Event*, StringFastLessCompare
00335         CEGUI_MAP_ALLOC(String, Event*)> EventMap;
00336     EventMap    d_events;
00337 
00338     bool    d_muted;    
00339 
00340 public:
00341     /*************************************************************************
00342         Iterator stuff
00343     *************************************************************************/
00344     typedef ConstMapIterator<EventMap> EventIterator;
00345 
00351     EventIterator getEventIterator(void) const;
00352 };
00353 
00354 } // End of  CEGUI namespace section
00355 
00356 
00357 #if defined(_MSC_VER)
00358 #   pragma warning(pop)
00359 #endif
00360 
00361 #endif  // end of guard _CEGUIEventSet_h_
00362 
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends