Crazy Eddie's GUI System 0.8.7
Loading...
Searching...
No Matches
WindowFactoryManager.h
1/***********************************************************************
2 created: 22/2/2004
3 author: Paul D Turner
4
5 purpose: Defines interface for WindowFactoryManager class
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 _CEGUIWindowFactoryManager_h_
30#define _CEGUIWindowFactoryManager_h_
31
32#include "CEGUI/Base.h"
33#include "CEGUI/String.h"
34#include "CEGUI/Singleton.h"
35#include "CEGUI/Logger.h"
36#include "CEGUI/IteratorBase.h"
37#include "CEGUI/WindowFactory.h"
38#include "CEGUI/TplWindowFactory.h"
39#include "CEGUI/Exceptions.h"
40#include <map>
41#include <vector>
42
43#if defined(_MSC_VER)
44# pragma warning(push)
45# pragma warning(disable : 4275)
46# pragma warning(disable : 4251)
47#endif
48
49
50// Start of CEGUI namespace section
51namespace CEGUI
52{
61class CEGUIEXPORT WindowFactoryManager :
62 public Singleton<WindowFactoryManager>,
63 public AllocatedObject<WindowFactoryManager>
64{
65public:
70 struct CEGUIEXPORT FalagardWindowMapping
71 {
72 String d_windowType;
73 String d_lookName;
74 String d_baseType;
75 String d_rendererType;
76 String d_effectName;
77 };
78
83 class CEGUIEXPORT AliasTargetStack
84 {
85 public:
91
92
98
99
107 const String& getActiveTarget(void) const;
108
117
118
119 private:
120 friend class WindowFactoryManager;
121
122 typedef std::vector<String
123 CEGUI_VECTOR_ALLOC(String)> TargetTypeStack;
124
125 TargetTypeStack d_targetStack;
126 };
127
128
129 /*************************************************************************
130 Construction and Destruction
131 *************************************************************************/
137
138
144 {
145 Logger::getSingleton().logEvent("CEGUI::WindowFactoryManager singleton destroyed");
146 }
147
148
149 /*************************************************************************
150 Public Interface
151 *************************************************************************/
166
180 template <typename T>
181 static void addFactory();
182
197 template <typename T>
198 static void addWindowType();
199
214 void removeFactory(const String& name);
215
216
232
233
242
243
256 WindowFactory* getFactory(const String& type) const;
257
258
273 bool isFactoryPresent(const String& name) const;
274
275
301 void addWindowTypeAlias(const String& aliasName, const String& targetType);
302
303
321 void removeWindowTypeAlias(const String& aliasName, const String& targetType);
322
328
361 const String& targetType,
362 const String& lookName,
363 const String& renderer,
364 const String& effectName = String(""));
365
374
380
392 bool isFalagardMappedType(const String& type) const;
393
406 const String& getMappedLookForType(const String& type) const;
407
420 const String& getMappedRendererForType(const String& type) const;
421
441
455
456private:
457 /*************************************************************************
458 Implementation Data
459 *************************************************************************/
460 typedef std::map<String, WindowFactory*, StringFastLessCompare
461 CEGUI_MAP_ALLOC(String, WindowFactory*)> WindowFactoryRegistry;
463 CEGUI_MAP_ALLOC(String, AliasTargetStack)> TypeAliasRegistry;
465 CEGUI_MAP_ALLOC(String, FalagardWindowMapping)> FalagardMapRegistry;
467 typedef std::vector<WindowFactory*
468 CEGUI_VECTOR_ALLOC(WindowFactory*)> OwnedWindowFactoryList;
469
470 WindowFactoryRegistry d_factoryRegistry;
471 TypeAliasRegistry d_aliasRegistry;
472 FalagardMapRegistry d_falagardRegistry;
474 static OwnedWindowFactoryList d_ownedFactories;
475
476public:
477 /*************************************************************************
478 Iterator stuff
479 *************************************************************************/
483
489
490
496
497
503};
504
505//----------------------------------------------------------------------------//
506template <typename T>
508{
509 // create the factory object
510 WindowFactory* factory = CEGUI_NEW_AO T;
511
512 // only do the actual add now if our singleton has already been created
513 if (WindowFactoryManager::getSingletonPtr())
514 {
515 Logger::getSingleton().logEvent("Created WindowFactory for '" +
516 factory->getTypeName() +
517 "' windows.");
518 // add the factory we just created
519 CEGUI_TRY
520 {
521 WindowFactoryManager::getSingleton().addFactory(factory);
522 }
523 CEGUI_CATCH (Exception&)
524 {
525 Logger::getSingleton().logEvent("Deleted WindowFactory for '" +
526 factory->getTypeName() +
527 "' windows.");
528 // delete the factory object
529 CEGUI_DELETE_AO factory;
530 CEGUI_RETHROW;
531 }
532 }
533
534 d_ownedFactories.push_back(factory);
535}
536
537//----------------------------------------------------------------------------//
538template <typename T>
540{
541 WindowFactoryManager::addFactory<TplWindowFactory<T> >();
542}
543
544//----------------------------------------------------------------------------//
545
546} // End of CEGUI namespace section
547
548
549#if defined(_MSC_VER)
550# pragma warning(pop)
551#endif
552
553#endif // end of guard _CEGUIWindowFactoryManager_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 properties able to do native set/get
Definition TypedProperty.h:50
Class used to track active alias targets for Window factory types.
Definition WindowFactoryManager.h:84
AliasTargetStack(void)
Constructor for WindowAliasTargetStack objects.
Definition WindowFactoryManager.h:90
~AliasTargetStack(void)
Destructor for WindowAliasTargetStack objects.
Definition WindowFactoryManager.h:97
uint getStackedTargetCount(void) const
Return the number of stacked target types in the stack.
const String & getActiveTarget(void) const
Return a String holding the current target type for this stack.
Class that manages WindowFactory objects.
Definition WindowFactoryManager.h:64
void addFactory(WindowFactory *factory)
Adds a new WindowFactory to the list of registered factories.
void removeWindowTypeAlias(const String &aliasName, const String &targetType)
Remove the specified alias mapping. If the alias mapping does not exist, nothing happens.
void addWindowTypeAlias(const String &aliasName, const String &targetType)
Adds an alias for a current window type.
WindowFactoryManager(void)
Constructs a new WindowFactoryManager object.
~WindowFactoryManager(void)
Destructor for WindowFactoryManager objects.
Definition WindowFactoryManager.h:143
static void addWindowType()
Internally creates a factory suitable for creating Window objects of the given type and adds it to th...
Definition WindowFactoryManager.h:539
TypeAliasIterator getAliasIterator(void) const
Return a WindowFactoryManager::TypeAliasIterator object to iterate over the defined aliases for windo...
WindowFactoryIterator getIterator(void) const
Return a WindowFactoryManager::WindowFactoryIterator object to iterate over the available WindowFacto...
const FalagardWindowMapping & getFalagardMappingForType(const String &type) const
Return the FalagardWindowMapping for the specified window mapping type.
void removeFactory(const String &name)
Removes a WindowFactory from the list of registered factories.
bool isFalagardMappedType(const String &type) const
Return whether the given type is a falagard mapped type.
void addFalagardWindowMapping(const String &newType, const String &targetType, const String &lookName, const String &renderer, const String &effectName=String(""))
Add a mapping for a falagard based window.
void removeFalagardWindowMapping(const String &type)
Remove the specified falagard type mapping if it exists.
const String & getMappedRendererForType(const String &type) const
Return the name of the WindowRenderer assigned to the specified window mapping.
void removeAllFactories(void)
Remove all WindowFactory objects from the list.
bool isFactoryPresent(const String &name) const
Checks the list of registered WindowFactory objects, aliases, and falagard mapped types for one which...
FalagardMappingIterator getFalagardMappingIterator() const
Return a WindowFactoryManager::FalagardMappingIterator object to iterate over the defined falagard wi...
const String & getMappedLookForType(const String &type) const
Return the name of the LookN'Feel assigned to the specified window mapping.
WindowFactory * getFactory(const String &type) const
Return a pointer to the specified WindowFactory object.
void removeAllFalagardWindowMappings()
Remove all registered falagard type mappings.
String getDereferencedAliasType(const String &type) const
Use the alias system, where required, to 'de-reference' the specified type to an actual window type t...
void removeFactory(WindowFactory *factory)
Removes a WindowFactory from the list of registered factories.
static void addFactory()
Creates a WindowFactory of the type T and adds it to the system for use. The created WindowFactory wi...
Definition WindowFactoryManager.h:507
void removeAllWindowTypeAliases()
Remove all registered window type alias mappings.
Abstract class that defines the required interface for all WindowFactory objects.
Definition WindowFactory.h:117
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
struct used to hold mapping information required to create a falagard based window.
Definition WindowFactoryManager.h:71