Crazy Eddie's GUI System  0.8.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
RenderEffectManager.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 "CEGUI/Singleton.h"
32 #include "CEGUI/IteratorBase.h"
33 #include "CEGUI/Logger.h"
34 #include "CEGUI/Exceptions.h"
35 #include "CEGUI/RenderEffectFactory.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 :
52  public Singleton<RenderEffectManager>,
53  public AllocatedObject<RenderEffectManager>
54 {
55 private:
58  CEGUI_MAP_ALLOC(String, RenderEffectFactory*)> RenderEffectRegistry;
59 
61  typedef std::map<RenderEffect*, RenderEffectFactory*, std::less<RenderEffect*>
62  CEGUI_MAP_ALLOC(RenderEffect*, RenderEffectFactory*)> EffectCreatorMap;
63 
65  RenderEffectRegistry d_effectRegistry;
67  EffectCreatorMap d_effects;
68 
69 public:
72 
75 
78 
99  template <typename T>
100  void addEffect(const String& name);
101 
118  void removeEffect(const String& name);
119 
132  bool isEffectAvailable(const String& name) const;
133 
154  RenderEffect& create(const String& name, Window* window);
155 
173  void destroy(RenderEffect& effect);
174 };
175 
176 //---------------------------------------------------------------------------//
177 template <typename T>
179 {
180  if (isEffectAvailable(name))
181  CEGUI_THROW(AlreadyExistsException(
182  "A RenderEffect is already registered under the name '" +
183  name + "'"));
184 
185  // create an instance of a factory to create effects of type T
186  d_effectRegistry[name] = CEGUI_NEW_AO TplRenderEffectFactory<T>;
187 
188  Logger::getSingleton().logEvent(
189  "Registered RenderEffect named '" + name + "'");
190 }
191 
192 //---------------------------------------------------------------------------//
193 
194 
195 } // End of CEGUI namespace section
196 
197 #if defined(_MSC_VER)
198 # pragma warning(pop)
199 #endif
200 
201 #endif // end of guard _CEGUIRenderEffectManager_h_
202