Crazy Eddie's GUI System
0.8.4
|
00001 /*********************************************************************** 00002 created: Wed Dec 23 2009 00003 author: Paul D Turner <paul@cegui.org.uk> 00004 *************************************************************************/ 00005 /*************************************************************************** 00006 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team 00007 * 00008 * Permission is hereby granted, free of charge, to any person obtaining 00009 * a copy of this software and associated documentation files (the 00010 * "Software"), to deal in the Software without restriction, including 00011 * without limitation the rights to use, copy, modify, merge, publish, 00012 * distribute, sublicense, and/or sell copies of the Software, and to 00013 * permit persons to whom the Software is furnished to do so, subject to 00014 * the following conditions: 00015 * 00016 * The above copyright notice and this permission notice shall be 00017 * included in all copies or substantial portions of the Software. 00018 * 00019 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 00020 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 00021 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 00022 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 00023 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 00024 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 00025 * OTHER DEALINGS IN THE SOFTWARE. 00026 ***************************************************************************/ 00027 #ifndef _CEGUIRenderEffectManager_h_ 00028 #define _CEGUIRenderEffectManager_h_ 00029 00030 #include "CEGUI/Singleton.h" 00031 #include "CEGUI/IteratorBase.h" 00032 #include "CEGUI/Logger.h" 00033 #include "CEGUI/Exceptions.h" 00034 #include "CEGUI/RenderEffectFactory.h" 00035 #include <map> 00036 00037 #if defined(_MSC_VER) 00038 # pragma warning(push) 00039 # pragma warning(disable : 4251) 00040 #endif 00041 00042 // Start of CEGUI namespace section 00043 namespace CEGUI 00044 { 00050 class CEGUIEXPORT RenderEffectManager : 00051 public Singleton<RenderEffectManager>, 00052 public AllocatedObject<RenderEffectManager> 00053 { 00054 private: 00056 typedef std::map<String, RenderEffectFactory*, StringFastLessCompare 00057 CEGUI_MAP_ALLOC(String, RenderEffectFactory*)> RenderEffectRegistry; 00058 00060 typedef std::map<RenderEffect*, RenderEffectFactory*, std::less<RenderEffect*> 00061 CEGUI_MAP_ALLOC(RenderEffect*, RenderEffectFactory*)> EffectCreatorMap; 00062 00064 RenderEffectRegistry d_effectRegistry; 00066 EffectCreatorMap d_effects; 00067 00068 public: 00070 typedef ConstMapIterator<RenderEffectRegistry> RenderEffectIterator; 00071 00073 RenderEffectManager(); 00074 00076 ~RenderEffectManager(); 00077 00098 template <typename T> 00099 void addEffect(const String& name); 00100 00117 void removeEffect(const String& name); 00118 00131 bool isEffectAvailable(const String& name) const; 00132 00153 RenderEffect& create(const String& name, Window* window); 00154 00172 void destroy(RenderEffect& effect); 00173 }; 00174 00175 //---------------------------------------------------------------------------// 00176 template <typename T> 00177 void RenderEffectManager::addEffect(const String& name) 00178 { 00179 if (isEffectAvailable(name)) 00180 CEGUI_THROW(AlreadyExistsException( 00181 "A RenderEffect is already registered under the name '" + 00182 name + "'")); 00183 00184 // create an instance of a factory to create effects of type T 00185 d_effectRegistry[name] = CEGUI_NEW_AO TplRenderEffectFactory<T>; 00186 00187 Logger::getSingleton().logEvent( 00188 "Registered RenderEffect named '" + name + "'"); 00189 } 00190 00191 //---------------------------------------------------------------------------// 00192 00193 00194 } // End of CEGUI namespace section 00195 00196 #if defined(_MSC_VER) 00197 # pragma warning(pop) 00198 #endif 00199 00200 #endif // end of guard _CEGUIRenderEffectManager_h_ 00201