MyGUI
3.2.0
|
00001 00006 /* 00007 This file is part of MyGUI. 00008 00009 MyGUI is free software: you can redistribute it and/or modify 00010 it under the terms of the GNU Lesser General Public License as published by 00011 the Free Software Foundation, either version 3 of the License, or 00012 (at your option) any later version. 00013 00014 MyGUI is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU Lesser General Public License for more details. 00018 00019 You should have received a copy of the GNU Lesser General Public License 00020 along with MyGUI. If not, see <http://www.gnu.org/licenses/>. 00021 */ 00022 #ifndef __MYGUI_RESOURCE_MANAGER_H__ 00023 #define __MYGUI_RESOURCE_MANAGER_H__ 00024 00025 #include "MyGUI_Prerequest.h" 00026 #include "MyGUI_Singleton.h" 00027 #include "MyGUI_Enumerator.h" 00028 #include "MyGUI_XmlDocument.h" 00029 #include "MyGUI_IResource.h" 00030 #include "MyGUI_Delegate.h" 00031 #include "MyGUI_BackwardCompatibility.h" 00032 00033 namespace MyGUI 00034 { 00035 00036 class MYGUI_EXPORT ResourceManager : 00037 public Singleton<ResourceManager>, 00038 public MemberObsolete<ResourceManager> 00039 { 00040 public: 00041 ResourceManager(); 00042 00043 void initialise(); 00044 void shutdown(); 00045 00046 public: 00048 bool load(const std::string& _file); 00049 00050 void loadFromXmlNode(xml::ElementPtr _node, const std::string& _file, Version _version); 00051 00053 void addResource(IResourcePtr _item); 00054 00056 void removeResource(IResourcePtr _item); 00057 00058 typedef delegates::CDelegate3<xml::ElementPtr, const std::string&, Version> LoadXmlDelegate; 00059 00061 LoadXmlDelegate& registerLoadXmlDelegate(const std::string& _key); 00062 00064 void unregisterLoadXmlDelegate(const std::string& _key); 00065 00067 bool isExist(const std::string& _name) const; 00068 00070 IResource* findByName(const std::string& _name) const; 00071 00073 IResource* getByName(const std::string& _name, bool _throw = true) const; 00074 00075 bool removeByName(const std::string& _name); 00076 00077 void clear(); 00078 00079 typedef std::map<std::string, IResource*> MapResource; 00080 typedef Enumerator<MapResource> EnumeratorPtr; 00081 00082 EnumeratorPtr getEnumerator() const; 00083 00084 size_t getCount() const; 00085 00086 private: 00087 void _loadList(xml::ElementPtr _node, const std::string& _file, Version _version); 00088 bool _loadImplement(const std::string& _file, bool _match, const std::string& _type, const std::string& _instance); 00089 00090 private: 00091 // карта с делегатами для парсинга хмл блоков 00092 typedef std::map<std::string, LoadXmlDelegate> MapLoadXmlDelegate; 00093 MapLoadXmlDelegate mMapLoadXmlDelegate; 00094 00095 MapResource mResources; 00096 00097 typedef std::vector<IResource*> VectorResource; 00098 VectorResource mRemovedResoures; 00099 00100 bool mIsInitialise; 00101 }; 00102 00103 } // namespace MyGUI 00104 00105 #endif // __MYGUI_RESOURCE_MANAGER_H__