23 mCategoryName(
"Resource"),
24 mXmlListTagName(
"List"),
25 mSingletonHolder(
this)
55 mMapLoadXmlDelegate.clear();
58 mIsInitialise =
false;
75 std::string type, name;
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 mRemovedResoures.push_back((*item).second);
96 mResources.erase(item);
113 if (!
node->findAttribute(
"file",
source))
continue;
121 MapLoadXmlDelegate::iterator
iter = mMapLoadXmlDelegate.find(
_key);
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)
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");
207 if (!
_item->getResourceName().empty())
213 if (
_item ==
nullptr)
216 if (!
_item->getResourceName().empty())
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;
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;
#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()
const std::string & getCategoryName() const
Enumerator< MapResource > EnumeratorPtr
IResource * findByName(const std::string &_name) const
void loadFromXmlNode(xml::ElementPtr _node, const std::string &_file, Version _version)
delegates::CDelegate3< xml::ElementPtr, const std::string &, Version > LoadXmlDelegate
void removeResource(IResourcePtr _item)
IResource * getByName(const std::string &_name, bool _throw=true) const
EnumeratorPtr getEnumerator() const
bool removeByName(const std::string &_name)
bool load(const std::string &_file)
void unregisterLoadXmlDelegate(const std::string &_key)
bool isExist(const std::string &_name) const
static const char * getClassTypeName()
LoadXmlDelegate & registerLoadXmlDelegate(const std::string &_key)
void addResource(IResourcePtr _item)
static Version parse(const std::string &_value)
ElementEnumerator getElementEnumerator()
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))