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