Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
WindowRendererManager.h
1/***********************************************************************
2 created: Jan 11 2006
3 author: Tomas Lindquist Olsen
4
5 purpose: Defines interface for the WindowRendererManager class
6*************************************************************************/
7/***************************************************************************
8 * Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining
11 * a copy of this software and associated documentation files (the
12 * "Software"), to deal in the Software without restriction, including
13 * without limitation the rights to use, copy, modify, merge, publish,
14 * distribute, sublicense, and/or sell copies of the Software, and to
15 * permit persons to whom the Software is furnished to do so, subject to
16 * the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be
19 * included in all copies or substantial portions of the Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 ***************************************************************************/
29#ifndef _CEGUIWindowRendererManager_h_
30#define _CEGUIWindowRendererManager_h_
31
32#include "CEGUI/Singleton.h"
33#include "CEGUI/WindowRenderer.h"
34#include "CEGUI/Logger.h"
35#include "CEGUI/Exceptions.h"
36#include "CEGUI/TplWindowRendererFactory.h"
37#include <map>
38#include <vector>
39
40#if defined(_MSC_VER)
41# pragma warning(push)
42# pragma warning(disable : 4251)
43#endif
44
45// Start of CEGUI namespace section
46namespace CEGUI
47{
48class CEGUIEXPORT WindowRendererManager :
49 public Singleton<WindowRendererManager>,
50 public AllocatedObject<WindowRendererManager>
51{
52public:
53 /*************************************************************************
54 Contructor / Destructor
55 *************************************************************************/
58
59 /*************************************************************************
60 Singleton
61 *************************************************************************/
62 static WindowRendererManager& getSingleton();
63 static WindowRendererManager* getSingletonPtr();
64
65 /*************************************************************************
66 Accessors
67 *************************************************************************/
68 bool isFactoryPresent(const String& name) const;
69 WindowRendererFactory* getFactory(const String& name) const;
70
71 /*************************************************************************
72 Manipulators
73 *************************************************************************/
87 template <typename T>
88 static void addFactory();
89
104 template <typename T>
105 static void addWindowRendererType();
106
107 void addFactory(WindowRendererFactory* wr);
108 void removeFactory(const String& name);
109
110 /*************************************************************************
111 Factory usage
112 *************************************************************************/
113 WindowRenderer* createWindowRenderer(const String& name);
114 void destroyWindowRenderer(WindowRenderer* wr);
115
116private:
117 /*************************************************************************
118 Private implementation
119 *************************************************************************/
120
121 /*************************************************************************
122 Implementation data
123 *************************************************************************/
125 CEGUI_MAP_ALLOC(String, WindowRendererFactory*)> WR_Registry;
126 WR_Registry d_wrReg;
127
129 typedef std::vector<WindowRendererFactory*
130 CEGUI_VECTOR_ALLOC(WindowRendererFactory*)> OwnedFactoryList;
132 static OwnedFactoryList d_ownedFactories;
133};
134
135//----------------------------------------------------------------------------//
136template <typename T>
138{
139 // create the factory object
140 WindowRendererFactory* factory = CEGUI_NEW_AO T;
141
142 // only do the actual add now if our singleton has already been created
143 if (WindowRendererManager::getSingletonPtr())
144 {
145 Logger::getSingleton().logEvent("Created WindowRendererFactory for '" +
146 factory->getName() +
147 "' WindowRenderers.");
148 // add the factory we just created
149 CEGUI_TRY
150 {
151 WindowRendererManager::getSingleton().addFactory(factory);
152 }
153 CEGUI_CATCH (Exception&)
154 {
155 Logger::getSingleton().logEvent("Deleted WindowRendererFactory for "
156 "'" + factory->getName() +
157 "' WindowRenderers.");
158 // delete the factory object
159 CEGUI_DELETE_AO factory;
160 CEGUI_RETHROW;
161 }
162 }
163
164 d_ownedFactories.push_back(factory);
165}
166
167//----------------------------------------------------------------------------//
168template <typename T>
173
174//----------------------------------------------------------------------------//
175
176
177} // End of CEGUI namespace
178
179#if defined(_MSC_VER)
180# pragma warning(pop)
181#endif
182
183#endif // _CEGUIWindowRendererManager_h_
Definition MemoryAllocatedObject.h:110
Root exception class used within the GUI system.
Definition Exceptions.h:49
Definition Singleton.h:56
String class used within the GUI system.
Definition String.h:64
Base-class for WindowRendererFactory.
Definition WindowRenderer.h:238
const String & getName() const
Returns the type name of this window renderer factory.
Definition WindowRenderer.h:259
Definition WindowRendererManager.h:51
static void addFactory()
Creates a WindowRendererFactory of the type T and adds it to the system for use.
Definition WindowRendererManager.h:137
static void addWindowRendererType()
Internally creates a factory suitable for creating WindowRenderer objects of the given type and adds ...
Definition WindowRendererManager.h:169
Base-class for the assignable WindowRenderer object.
Definition WindowRenderer.h:52
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