00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef __MYGUI_RESOURCE_MANAGER_H__
00024 #define __MYGUI_RESOURCE_MANAGER_H__
00025
00026 #include "MyGUI_Prerequest.h"
00027 #include "MyGUI_Instance.h"
00028 #include "MyGUI_Enumerator.h"
00029 #include "MyGUI_Guid.h"
00030 #include "MyGUI_XmlDocument.h"
00031 #include "MyGUI_IResource.h"
00032 #include "MyGUI_ResourceHolder.h"
00033 #include "MyGUI_Delegate.h"
00034
00035 namespace MyGUI
00036 {
00037
00038 class MYGUI_EXPORT ResourceManager :
00039 public ResourceHolder<IResource>
00040 {
00041 MYGUI_INSTANCE_HEADER( ResourceManager )
00042
00043 public:
00044 void initialise();
00045 void shutdown();
00046
00047 public:
00048
00050 bool load(const std::string& _file);
00051
00052 bool _loadImplement(const std::string& _file, bool _match, const std::string& _type, const std::string& _instance);
00053 void _load(xml::ElementPtr _node, const std::string& _file, Version _version);
00054 void _loadList(xml::ElementPtr _node, const std::string& _file, Version _version);
00055
00057 IResourcePtr getByID(const Guid& _id, bool _throw = true);
00058
00059 std::string getFileNameByID(const Guid& _id);
00060
00061 void addResource(IResourcePtr _item);
00062
00063 void removeResource(IResourcePtr _item);
00064
00065 typedef delegates::CDelegate3<xml::ElementPtr, const std::string &, Version> LoadXmlDelegate;
00066
00067 LoadXmlDelegate& registerLoadXmlDelegate(const std::string& _key);
00068
00069 void unregisterLoadXmlDelegate(const std::string& _key);
00070
00071
00072 #ifndef MYGUI_DONT_USE_OBSOLETE
00073
00074 MYGUI_OBSOLETE("use : size_t ResourceManager::getCount()")
00075 size_t getResourceCount() { return getCount(); }
00076
00077 MYGUI_OBSOLETE("use : IResourcePtr ResourceManager::getByName(const std::string& _name, bool _throw)")
00078 IResourcePtr getResource(const std::string& _name, bool _throw = true) { return getByName(_name, _throw); }
00079
00080 MYGUI_OBSOLETE("use : IResourcePtr ResourceManager::getByID(const Guid& _id, bool _throw)")
00081 IResourcePtr getResource(const Guid& _id, bool _throw = true) { return getByID(_id, _throw); }
00082
00083 #endif // MYGUI_DONT_USE_OBSOLETE
00084
00085 private:
00086 typedef std::map<Guid, IResourcePtr> MapResourceID;
00087 MapResourceID mResourcesID;
00088
00089
00090 typedef std::map<std::string, LoadXmlDelegate> MapLoadXmlDelegate;
00091 MapLoadXmlDelegate mMapLoadXmlDelegate;
00092
00093 std::string mResourceGroup;
00094 typedef std::vector<Guid> VectorGuid;
00095 typedef std::map<std::string, VectorGuid> MapVectorString;
00096
00097 MapVectorString mListFileGuid;
00098 };
00099
00100 }
00101
00102 #endif // __MYGUI_RESOURCE_MANAGER_H__