Crazy Eddies GUI System
0.6.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
include
CEGUIWindowRendererModule.h
1
/***********************************************************************
2
filename: CEGUIWindowRendererModule.h
3
created: Fri Jan 13 2006
4
author: Paul D Turner <paul@cegui.org.uk>
5
Tomas Lindquist Olsen <tomas@famolsen.dk>
6
*************************************************************************/
7
/***************************************************************************
8
* Copyright (C) 2004 - 2006 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 _CEGUIWindowRendererModule_h_
30
#define _CEGUIWindowRendererModule_h_
31
32
#include "CEGUIExceptions.h"
33
#include "CEGUIWindowRendererManager.h"
34
#include "CEGUILogger.h"
35
36
#if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
37
# ifdef CEGUIWRMODULE_EXPORTS
38
# define CEGUIWRMODULE_API __declspec(dllexport)
39
# else
40
# define CEGUIWRMODULE_API __declspec(dllimport)
41
# endif
42
#else
43
# define CEGUIWRMODULE_API
44
#endif
45
46
// declare module
47
#define CEGUI_DECLARE_WR_MODULE( moduleName )\
48
\
49
class CEGUI::WindowRendererFactory;\
50
\
51
extern "C" CEGUIWRMODULE_API void registerFactoryFunction(const CEGUI::String& type_name);\
52
extern "C" CEGUIWRMODULE_API CEGUI::uint registerAllFactoriesFunction(void);\
53
void doSafeFactoryRegistration(CEGUI::WindowRendererFactory* factory);
54
55
// define factory
56
#define CEGUI_DEFINE_WR_FACTORY( className )\
57
namespace CEGUI {\
58
class className ## WRFactory : public WindowRendererFactory\
59
{\
60
public:\
61
className ## WRFactory(void) : WindowRendererFactory(className::TypeName) { }\
62
WindowRenderer* create(void)\
63
{ return new className(className::TypeName); }\
64
void destroy(WindowRenderer* wr)\
65
{ delete wr; }\
66
};\
67
}\
68
static CEGUI::className ## WRFactory s_ ## className ## WRFactory;
69
70
// start factory map
71
#define CEGUI_START_WR_FACTORY_MAP( module )\
72
struct module ## WRMapEntry\
73
{\
74
const CEGUI::utf8* d_name;\
75
CEGUI::WindowRendererFactory* d_factory;\
76
};\
77
\
78
module ## WRMapEntry module ## WRFactoriesMap[] =\
79
{\
80
81
// end factory map
82
#define CEGUI_END_WR_FACTORY_MAP {0,0}};
83
84
// map entry
85
#define CEGUI_WR_FACTORY_MAP_ENTRY( class )\
86
{CEGUI::class::TypeName, &s_ ## class ## WRFactory},
87
88
// define module
89
#define CEGUI_DEFINE_WR_MODULE( module )\
90
void registerFactoryFunction(const CEGUI::String& type_name)\
91
{\
92
module ## WRMapEntry* entry = module ## WRFactoriesMap;\
93
while (entry->d_name)\
94
{\
95
if (entry->d_name == type_name)\
96
{\
97
doSafeFactoryRegistration(entry->d_factory);\
98
return;\
99
}\
100
++entry;\
101
}\
102
\
103
throw CEGUI::UnknownObjectException("::registerFactory - The window renderer factory for type '" + type_name + "' is not known in this module.");\
104
}\
105
\
106
extern "C" CEGUI::uint registerAllFactoriesFunction(void)\
107
{\
108
CEGUI::uint count = 0;\
109
module ## WRMapEntry* entry = module ## WRFactoriesMap;\
110
while (entry->d_name)\
111
{\
112
doSafeFactoryRegistration(entry->d_factory);\
113
++entry;\
114
++count;\
115
}\
116
return count;\
117
}\
118
\
119
void doSafeFactoryRegistration(CEGUI::WindowRendererFactory* factory)\
120
{\
121
assert(factory != 0);\
122
\
123
CEGUI::WindowRendererManager& wfm = CEGUI::WindowRendererManager::getSingleton();\
124
if (wfm.isFactoryPresent(factory->getName()))\
125
{\
126
CEGUI::Logger::getSingleton().logEvent(\
127
"WindowRenderer factory '" + factory->getName() + "' appears to be already registered, skipping.",\
128
CEGUI::Informative);\
129
}\
130
else\
131
{\
132
wfm.addFactory(factory);\
133
}\
134
}
135
136
#endif // end of guard _CEGUIWindowRendererModule_h_
Generated by
1.8.3.1