Crazy Eddies GUI System  0.7.8
CEGUIRenderEffectManager.h
1 /***********************************************************************
2  filename: CEGUIRenderEffectManager.h
3  created: Wed Dec 23 2009
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIRenderEffectManager_h_
29 #define _CEGUIRenderEffectManager_h_
30 
31 #include "CEGUISingleton.h"
32 #include "CEGUIIteratorBase.h"
33 #include "CEGUILogger.h"
34 #include "CEGUIExceptions.h"
35 #include "CEGUIRenderEffectFactory.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 {
51 class CEGUIEXPORT RenderEffectManager : public Singleton<RenderEffectManager>
52 {
53 private:
55  typedef std::map<String,
57  String::FastLessCompare> RenderEffectRegistry;
58 
60  typedef std::map<RenderEffect*, RenderEffectFactory*> EffectCreatorMap;
61 
63  RenderEffectRegistry d_effectRegistry;
65  EffectCreatorMap d_effects;
66 
67 public:
70 
73 
76 
97  template <typename T>
98  void addEffect(const String& name);
99 
116  void removeEffect(const String& name);
117 
130  bool isEffectAvailable(const String& name) const;
131 
148  RenderEffect& create(const String& name);
149 
167  void destroy(RenderEffect& effect);
168 };
169 
170 //---------------------------------------------------------------------------//
171 template <typename T>
173 {
174  if (isEffectAvailable(name))
175  CEGUI_THROW(AlreadyExistsException("RenderEffectManager::addEffect: "
176  "A RenderEffect is already registered under the name '" +
177  name + "'"));
178 
179  // create an instance of a factory to create effects of type T
180  d_effectRegistry[name] = new TplRenderEffectFactory<T>;
181 
182  Logger::getSingleton().logEvent(
183  "Registered RenderEffect named '" + name + "'");
184 }
185 
186 //---------------------------------------------------------------------------//
187 
188 
189 } // End of CEGUI namespace section
190 
191 #if defined(_MSC_VER)
192 # pragma warning(pop)
193 #endif
194 
195 #endif // end of guard _CEGUIRenderEffectManager_h_
196