Crazy Eddies GUI System  0.6.0
CEGUIWindowFactoryManager.h
1 /***********************************************************************
2  filename: CEGUIWindowFactoryManager.h
3  created: 22/2/2004
4  author: Paul D Turner
5 
6  purpose: Defines interface for WindowFactoryManager class
7 *************************************************************************/
8 /***************************************************************************
9  * Copyright (C) 2004 - 2006 Paul D Turner & The CEGUI Development Team
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining
12  * a copy of this software and associated documentation files (the
13  * "Software"), to deal in the Software without restriction, including
14  * without limitation the rights to use, copy, modify, merge, publish,
15  * distribute, sublicense, and/or sell copies of the Software, and to
16  * permit persons to whom the Software is furnished to do so, subject to
17  * the following conditions:
18  *
19  * The above copyright notice and this permission notice shall be
20  * included in all copies or substantial portions of the Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
25  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  ***************************************************************************/
30 #ifndef _CEGUIWindowFactoryManager_h_
31 #define _CEGUIWindowFactoryManager_h_
32 
33 #include "CEGUIBase.h"
34 #include "CEGUIString.h"
35 #include "CEGUISingleton.h"
36 #include "CEGUILogger.h"
37 #include "CEGUIIteratorBase.h"
38 #include <map>
39 #include <vector>
40 
41 #if defined(_MSC_VER)
42 # pragma warning(push)
43 # pragma warning(disable : 4275)
44 # pragma warning(disable : 4251)
45 #endif
46 
47 
48 // Start of CEGUI namespace section
49 namespace CEGUI
50 {
59 class CEGUIEXPORT WindowFactoryManager : public Singleton<WindowFactoryManager>
60 {
61 public:
66  struct CEGUIEXPORT FalagardWindowMapping
67  {
68  String d_windowType;
69  String d_lookName;
70  String d_baseType;
71  String d_rendererType;
72  };
73 
78  class CEGUIEXPORT AliasTargetStack
79  {
80  public:
86 
87 
93 
94 
102  const String& getActiveTarget(void) const;
103 
111  uint getStackedTargetCount(void) const;
112 
113 
114  private:
115  friend class WindowFactoryManager;
116  typedef std::vector<String> TargetTypeStack;
117 
118  TargetTypeStack d_targetStack;
119  };
120 
121 
122  /*************************************************************************
123  Construction and Destruction
124  *************************************************************************/
130  {
131  Logger::getSingleton().logEvent("CEGUI::WindowFactoryManager singleton created");
132  }
133 
134 
140  {
141  Logger::getSingleton().logEvent("CEGUI::WindowFactoryManager singleton destroyed");
142  }
143 
144 
145  /*************************************************************************
146  Public Interface
147  *************************************************************************/
161  void addFactory(WindowFactory* factory);
162 
163 
178  void removeFactory(const String& name);
179 
180 
195  void removeFactory(WindowFactory* factory);
196 
197 
205  void removeAllFactories(void) {d_factoryRegistry.clear();}
206 
207 
220  WindowFactory* getFactory(const String& type) const;
221 
222 
237  bool isFactoryPresent(const String& name) const;
238 
239 
265  void addWindowTypeAlias(const String& aliasName, const String& targetType);
266 
267 
285  void removeWindowTypeAlias(const String& aliasName, const String& targetType);
286 
315  void addFalagardWindowMapping(const String& newType, const String& targetType, const String& lookName, const String& renderer);
316 
324  void removeFalagardWindowMapping(const String& type);
325 
337  bool isFalagardMappedType(const String& type) const;
338 
351  const String& getMappedLookForType(const String& type) const;
352 
365  const String& getMappedRendererForType(const String& type) const;
366 
385  String getDereferencedAliasType(const String& type) const;
386 
399  const FalagardWindowMapping& getFalagardMappingForType(const String& type) const;
400 
401 private:
402  /*************************************************************************
403  Implementation Data
404  *************************************************************************/
405  typedef std::map<String, WindowFactory*, String::FastLessCompare> WindowFactoryRegistry;
406  typedef std::map<String, AliasTargetStack, String::FastLessCompare> TypeAliasRegistry;
407  typedef std::map<String, FalagardWindowMapping, String::FastLessCompare> FalagardMapRegistry;
408 
409  WindowFactoryRegistry d_factoryRegistry;
410  TypeAliasRegistry d_aliasRegistry;
411  FalagardMapRegistry d_falagardRegistry;
412 
413 public:
414  /*************************************************************************
415  Iterator stuff
416  *************************************************************************/
417  typedef ConstBaseIterator<WindowFactoryRegistry> WindowFactoryIterator;
418  typedef ConstBaseIterator<TypeAliasRegistry> TypeAliasIterator;
419  typedef ConstBaseIterator<FalagardMapRegistry> FalagardMappingIterator;
420 
425  WindowFactoryIterator getIterator(void) const;
426 
427 
432  TypeAliasIterator getAliasIterator(void) const;
433 
434 
439  FalagardMappingIterator getFalagardMappingIterator() const;
440 };
441 
442 } // End of CEGUI namespace section
443 
444 
445 #if defined(_MSC_VER)
446 # pragma warning(pop)
447 #endif
448 
449 #endif // end of guard _CEGUIWindowFactoryManager_h_