MyGUI 3.4.3
MyGUI_ResourceManager.h
Go to the documentation of this file.
1/*
2 * This source file is part of MyGUI. For the latest info, see http://mygui.info/
3 * Distributed under the MIT License
4 * (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
5 */
6
7#ifndef MYGUI_RESOURCE_MANAGER_H_
8#define MYGUI_RESOURCE_MANAGER_H_
9
10#include "MyGUI_Prerequest.h"
11#include "MyGUI_Singleton.h"
12#include "MyGUI_EventPair.h"
13#include "MyGUI_Enumerator.h"
14#include "MyGUI_XmlDocument.h"
15#include "MyGUI_IResource.h"
16#include "MyGUI_Delegate.h"
18
19namespace MyGUI
20{
21
22 class MYGUI_EXPORT ResourceManager : public MemberObsolete<ResourceManager>
23 {
25
26 public:
28
29 void initialise();
30 void shutdown();
31
32 public:
34 bool load(const std::string& _file);
35
36 void loadFromXmlNode(xml::ElementPtr _node, std::string_view _file, Version _version);
37
39 void addResource(IResourcePtr _item);
40
42 void removeResource(IResourcePtr _item);
43
47
49 LoadXmlDelegate& registerLoadXmlDelegate(std::string_view _key);
50
52 void unregisterLoadXmlDelegate(std::string_view _key);
53
55 bool isExist(std::string_view _name) const;
56
58 IResource* findByName(std::string_view _name) const;
59
61 IResource* getByName(std::string_view _name, bool _throw = true) const;
62
63 bool removeByName(std::string_view _name);
64
65 void clear();
66
67 using MapResource = std::map<std::string, IResource*, std::less<>>;
69
70 EnumeratorPtr getEnumerator() const;
71
72 size_t getCount() const;
73
74 const std::string& getCategoryName() const;
75
76 private:
77 void _loadList(xml::ElementPtr _node, std::string_view _file, Version _version);
78 bool _loadImplement(const std::string& _file, bool _match, std::string_view _type, std::string_view _instance);
79
80 private:
81 // карта с делегатами для парсинга хмл блоков
82 using MapLoadXmlDelegate = std::map<std::string, LoadXmlDelegate, std::less<>>;
83 MapLoadXmlDelegate mMapLoadXmlDelegate;
84
85 MapResource mResources;
86
87 using VectorResource = std::vector<IResource*>;
88 VectorResource mRemovedResources;
89
90 bool mIsInitialise{false};
91 std::string mCategoryName;
92 std::string mXmlListTagName;
93 };
94
95} // namespace MyGUI
96
97#endif // MYGUI_RESOURCE_MANAGER_H_
#define MYGUI_EXPORT
#define MYGUI_SINGLETON_DECLARATION(ClassName)
std::map< std::string, IResource *, std::less<> > MapResource