MyGUI  3.0.1
MyGUI_ResourceManager.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_RESOURCE_MANAGER_H__
24 #define __MYGUI_RESOURCE_MANAGER_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_Instance.h"
28 #include "MyGUI_Enumerator.h"
29 #include "MyGUI_Guid.h"
30 #include "MyGUI_XmlDocument.h"
31 #include "MyGUI_IResource.h"
32 #include "MyGUI_ResourceHolder.h"
33 #include "MyGUI_Delegate.h"
34 
35 namespace MyGUI
36 {
37 
39  public ResourceHolder<IResource>
40  {
42 
43  public:
44  void initialise();
45  void shutdown();
46 
47  public:
48 
50  bool load(const std::string& _file);
51 
52  bool _loadImplement(const std::string& _file, bool _match, const std::string& _type, const std::string& _instance);
53  void _load(xml::ElementPtr _node, const std::string& _file, Version _version);
54  void _loadList(xml::ElementPtr _node, const std::string& _file, Version _version);
55 
57  IResourcePtr getByID(const Guid& _id, bool _throw = true);
58 
59  std::string getFileNameByID(const Guid& _id);
60 
61  void addResource(IResourcePtr _item);
62 
63  void removeResource(IResourcePtr _item);
64 
66 
67  LoadXmlDelegate& registerLoadXmlDelegate(const std::string& _key);
68 
69  void unregisterLoadXmlDelegate(const std::string& _key);
70 
71  /*obsolete:*/
72 #ifndef MYGUI_DONT_USE_OBSOLETE
73 
74  MYGUI_OBSOLETE("use : size_t ResourceManager::getCount()")
75  size_t getResourceCount() { return getCount(); }
76 
77  MYGUI_OBSOLETE("use : IResourcePtr ResourceManager::getByName(const std::string& _name, bool _throw)")
78  IResourcePtr getResource(const std::string& _name, bool _throw = true) { return getByName(_name, _throw); }
79 
80  MYGUI_OBSOLETE("use : IResourcePtr ResourceManager::getByID(const Guid& _id, bool _throw)")
81  IResourcePtr getResource(const Guid& _id, bool _throw = true) { return getByID(_id, _throw); }
82 
83 #endif // MYGUI_DONT_USE_OBSOLETE
84 
85  private:
86  typedef std::map<Guid, IResourcePtr> MapResourceID;
87  MapResourceID mResourcesID;
88 
89  // карта с делегатами для парсинга хмл блоков
90  typedef std::map<std::string, LoadXmlDelegate> MapLoadXmlDelegate;
91  MapLoadXmlDelegate mMapLoadXmlDelegate;
92 
93  std::string mResourceGroup;
94  typedef std::vector<Guid> VectorGuid;
95  typedef std::map<std::string, VectorGuid> MapVectorString;
96 
97  MapVectorString mListFileGuid;
98  };
99 
100 } // namespace MyGUI
101 
102 #endif // __MYGUI_RESOURCE_MANAGER_H__