MyGUI: MyGUI_ResourceManager.h Source File

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"
17#include "MyGUI_BackwardCompatibility.h"
18
19namespace MyGUI
20{
21
22 class MYGUI_EXPORT ResourceManager : public MemberObsolete<ResourceManager>
23 {
24 MYGUI_SINGLETON_DECLARATION(ResourceManager);
25
26 public:
27 ResourceManager();
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
44 using LoadXmlDelegate = EventPairConvertStringView<
45 delegates::Delegate<xml::ElementPtr, const std::string&, Version>,
46 delegates::Delegate<xml::ElementPtr, std::string_view, Version>>;
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<>>;
68 using EnumeratorPtr = Enumerator<MapResource>;
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_
MyGUI_BackwardCompatibility.h
MyGUI_Delegate.h
MyGUI_Enumerator.h
MyGUI_EventPair.h
MyGUI_IResource.h
MYGUI_EXPORT
#define MYGUI_EXPORT
Definition MyGUI_Platform.h:77
MyGUI_Prerequest.h
MyGUI_Singleton.h
MYGUI_SINGLETON_DECLARATION
#define MYGUI_SINGLETON_DECLARATION(ClassName)
Definition MyGUI_Singleton.h:112
MyGUI_XmlDocument.h
MyGUI::Enumerator
Definition MyGUI_Enumerator.h:49
MyGUI::EventPairConvertStringView
Definition MyGUI_EventPair.h:213
MyGUI::IResource
Definition MyGUI_IResource.h:24
MyGUI::MemberObsolete
Definition MyGUI_DeprecatedTypes.h:14
MyGUI::ResourceManager::unregisterLoadXmlDelegate
void unregisterLoadXmlDelegate(std::string_view _key)
Definition MyGUI_ResourceManager.cpp:127
MyGUI::ResourceManager::MapResource
std::map< std::string, IResource *, std::less<> > MapResource
Definition MyGUI_ResourceManager.h:67
MyGUI::ResourceManager::getCategoryName
const std::string & getCategoryName() const
Definition MyGUI_ResourceManager.cpp:283
MyGUI::ResourceManager::isExist
bool isExist(std::string_view _name) const
Definition MyGUI_ResourceManager.cpp:232
MyGUI::ResourceManager::initialise
void initialise()
Definition MyGUI_ResourceManager.cpp:28
MyGUI::ResourceManager::getCount
size_t getCount() const
Definition MyGUI_ResourceManager.cpp:278
MyGUI::ResourceManager::removeResource
void removeResource(IResourcePtr _item)
Definition MyGUI_ResourceManager.cpp:219
MyGUI::ResourceManager::registerLoadXmlDelegate
LoadXmlDelegate & registerLoadXmlDelegate(std::string_view _key)
Definition MyGUI_ResourceManager.cpp:120
MyGUI::ResourceManager::loadFromXmlNode
void loadFromXmlNode(xml::ElementPtr _node, std::string_view _file, Version _version)
Definition MyGUI_ResourceManager.cpp:65
MyGUI::ResourceManager::ResourceManager
ResourceManager(const ResourceManager &)=delete
MyGUI::ResourceManager::getByName
IResource * getByName(std::string_view _name, bool _throw=true) const
Definition MyGUI_ResourceManager.cpp:243
MyGUI::ResourceManager::clear
void clear()
Definition MyGUI_ResourceManager.cpp:262
MyGUI::ResourceManager::getEnumerator
EnumeratorPtr getEnumerator() const
Definition MyGUI_ResourceManager.cpp:273
MyGUI::ResourceManager::EnumeratorPtr
Enumerator< MapResource > EnumeratorPtr
Definition MyGUI_ResourceManager.h:68
MyGUI::ResourceManager::load
bool load(const std::string &_file)
Definition MyGUI_ResourceManager.cpp:60
MyGUI::ResourceManager::findByName
IResource * findByName(std::string_view _name) const
Definition MyGUI_ResourceManager.cpp:237
MyGUI::ResourceManager::shutdown
void shutdown()
Definition MyGUI_ResourceManager.cpp:43
MyGUI::ResourceManager::removeByName
bool removeByName(std::string_view _name)
Definition MyGUI_ResourceManager.cpp:250
MyGUI::ResourceManager::LoadXmlDelegate
EventPairConvertStringView< delegates::Delegate< xml::ElementPtr, const std::string &, Version >, delegates::Delegate< xml::ElementPtr, std::string_view, Version > > LoadXmlDelegate
Definition MyGUI_ResourceManager.h:44
MyGUI::ResourceManager::addResource
void addResource(IResourcePtr _item)
Definition MyGUI_ResourceManager.cpp:213
MyGUI::Version
Definition MyGUI_Version.h:18
MyGUI::delegates::Delegate
Definition MyGUI_Delegate.h:158
MyGUI::xml::ElementPtr
Element * ElementPtr
Definition MyGUI_XmlDocument.h:112
MyGUI
Definition MyGUI_ActionController.h:15
MyGUI::IResourcePtr
IResource * IResourcePtr
Definition MyGUI_IResource.h:19