00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CEGUIWindowFactoryManager_h_
00031 #define _CEGUIWindowFactoryManager_h_
00032
00033 #include "CEGUIBase.h"
00034 #include "CEGUIString.h"
00035 #include "CEGUISingleton.h"
00036 #include "CEGUILogger.h"
00037 #include "CEGUIIteratorBase.h"
00038 #include "CEGUIWindowFactory.h"
00039 #include <map>
00040 #include <vector>
00041
00042 #if defined(_MSC_VER)
00043 # pragma warning(push)
00044 # pragma warning(disable : 4275)
00045 # pragma warning(disable : 4251)
00046 #endif
00047
00048
00049
00050 namespace CEGUI
00051 {
00060 class CEGUIEXPORT WindowFactoryManager : public Singleton<WindowFactoryManager>
00061 {
00062 public:
00067 struct CEGUIEXPORT FalagardWindowMapping
00068 {
00069 String d_windowType;
00070 String d_lookName;
00071 String d_baseType;
00072 String d_rendererType;
00073 String d_effectName;
00074 };
00075
00080 class CEGUIEXPORT AliasTargetStack
00081 {
00082 public:
00087 AliasTargetStack(void) {}
00088
00089
00094 ~AliasTargetStack(void) {}
00095
00096
00104 const String& getActiveTarget(void) const;
00105
00113 uint getStackedTargetCount(void) const;
00114
00115
00116 private:
00117 friend class WindowFactoryManager;
00118 typedef std::vector<String> TargetTypeStack;
00119
00120 TargetTypeStack d_targetStack;
00121 };
00122
00123
00124
00125
00126
00131 WindowFactoryManager(void);
00132
00133
00138 ~WindowFactoryManager(void)
00139 {
00140 Logger::getSingleton().logEvent("CEGUI::WindowFactoryManager singleton destroyed");
00141 }
00142
00143
00144
00145
00146
00160 void addFactory(WindowFactory* factory);
00161
00175 template <typename T>
00176 static void addFactory();
00177
00178
00193 void removeFactory(const String& name);
00194
00195
00210 void removeFactory(WindowFactory* factory);
00211
00212
00220 void removeAllFactories(void);
00221
00222
00235 WindowFactory* getFactory(const String& type) const;
00236
00237
00252 bool isFactoryPresent(const String& name) const;
00253
00254
00280 void addWindowTypeAlias(const String& aliasName, const String& targetType);
00281
00282
00300 void removeWindowTypeAlias(const String& aliasName, const String& targetType);
00301
00333 void addFalagardWindowMapping(const String& newType,
00334 const String& targetType,
00335 const String& lookName,
00336 const String& renderer,
00337 const String& effectName = String(""));
00338
00346 void removeFalagardWindowMapping(const String& type);
00347
00359 bool isFalagardMappedType(const String& type) const;
00360
00373 const String& getMappedLookForType(const String& type) const;
00374
00387 const String& getMappedRendererForType(const String& type) const;
00388
00407 String getDereferencedAliasType(const String& type) const;
00408
00421 const FalagardWindowMapping& getFalagardMappingForType(const String& type) const;
00422
00423 private:
00424
00425
00426
00427 typedef std::map<String, WindowFactory*, String::FastLessCompare> WindowFactoryRegistry;
00428 typedef std::map<String, AliasTargetStack, String::FastLessCompare> TypeAliasRegistry;
00429 typedef std::map<String, FalagardWindowMapping, String::FastLessCompare> FalagardMapRegistry;
00430
00431 typedef std::vector<WindowFactory*> OwnedWindowFactoryList;
00432
00433 WindowFactoryRegistry d_factoryRegistry;
00434 TypeAliasRegistry d_aliasRegistry;
00435 FalagardMapRegistry d_falagardRegistry;
00436
00437 static OwnedWindowFactoryList d_ownedFactories;
00438
00439 public:
00440
00441
00442
00443 typedef ConstBaseIterator<WindowFactoryRegistry> WindowFactoryIterator;
00444 typedef ConstBaseIterator<TypeAliasRegistry> TypeAliasIterator;
00445 typedef ConstBaseIterator<FalagardMapRegistry> FalagardMappingIterator;
00446
00451 WindowFactoryIterator getIterator(void) const;
00452
00453
00458 TypeAliasIterator getAliasIterator(void) const;
00459
00460
00465 FalagardMappingIterator getFalagardMappingIterator() const;
00466 };
00467
00468
00469 template <typename T>
00470 void WindowFactoryManager::addFactory()
00471 {
00472
00473 WindowFactory* factory = new T;
00474
00475
00476 if (WindowFactoryManager::getSingletonPtr())
00477 {
00478 Logger::getSingleton().logEvent("Created WindowFactory for '" +
00479 factory->getTypeName() +
00480 "' windows.");
00481
00482 CEGUI_TRY
00483 {
00484 WindowFactoryManager::getSingleton().addFactory(factory);
00485 }
00486 CEGUI_CATCH (Exception&)
00487 {
00488 Logger::getSingleton().logEvent("Deleted WindowFactory for '" +
00489 factory->getTypeName() +
00490 "' windows.");
00491
00492 delete factory;
00493 CEGUI_RETHROW;
00494 }
00495 }
00496
00497 d_ownedFactories.push_back(factory);
00498 }
00499
00500 }
00501
00502
00503 #if defined(_MSC_VER)
00504 # pragma warning(pop)
00505 #endif
00506
00507 #endif // end of guard _CEGUIWindowFactoryManager_h_