MyGUI
3.0.3
|
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_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 /*obsolete:*/ 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 typedef std::vector<IResourcePtr> VectorResource; 00100 VectorResource mRemovedResoures; 00101 }; 00102 00103 } // namespace MyGUI 00104 00105 #endif // __MYGUI_RESOURCE_MANAGER_H__