MyGUI_ResourceManager.h
Go to the documentation of this file.
/*
* This source file is part of MyGUI. For the latest info, see http://mygui.info/
* Distributed under the MIT License
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/
#ifndef MYGUI_RESOURCE_MANAGER_H_
#define MYGUI_RESOURCE_MANAGER_H_
#include "MyGUI_Prerequest.h"
#include "MyGUI_Singleton.h"
#include "MyGUI_EventPair.h"
#include "MyGUI_Enumerator.h"
#include "MyGUI_XmlDocument.h"
#include "MyGUI_IResource.h"
#include "MyGUI_Delegate.h"
#include "MyGUI_BackwardCompatibility.h"
namespace MyGUI
{
class MYGUI_EXPORT ResourceManager : public MemberObsolete<ResourceManager>
{
MYGUI_SINGLETON_DECLARATION(ResourceManager);
public:
ResourceManager();
void initialise();
void shutdown();
public:
bool load(const std::string& _file);
void loadFromXmlNode(xml::ElementPtr _node, std::string_view _file, Version _version);
void addResource(IResourcePtr _item);
void removeResource(IResourcePtr _item);
using LoadXmlDelegate = EventPairConvertStringView<
delegates::Delegate<xml::ElementPtr, const std::string&, Version>,
delegates::Delegate<xml::ElementPtr, std::string_view, Version>>;
LoadXmlDelegate& registerLoadXmlDelegate(std::string_view _key);
void unregisterLoadXmlDelegate(std::string_view _key);
bool isExist(std::string_view _name) const;
IResource* findByName(std::string_view _name) const;
IResource* getByName(std::string_view _name, bool _throw = true) const;
bool removeByName(std::string_view _name);
void clear();
using MapResource = std::map<std::string, IResource*, std::less<>>;
using EnumeratorPtr = Enumerator<MapResource>;
EnumeratorPtr getEnumerator() const;
size_t getCount() const;
const std::string& getCategoryName() const;
private:
void _loadList(xml::ElementPtr _node, std::string_view _file, Version _version);
bool _loadImplement(const std::string& _file, bool _match, std::string_view _type, std::string_view _instance);
private:
// карта с делегатами для парсинга хмл блоков
using MapLoadXmlDelegate = std::map<std::string, LoadXmlDelegate, std::less<>>;
MapLoadXmlDelegate mMapLoadXmlDelegate;
MapResource mResources;
using VectorResource = std::vector<IResource*>;
VectorResource mRemovedResources;
bool mIsInitialise{false};
std::string mCategoryName;
std::string mXmlListTagName;
};
} // namespace MyGUI
#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::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::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::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