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 };
00074
00079 class CEGUIEXPORT AliasTargetStack
00080 {
00081 public:
00086 AliasTargetStack(void) {}
00087
00088
00093 ~AliasTargetStack(void) {}
00094
00095
00103 const String& getActiveTarget(void) const;
00104
00112 uint getStackedTargetCount(void) const;
00113
00114
00115 private:
00116 friend class WindowFactoryManager;
00117 typedef std::vector<String> TargetTypeStack;
00118
00119 TargetTypeStack d_targetStack;
00120 };
00121
00122
00123
00124
00125
00130 WindowFactoryManager(void);
00131
00132
00137 ~WindowFactoryManager(void)
00138 {
00139 Logger::getSingleton().logEvent("CEGUI::WindowFactoryManager singleton destroyed");
00140 }
00141
00142
00143
00144
00145
00159 void addFactory(WindowFactory* factory);
00160
00174 template <typename T>
00175 static void addFactory();
00176
00177
00192 void removeFactory(const String& name);
00193
00194
00209 void removeFactory(WindowFactory* factory);
00210
00211
00219 void removeAllFactories(void);
00220
00221
00234 WindowFactory* getFactory(const String& type) const;
00235
00236
00251 bool isFactoryPresent(const String& name) const;
00252
00253
00279 void addWindowTypeAlias(const String& aliasName, const String& targetType);
00280
00281
00299 void removeWindowTypeAlias(const String& aliasName, const String& targetType);
00300
00329 void addFalagardWindowMapping(const String& newType, const String& targetType, const String& lookName, const String& renderer);
00330
00338 void removeFalagardWindowMapping(const String& type);
00339
00351 bool isFalagardMappedType(const String& type) const;
00352
00365 const String& getMappedLookForType(const String& type) const;
00366
00379 const String& getMappedRendererForType(const String& type) const;
00380
00399 String getDereferencedAliasType(const String& type) const;
00400
00413 const FalagardWindowMapping& getFalagardMappingForType(const String& type) const;
00414
00415 private:
00416
00417
00418
00419 typedef std::map<String, WindowFactory*, String::FastLessCompare> WindowFactoryRegistry;
00420 typedef std::map<String, AliasTargetStack, String::FastLessCompare> TypeAliasRegistry;
00421 typedef std::map<String, FalagardWindowMapping, String::FastLessCompare> FalagardMapRegistry;
00422
00423 typedef std::vector<WindowFactory*> OwnedWindowFactoryList;
00424
00425 WindowFactoryRegistry d_factoryRegistry;
00426 TypeAliasRegistry d_aliasRegistry;
00427 FalagardMapRegistry d_falagardRegistry;
00428
00429 static OwnedWindowFactoryList d_ownedFactories;
00430
00431 public:
00432
00433
00434
00435 typedef ConstBaseIterator<WindowFactoryRegistry> WindowFactoryIterator;
00436 typedef ConstBaseIterator<TypeAliasRegistry> TypeAliasIterator;
00437 typedef ConstBaseIterator<FalagardMapRegistry> FalagardMappingIterator;
00438
00443 WindowFactoryIterator getIterator(void) const;
00444
00445
00450 TypeAliasIterator getAliasIterator(void) const;
00451
00452
00457 FalagardMappingIterator getFalagardMappingIterator() const;
00458 };
00459
00460
00461 template <typename T>
00462 void WindowFactoryManager::addFactory()
00463 {
00464
00465 WindowFactory* factory = new T;
00466
00467
00468 if (WindowFactoryManager::getSingletonPtr())
00469 {
00470 Logger::getSingleton().logEvent("Created WindowFactory for '" +
00471 factory->getTypeName() +
00472 "' windows.");
00473
00474 try
00475 {
00476 WindowFactoryManager::getSingleton().addFactory(factory);
00477 }
00478 catch (Exception& e)
00479 {
00480 Logger::getSingleton().logEvent("Deleted WindowFactory for '" +
00481 factory->getTypeName() +
00482 "' windows.");
00483
00484 delete factory;
00485 throw;
00486 }
00487 }
00488
00489 d_ownedFactories.push_back(factory);
00490 }
00491
00492 }
00493
00494
00495 #if defined(_MSC_VER)
00496 # pragma warning(pop)
00497 #endif
00498
00499 #endif // end of guard _CEGUIWindowFactoryManager_h_