23 mCategoryName(
"Resource"),
24 mXmlListTagName(
"List"),
25 mSingletonHolder(this)
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,
"duplicate 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;
#define MYGUI_ASSERT(exp, dest)
#define MYGUI_LOG(level, text)
virtual IDataStream * getData(const std::string &_name) const =0
static DataManager & getInstance()
void unregisterFactory(const std::string &_category, const std::string &_type)
static FactoryManager & getInstance()
void registerFactory(const std::string &_category, const std::string &_type, Delegate::IDelegate *_delegate)
IObject * createObject(const std::string &_category, const std::string &_type)
Type * castType(bool _throw=true)
const std::string & getResourceName() const
void deserialization(xml::ElementPtr _node, Version _version) override
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()
bool findAttribute(const std::string &_name, std::string &_value)
delegates::DelegateFunction< Args... > * newDelegate(void(*_func)(Args... args))
MYGUI_SINGLETON_DEFINITION(ClipboardManager)