22 mCategoryName(
"Resource"),
23 mXmlListTagName(
"List"),
24 mSingletonHolder(
this)
54 mMapLoadXmlDelegate.clear();
57 mIsInitialise =
false;
76 root->findAttribute(
"type", type);
77 root->findAttribute(
"name", name);
83 if (
object ==
nullptr)
85 MYGUI_LOG(Error,
"resource type '" << type <<
"' not found");
89 MapResource::iterator item = mResources.find(name);
90 if (item != mResources.end())
92 MYGUI_LOG(Warning,
"duplicate resource name '" << name <<
"'");
95 mRemovedResources.push_back((*item).second);
96 mResources.erase(item);
122 MapLoadXmlDelegate::iterator
iter = mMapLoadXmlDelegate.find(
_key);
129 MapLoadXmlDelegate::iterator
iter = mMapLoadXmlDelegate.find(
_key);
130 if (
iter != mMapLoadXmlDelegate.end())
131 mMapLoadXmlDelegate.erase(
iter);
134 bool ResourceManager::_loadImplement(
135 const std::string&
_file,
137 std::string_view
_type,
150 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', " << doc.getLastError());
155 if ((
nullptr == root) || (root->getName() !=
"MyGUI"))
157 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', tag 'MyGUI' not found");
162 if (root->findAttribute(
"type", type))
165 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type);
166 if (iter != mMapLoadXmlDelegate.end())
168 if ((!_match) || (type == _type))
169 (*iter).second(root, _file, version);
172 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', type '" << _type <<
"' not found");
178 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', delegate for type '" << type <<
"'not found");
186 while (node.next(
"MyGUI"))
188 if (node->findAttribute(
"type", type))
191 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type);
192 if (iter != mMapLoadXmlDelegate.end())
194 (*iter).second(node.current(), _file, version);
200 _instance <<
" : '" << _file <<
"', delegate for type '" << type <<
"'not found");
205 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', tag 'type' not found");
215 if (!
_item->getResourceName().empty())
221 if (
_item ==
nullptr)
224 if (!
_item->getResourceName().empty())
226 MapResource::iterator item = mResources.find(
_item->getResourceName());
227 if (item != mResources.end())
228 mResources.erase(item);
234 return mResources.find(
_name) != mResources.end();
239 MapResource::const_iterator item = mResources.find(
_name);
240 return (item == mResources.end()) ?
nullptr : item->second;
252 MapResource::const_iterator item = mResources.find(
_name);
253 if (item != mResources.end())
256 mResources.erase(item->first);
270 mRemovedResources.clear();
280 return mResources.size();
285 return mCategoryName;
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_LOG(level, text)
#define MYGUI_SINGLETON_DEFINITION(ClassName)
static DataManager & getInstance()
T::const_reference current()
static FactoryManager & getInstance()
void unregisterLoadXmlDelegate(std::string_view _key)
const std::string & getCategoryName() const
bool isExist(std::string_view _name) const
void removeResource(IResourcePtr _item)
LoadXmlDelegate & registerLoadXmlDelegate(std::string_view _key)
void loadFromXmlNode(xml::ElementPtr _node, std::string_view _file, Version _version)
IResource * getByName(std::string_view _name, bool _throw=true) const
static std::string_view getClassTypeName()
EnumeratorPtr getEnumerator() const
Enumerator< MapResource > EnumeratorPtr
bool load(const std::string &_file)
IResource * findByName(std::string_view _name) const
bool removeByName(std::string_view _name)
EventPairConvertStringView< delegates::Delegate< xml::ElementPtr, const std::string &, Version >, delegates::Delegate< xml::ElementPtr, std::string_view, Version > > LoadXmlDelegate
void addResource(IResourcePtr _item)
static Version parse(std::string_view _value)
ElementEnumerator getElementEnumerator()
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))