28 #ifndef _CEGUINamedXMLResourceManager_h_
29 #define _CEGUINamedXMLResourceManager_h_
31 #include "CEGUI/EventSet.h"
32 #include "CEGUI/String.h"
33 #include "CEGUI/Exceptions.h"
34 #include "CEGUI/Logger.h"
35 #include "CEGUI/InputEvent.h"
36 #include "CEGUI/System.h"
108 template<
typename T,
typename U>
225 T&
get(
const String& object_name)
const;
252 template<
typename T,
typename U>
254 const String& resource_type) :
255 d_resourceType(resource_type)
260 template<
typename T,
typename U>
266 template<
typename T,
typename U>
272 xml_loader.handleContainer(source);
273 return doExistingObjectAction(xml_loader.getObjectName(),
274 &xml_loader.getObject(), action);
278 template<
typename T,
typename U>
280 const String& resource_group,
285 xml_loader.handleFile(xml_filename, resource_group);
286 return doExistingObjectAction(xml_loader.getObjectName(),
287 &xml_loader.getObject(), action);
291 template<
typename T,
typename U>
297 xml_loader.handleString(source);
298 return doExistingObjectAction(xml_loader.getObjectName(),
299 &xml_loader.getObject(), action);
303 template<
typename T,
typename U>
306 typename ObjectRegistry::iterator i(d_objects.find(object_name));
309 if (i == d_objects.end())
316 template<
typename T,
typename U>
321 typename ObjectRegistry::iterator i(d_objects.begin());
322 for (; i != d_objects.end(); ++i)
323 if (i->second == &
object)
331 template<
typename T,
typename U>
334 while (!d_objects.empty())
335 destroyObject(d_objects.begin());
339 template<
typename T,
typename U>
342 typename ObjectRegistry::const_iterator i(d_objects.find(object_name));
344 if (i == d_objects.end())
346 "No object of type '" + d_resourceType +
"' named '" + object_name +
347 "' is present in the collection."));
353 template<
typename T,
typename U>
356 return d_objects.find(object_name) != d_objects.end();
360 template<
typename T,
typename U>
362 typename ObjectRegistry::iterator ob)
365 sprintf(addr_buff,
"(%p)", static_cast<void*>(ob->second));
366 Logger::getSingleton().logEvent(
"Object of type '" + d_resourceType +
367 "' named '" + ob->first +
"' has been destroyed. " +
373 CEGUI_DELETE_AO ob->second;
377 fireEvent(EventResourceDestroyed, args, EventNamespace);
381 template<
typename T,
typename U>
389 if (isDefined(object_name))
394 Logger::getSingleton().logEvent(
"---- Returning existing instance "
395 "of " + d_resourceType +
" named '" + object_name +
"'.");
397 CEGUI_DELETE_AO object;
399 return *d_objects[object_name];
402 Logger::getSingleton().logEvent(
"---- Replacing existing instance "
403 "of " + d_resourceType +
" named '" + object_name +
405 destroy(object_name);
406 event_name = EventResourceReplaced;
410 CEGUI_DELETE_AO object;
412 "an object of type '" + d_resourceType +
"' named '" +
413 object_name +
"' already exists in the collection."));
416 CEGUI_DELETE_AO object;
418 "Invalid CEGUI::XMLResourceExistsAction was specified."));
422 event_name = EventResourceCreated;
424 d_objects[object_name] = object;
425 doPostObjectAdditionAction(*
object);
429 fireEvent(event_name, args, EventNamespace);
435 template<
typename T,
typename U>
442 template<
typename T,
typename U>
444 const String& resource_group)
446 std::vector<String> names;
448 getResourceGroupFileNames(names, pattern, resource_group);
450 for (
size_t i = 0; i < num; ++i)
451 createFromFile(names[i], resource_group);
458 #endif // end of guard _CEGUINamedXMLResourceManager_h_