• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List

CEGUIWindowRendererManager.h

00001 /***********************************************************************
00002     filename:   CEGUIWindowRenderer.h
00003     created:    Jan 11 2006
00004     author:     Tomas Lindquist Olsen
00005 
00006     purpose:    Defines interface for the WindowRendererManager class
00007 *************************************************************************/
00008 /***************************************************************************
00009  *   Copyright (C) 2004 - 2009 Paul D Turner & The CEGUI Development Team
00010  *
00011  *   Permission is hereby granted, free of charge, to any person obtaining
00012  *   a copy of this software and associated documentation files (the
00013  *   "Software"), to deal in the Software without restriction, including
00014  *   without limitation the rights to use, copy, modify, merge, publish,
00015  *   distribute, sublicense, and/or sell copies of the Software, and to
00016  *   permit persons to whom the Software is furnished to do so, subject to
00017  *   the following conditions:
00018  *
00019  *   The above copyright notice and this permission notice shall be
00020  *   included in all copies or substantial portions of the Software.
00021  *
00022  *   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
00023  *   EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00024  *   MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00025  *   IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
00026  *   OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
00027  *   ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
00028  *   OTHER DEALINGS IN THE SOFTWARE.
00029  ***************************************************************************/
00030 #ifndef _CEGUIWindowRendererManager_h_
00031 #define _CEGUIWindowRendererManager_h_
00032 
00033 #include "CEGUISingleton.h"
00034 #include "CEGUIWindowRenderer.h"
00035 #include "CEGUILogger.h"
00036 #include "CEGUIExceptions.h"
00037 #include <map>
00038 #include <vector>
00039 
00040 #if defined(_MSC_VER)
00041 #   pragma warning(push)
00042 #   pragma warning(disable : 4251)
00043 #endif
00044 
00045 // Start of CEGUI namespace section
00046 namespace CEGUI
00047 {
00048 class CEGUIEXPORT WindowRendererManager : public Singleton<WindowRendererManager>
00049 {
00050 public:
00051     /*************************************************************************
00052         Contructor / Destructor
00053     *************************************************************************/
00054     WindowRendererManager();
00055     ~WindowRendererManager();
00056 
00057     /*************************************************************************
00058         Singleton
00059     *************************************************************************/
00060     static WindowRendererManager& getSingleton();
00061     static WindowRendererManager* getSingletonPtr();
00062 
00063     /*************************************************************************
00064         Accessors
00065     *************************************************************************/
00066     bool isFactoryPresent(const String& name) const;
00067     WindowRendererFactory* getFactory(const String& name) const;
00068 
00069     /*************************************************************************
00070         Manipulators
00071     *************************************************************************/
00085     template <typename T>
00086     static void addFactory();
00087     void addFactory(WindowRendererFactory* wr);
00088     void removeFactory(const String& name);
00089 
00090     /*************************************************************************
00091         Factory usage
00092     *************************************************************************/
00093     WindowRenderer* createWindowRenderer(const String& name);
00094     void destroyWindowRenderer(WindowRenderer* wr);
00095 
00096 private:
00097     /*************************************************************************
00098         Private implementation
00099     *************************************************************************/
00100 
00101     /*************************************************************************
00102         Implementation data
00103     *************************************************************************/
00104     typedef std::map<String, WindowRendererFactory*, String::FastLessCompare> WR_Registry;
00105     WR_Registry d_wrReg;
00106 
00108     typedef std::vector<WindowRendererFactory*> OwnedFactoryList;
00110     static OwnedFactoryList d_ownedFactories;
00111 };
00112 
00113 //----------------------------------------------------------------------------//
00114 template <typename T>
00115 void WindowRendererManager::addFactory()
00116 {
00117     // create the factory object
00118     WindowRendererFactory* factory = new T;
00119 
00120     // only do the actual add now if our singleton has already been created
00121     if (WindowRendererManager::getSingletonPtr())
00122     {
00123         Logger::getSingleton().logEvent("Created WindowRendererFactory for '" +
00124                                         factory->getName() +
00125                                         "' WindowRenderers.");
00126         // add the factory we just created
00127         CEGUI_TRY
00128         {
00129             WindowRendererManager::getSingleton().addFactory(factory);
00130         }
00131         CEGUI_CATCH (Exception&)
00132         {
00133             Logger::getSingleton().logEvent("Deleted WindowRendererFactory for "
00134                                             "'" + factory->getName() +
00135                                             "' WindowRenderers.");
00136             // delete the factory object
00137             delete factory;
00138             CEGUI_RETHROW;
00139         }
00140     }
00141 
00142     d_ownedFactories.push_back(factory);
00143 }
00144 
00145 //----------------------------------------------------------------------------//
00146 
00147 
00148 } // End of CEGUI namespace
00149 
00150 #if defined(_MSC_VER)
00151 #   pragma warning(pop)
00152 #endif
00153 
00154 #endif // _CEGUIWindowRendererManager_h_

Generated on Sat Sep 25 2010 02:10:34 for Crazy Eddies GUI System by  doxygen 1.7.1