Crazy Eddie's GUI System 0.8.7
RenderEffectManager.h
1/***********************************************************************
2 created: Wed Dec 23 2009
3 author: Paul D Turner <paul@cegui.org.uk>
4*************************************************************************/
5/***************************************************************************
6 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
22 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
26 ***************************************************************************/
27#ifndef _CEGUIRenderEffectManager_h_
28#define _CEGUIRenderEffectManager_h_
29
30#include "CEGUI/Singleton.h"
31#include "CEGUI/IteratorBase.h"
32#include "CEGUI/Logger.h"
33#include "CEGUI/Exceptions.h"
34#include "CEGUI/RenderEffectFactory.h"
35#include <map>
36
37#if defined(_MSC_VER)
38# pragma warning(push)
39# pragma warning(disable : 4251)
40#endif
41
42// Start of CEGUI namespace section
43namespace CEGUI
44{
50class CEGUIEXPORT RenderEffectManager :
51 public Singleton<RenderEffectManager>,
52 public AllocatedObject<RenderEffectManager>
53{
54private:
57 CEGUI_MAP_ALLOC(String, RenderEffectFactory*)> RenderEffectRegistry;
58
60 typedef std::map<RenderEffect*, RenderEffectFactory*, std::less<RenderEffect*>
61 CEGUI_MAP_ALLOC(RenderEffect*, RenderEffectFactory*)> EffectCreatorMap;
62
64 RenderEffectRegistry d_effectRegistry;
66 EffectCreatorMap d_effects;
67
68public:
71
74
77
98 template <typename T>
99 void addEffect(const String& name);
100
117 void removeEffect(const String& name);
118
131 bool isEffectAvailable(const String& name) const;
132
153 RenderEffect& create(const String& name, Window* window);
154
172 void destroy(RenderEffect& effect);
173};
174
175//---------------------------------------------------------------------------//
176template <typename T>
178{
179 if (isEffectAvailable(name))
180 CEGUI_THROW(AlreadyExistsException(
181 "A RenderEffect is already registered under the name '" +
182 name + "'"));
183
184 // create an instance of a factory to create effects of type T
185 d_effectRegistry[name] = CEGUI_NEW_AO TplRenderEffectFactory<T>;
186
187 Logger::getSingleton().logEvent(
188 "Registered RenderEffect named '" + name + "'");
189}
190
191//---------------------------------------------------------------------------//
192
193
194} // End of CEGUI namespace section
195
196#if defined(_MSC_VER)
197# pragma warning(pop)
198#endif
199
200#endif // end of guard _CEGUIRenderEffectManager_h_
201
Definition: MemoryAllocatedObject.h:110
Exception class used when an attempt is made create a named object of a particular type when an objec...
Definition: Exceptions.h:484
iterator class for maps
Definition: IteratorBase.h:197
Interface for factory objects that create RenderEffect instances. Currently this interface is intende...
Definition: RenderEffectFactory.h:42
Singleton class that manages creation and destruction of RenderEffect based objects.
Definition: RenderEffectManager.h:53
void destroy(RenderEffect &effect)
Destroy the given RenderEffect object.
ConstMapIterator< RenderEffectRegistry > RenderEffectIterator
Iterator type that iterates over entries in the RenderEffectRegistry.
Definition: RenderEffectManager.h:70
~RenderEffectManager()
Destructor for RenderEffectManager objects.
void removeEffect(const String &name)
Remove / unregister any RenderEffect using the specified identifier.
RenderEffect & create(const String &name, Window *window)
Create an instance of the RenderEffect based class identified by the specified name.
void addEffect(const String &name)
Register a RenderEffect type with the system and associate it with the identifier name.
Definition: RenderEffectManager.h:177
bool isEffectAvailable(const String &name) const
Return whether a RenderEffect has been registered under the specified name.
RenderEffectManager()
Constructor for RenderEffectManager objects.
Interface for objects that hook into RenderingWindow to affect the rendering process,...
Definition: RenderEffect.h:42
Definition: Singleton.h:56
String class used within the GUI system.
Definition: String.h:64
Templatised RenderEffectFactory subclass used internally by the system.
Definition: RenderEffectFactory.h:57
An abstract base class providing common functionality and specifying the required interface for deriv...
Definition: Window.h:151
Main namespace for Crazy Eddie's GUI Library.
Definition: arch_overview.dox:1
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: String.h:5580