• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_FactoryManager.h

Go to the documentation of this file.
00001 
00007 /*
00008     This file is part of MyGUI.
00009 
00010     MyGUI is free software: you can redistribute it and/or modify
00011     it under the terms of the GNU Lesser General Public License as published by
00012     the Free Software Foundation, either version 3 of the License, or
00013     (at your option) any later version.
00014 
00015     MyGUI is distributed in the hope that it will be useful,
00016     but WITHOUT ANY WARRANTY; without even the implied warranty of
00017     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018     GNU Lesser General Public License for more details.
00019 
00020     You should have received a copy of the GNU Lesser General Public License
00021     along with MyGUI.  If not, see <http://www.gnu.org/licenses/>.
00022 */
00023 #ifndef __MYGUI_FACTORY_MANAGER_H__
00024 #define __MYGUI_FACTORY_MANAGER_H__
00025 
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Instance.h"
00028 #include "MyGUI_IObject.h"
00029 #include "MyGUI_GenericFactory.h"
00030 
00031 namespace MyGUI
00032 {
00033 
00034     class MYGUI_EXPORT FactoryManager
00035     {
00036         MYGUI_INSTANCE_HEADER( FactoryManager );
00037 
00038     public:
00039         typedef delegates::CDelegate1<IObject*&> Delegate;
00040 
00041         void initialise();
00042         void shutdown();
00043 
00044         void registryFactory(const std::string& _category, const std::string& _type, Delegate::IDelegate* _delegate);
00045         void unregistryFactory(const std::string& _category, const std::string& _type);
00046         void unregistryFactory(const std::string& _category);
00047 
00048         template<typename Type>
00049         void registryFactory(const std::string& _category)
00050         {
00051             registryFactory(_category, Type::getClassTypeName(), GenericFactory<Type>::getFactory());
00052         }
00053 
00054         template<typename Type>
00055         void registryFactory(const std::string& _category, const std::string& _type)
00056         {
00057             registryFactory(_category, _type, GenericFactory<Type>::getFactory());
00058         }
00059 
00060         template<typename Type>
00061         void unregistryFactory(const std::string& _category)
00062         {
00063             unregistryFactory(_category, Type::getClassTypeName());
00064         }
00065 
00066         IObject* createObject(const std::string& _category, const std::string& _type);
00067         void destroyObject(IObject* _object);
00068 
00069     private:
00070         typedef std::map<std::string, Delegate> MapFactoryItem;
00071         typedef std::map<std::string, MapFactoryItem> MapRegistryFactoryItem;
00072         MapRegistryFactoryItem mRegistryFactoryItems;
00073     };
00074 
00075 } // namespace MyGUI
00076 
00077 #endif // __MYGUI_FACTORY_MANAGER_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1