• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • Examples
  • File List
  • Globals

MyGUI_ResourceManager.h

Go to the documentation of this file.
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_Common.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 
00034 namespace MyGUI
00035 {
00036 
00037     class MYGUI_EXPORT ResourceManager :
00038         public ResourceHolder<IResource>
00039     {
00040         MYGUI_INSTANCE_HEADER(ResourceManager);
00041 
00042     public:
00043         void initialise();
00044         void shutdown();
00045 
00046     public:
00047 
00049         bool load(const std::string& _file);
00050 
00051         bool _loadImplement(const std::string& _file, bool _match, const std::string& _type, const std::string& _instance);
00052         void _load(xml::ElementPtr _node, const std::string& _file, Version _version);
00053         void _loadList(xml::ElementPtr _node, const std::string& _file, Version _version);
00054         void _loadSection(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 
00100 } // namespace MyGUI
00101 
00102 #endif // __MYGUI_RESOURCE_MANAGER_H__

Generated on Sun Jan 30 2011 for MyGUI by  doxygen 1.7.1