Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

CEGUIGlobalEventSet.cpp

Go to the documentation of this file.
00001 /************************************************************************
00002         filename:       CEGUIGlobalEventSet.cpp
00003         created:        16/1/2005
00004         author:         Paul D Turner
00005 *************************************************************************/
00006 /*************************************************************************
00007     Crazy Eddie's GUI System (http://www.cegui.org.uk)
00008     Copyright (C)2004 - 2005 Paul D Turner (paul@cegui.org.uk)
00009 
00010     This library is free software; you can redistribute it and/or
00011     modify it under the terms of the GNU Lesser General Public
00012     License as published by the Free Software Foundation; either
00013     version 2.1 of the License, or (at your option) any later version.
00014 
00015     This library is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018     Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public
00021     License along with this library; if not, write to the Free Software
00022     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023 *************************************************************************/
00024 #include "CEGUIGlobalEventSet.h"
00025 #include "CEGUILogger.h"
00026 
00027 
00028 // Start of CEGUI namespace section
00029 namespace CEGUI
00030 {
00031         /*************************************************************************
00032                 Static Data Definitions
00033         *************************************************************************/
00034         // singleton instance pointer
00035         template<> GlobalEventSet* Singleton<GlobalEventSet>::ms_Singleton      = NULL;
00036 
00037         /*************************************************************************
00038                 GlobalEventSet constructor.
00039         *************************************************************************/
00040         GlobalEventSet::GlobalEventSet()
00041         {
00042                 Logger::getSingleton().logEvent("CEGUI::GlobalEventSet singleton created.");
00043         }
00044 
00045         /*************************************************************************
00046                 GlobalEventSet destructor.
00047         *************************************************************************/
00048         GlobalEventSet::~GlobalEventSet()
00049         {
00050                 Logger::getSingleton().logEvent("CEGUI::GlobalEventSet singleton destroyed.");
00051         }
00052 
00053         /*************************************************************************
00054                 Return singleton object
00055         *************************************************************************/
00056         GlobalEventSet& GlobalEventSet::getSingleton(void)
00057         {
00058                 return Singleton<GlobalEventSet>::getSingleton();
00059         }
00060 
00061         /*************************************************************************
00062                 Return singleton pointer
00063         *************************************************************************/
00064         GlobalEventSet* GlobalEventSet::getSingletonPtr(void)
00065         {
00066                 return Singleton<GlobalEventSet>::getSingletonPtr();
00067         }
00068 
00069         /*************************************************************************
00070                 Overridden subscribeEvent which always succeeds.
00071         *************************************************************************/
00072         Event::Connection GlobalEventSet::subscribeEvent(const String& name, Event::Subscriber subscriber)
00073         {
00074                 EventMap::iterator pos = d_events.find(name);
00075 
00076                 // if event did not exist, add it and then find it.
00077                 if (pos == d_events.end())
00078                 {
00079                         Logger::getSingleton().logEvent("Adding event '" + name + "' to GlobalEventSet.", Informative);
00080                         addEvent(name);
00081                         pos = d_events.find(name);
00082                 }
00083 
00084                 // do the actual subscription
00085                 return pos->second->subscribe(subscriber);
00086         }
00087 
00088         /*************************************************************************
00089                 Overridden subscribeEvent (with group) which always succeeds.
00090         *************************************************************************/
00091         Event::Connection GlobalEventSet::subscribeEvent(const String& name, Event::Group group, Event::Subscriber subscriber)
00092         {
00093                 EventMap::iterator pos = d_events.find(name);
00094 
00095                 // if event did not exist, add it and then find it.
00096                 if (pos == d_events.end())
00097                 {
00098                         addEvent(name);
00099                         pos = d_events.find(name);
00100                 }
00101 
00102                 // do subscription with group
00103                 return pos->second->subscribe(group, subscriber);
00104         }
00105 
00106         /*************************************************************************
00107                 Overridden fireEvent which always succeeds.
00108         *************************************************************************/
00109         void GlobalEventSet::fireEvent(const String& name, EventArgs& args, const String& eventNamespace)
00110         {
00111                 EventMap::iterator pos = d_events.find(eventNamespace + "/" + name);
00112 
00113                 // do nothing if the event does not exist
00114                 if (pos != d_events.end())
00115                 {
00116                         // fire the event
00117                         if (!d_muted)
00118                         {
00119                                 (*pos->second)(args);
00120                         }
00121 
00122                 }
00123 
00124         }
00125 
00126 } // End of  CEGUI namespace section

Generated on Wed Feb 16 12:41:06 2005 for Crazy Eddies GUI System by  doxygen 1.3.9.1