19 template <> ResourceManager* Singleton<ResourceManager>::msInstance =
nullptr;
20 template <>
const char* Singleton<ResourceManager>::mClassTypeName =
"ResourceManager";
24 mCategoryName(
"Resource"),
25 mXmlListTagName(
"List")
55 mMapLoadXmlDelegate.clear();
58 mIsInitialise =
false;
72 while (root.
next(mCategoryName))
75 std::string type, 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,
"dublicate resource name '" << name <<
"'");
95 mRemovedResoures.push_back((*item).second);
96 mResources.erase(item);
102 mResources[name] = resource;
110 while (node.
next(mXmlListTagName))
114 MYGUI_LOG(Info,
"Load ini file '" << source <<
"'");
121 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(_key);
122 MYGUI_ASSERT(iter == mMapLoadXmlDelegate.end(),
"name delegate is exist");
128 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(_key);
129 if (iter != mMapLoadXmlDelegate.end()) mMapLoadXmlDelegate.erase(iter);
132 bool ResourceManager::_loadImplement(
const std::string& _file,
bool _match,
const std::string& _type,
const std::string& _instance)
137 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', not found");
144 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', " << doc.getLastError());
149 if ( (
nullptr == root) || (root->getName() !=
"MyGUI") )
151 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', tag 'MyGUI' not found");
156 if (root->findAttribute(
"type", type))
159 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type);
160 if (iter != mMapLoadXmlDelegate.end())
162 if ((!_match) || (type == _type))
163 (*iter).second(root, _file, version);
166 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', type '" << _type <<
"' not found");
172 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', delegate for type '" << type <<
"'not found");
180 while (node.next(
"MyGUI"))
182 if (node->findAttribute(
"type", type))
185 MapLoadXmlDelegate::iterator iter = mMapLoadXmlDelegate.find(type);
186 if (iter != mMapLoadXmlDelegate.end())
188 (*iter).second(node.current(), _file, version);
192 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', delegate for type '" << type <<
"'not found");
197 MYGUI_LOG(Error, _instance <<
" : '" << _file <<
"', tag 'type' not found");
213 if (_item ==
nullptr)
218 MapResource::iterator item = mResources.find(_item->
getResourceName());
219 if (item != mResources.end())
220 mResources.erase(item);
226 return mResources.find(_name) != mResources.end();
231 MapResource::const_iterator item = mResources.find(_name);
232 return (item == mResources.end()) ?
nullptr : item->second;
238 MYGUI_ASSERT(result || !_throw,
"Resource '" << _name <<
"' not found");
244 MapResource::const_iterator item = mResources.find(_name);
245 if (item != mResources.end())
248 mResources.erase(item->first);
256 for (MapResource::iterator item = mResources.begin(); item != mResources.end(); ++ item)
260 for (VectorResource::iterator item = mRemovedResoures.begin(); item != mRemovedResoures.end(); ++ item)
262 mRemovedResoures.clear();
272 return mResources.size();
277 return mCategoryName;