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 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 }
00076
00077 #endif // __MYGUI_FACTORY_MANAGER_H__