MyGUI 3.2.0

- Main Page
- Related Pages
- Namespaces
- Data Structures
- Files
- Examples

- File List
- Globals

MyGUI_FactoryManager.h
Go to the documentation of this file.
1
6 /*
7 This file is part of MyGUI.
8
9 MyGUI is free software: you can redistribute it and/or modify
10 it under the terms of the GNU Lesser General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 MyGUI is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU Lesser General Public License for more details.
18
19 You should have received a copy of the GNU Lesser General Public License
20 along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
21 */
22 #ifndef __MYGUI_FACTORY_MANAGER_H__
23 #define __MYGUI_FACTORY_MANAGER_H__
24
25 #include "MyGUI_Prerequest.h"
26 #include "MyGUI_Singleton.h"
27 #include "MyGUI_IObject.h"
28 #include "MyGUI_GenericFactory.h"
29
30 namespace MyGUI
31 {
32
33 class MYGUI_EXPORT FactoryManager :
34 public Singleton<FactoryManager>
35 {
36 public:
37 FactoryManager();
38
39 void initialise();
40 void shutdown();
41
42 typedef delegates::CDelegate1<IObject*&> Delegate;
44 void registerFactory(const std::string& _category, const std::string& _type, Delegate::IDelegate* _delegate);
46 void unregisterFactory(const std::string& _category, const std::string& _type);
48 void unregisterFactory(const std::string& _category);
49
51 bool isFactoryExist(const std::string& _category, const std::string& _type);
52
54 template<typename Type>
55 void registerFactory(const std::string& _category)
56 {
57 registerFactory(_category, Type::getClassTypeName(), GenericFactory<Type>::getFactory());
58 }
59
61 template<typename Type>
62 void registerFactory(const std::string& _category, const std::string& _type)
63 {
64 registerFactory(_category, _type, GenericFactory<Type>::getFactory());
65 }
66
68 template<typename Type>
69 void unregisterFactory(const std::string& _category)
70 {
71 unregisterFactory(_category, Type::getClassTypeName());
72 }
73
75 IObject* createObject(const std::string& _category, const std::string& _type);
77 void destroyObject(IObject* _object);
78
79 private:
80 typedef std::map<std::string, Delegate> MapFactoryItem;
81 typedef std::map<std::string, MapFactoryItem> MapRegisterFactoryItem;
82 MapRegisterFactoryItem mRegisterFactoryItems;
83
84 bool mIsInitialise;
85 };
86
87 } // namespace MyGUI
88
89 #endif // __MYGUI_FACTORY_MANAGER_H__
MyGUI::delegates::CDelegate1
Definition: MyGUI_Delegate.h:169
MyGUI_Prerequest.h
MyGUI_Singleton.h
MyGUI::FactoryManager::unregisterFactory
void unregisterFactory(const std::string &_category)
Definition: MyGUI_FactoryManager.h:69
MyGUI::delegates::IDelegate1
Definition: MyGUI_Delegate.h:41
MyGUI::FactoryManager::registerFactory
void registerFactory(const std::string &_category)
Definition: MyGUI_FactoryManager.h:55
MyGUI::FactoryManager
Definition: MyGUI_FactoryManager.h:33
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition: MyGUI_Platform.h:120
MyGUI::GenericFactory
Definition: MyGUI_GenericFactory.h:17
MyGUI::FactoryManager::Delegate
delegates::CDelegate1< IObject *& > Delegate
Definition: MyGUI_FactoryManager.h:42
MyGUI::FactoryManager::registerFactory
void registerFactory(const std::string &_category, const std::string &_type)
Definition: MyGUI_FactoryManager.h:62
MyGUI_GenericFactory.h
MyGUI_IObject.h
MyGUI::IObject
Definition: MyGUI_IObject.h:31
MyGUI::Singleton
Definition: MyGUI_Singleton.h:35