00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
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 registerFactory(const std::string& _category, const std::string& _type, Delegate::IDelegate* _delegate);
00045 void unregisterFactory(const std::string& _category, const std::string& _type);
00046 void unregisterFactory(const std::string& _category);
00047
00048 bool isFactoryExist(const std::string& _category, const std::string& _type);
00049
00050 template<typename Type>
00051 void registerFactory(const std::string& _category)
00052 {
00053 registerFactory(_category, Type::getClassTypeName(), GenericFactory<Type>::getFactory());
00054 }
00055
00056 template<typename Type>
00057 void registerFactory(const std::string& _category, const std::string& _type)
00058 {
00059 registerFactory(_category, _type, GenericFactory<Type>::getFactory());
00060 }
00061
00062 template<typename Type>
00063 void unregisterFactory(const std::string& _category)
00064 {
00065 unregisterFactory(_category, Type::getClassTypeName());
00066 }
00067
00068 IObject* createObject(const std::string& _category, const std::string& _type);
00069 void destroyObject(IObject* _object);
00070
00071 private:
00072 typedef std::map<std::string, Delegate> MapFactoryItem;
00073 typedef std::map<std::string, MapFactoryItem> MapRegisterFactoryItem;
00074 MapRegisterFactoryItem mRegisterFactoryItems;
00075 };
00076
00077 }
00078
00079 #endif // __MYGUI_FACTORY_MANAGER_H__