27#ifndef _CEGUINamedXMLResourceManager_h_
28#define _CEGUINamedXMLResourceManager_h_
30#include "CEGUI/EventSet.h"
31#include "CEGUI/String.h"
32#include "CEGUI/Exceptions.h"
33#include "CEGUI/Logger.h"
34#include "CEGUI/InputEvent.h"
35#include "CEGUI/System.h"
107template<
typename T,
typename U>
251template<
typename T,
typename U>
259template<
typename T,
typename U>
265template<
typename T,
typename U>
272 return doExistingObjectAction(
xml_loader.getObjectName(),
277template<
typename T,
typename U>
285 return doExistingObjectAction(
xml_loader.getObjectName(),
290template<
typename T,
typename U>
297 return doExistingObjectAction(
xml_loader.getObjectName(),
302template<
typename T,
typename U>
305 typename ObjectRegistry::iterator
i(d_objects.find(
object_name));
308 if (
i == d_objects.end())
315template<
typename T,
typename U>
320 typename ObjectRegistry::iterator
i(d_objects.begin());
321 for (;
i != d_objects.end(); ++
i)
322 if (
i->second == &
object)
330template<
typename T,
typename U>
333 while (!d_objects.empty())
334 destroyObject(d_objects.begin());
338template<
typename T,
typename U>
341 typename ObjectRegistry::const_iterator
i(d_objects.find(
object_name));
343 if (
i == d_objects.end())
345 "No object of type '" + d_resourceType +
"' named '" +
object_name +
346 "' is present in the collection."));
352template<
typename T,
typename U>
355 return d_objects.find(
object_name) != d_objects.end();
359template<
typename T,
typename U>
361 typename ObjectRegistry::iterator
ob)
365 Logger::getSingleton().logEvent(
"Object of type '" + d_resourceType +
366 "' named '" +
ob->first +
"' has been destroyed. " +
372 CEGUI_DELETE_AO
ob->second;
376 fireEvent(EventResourceDestroyed,
args, EventNamespace);
380template<
typename T,
typename U>
393 Logger::getSingleton().logEvent(
"---- Returning existing instance "
394 "of " + d_resourceType +
" named '" +
object_name +
"'.");
401 Logger::getSingleton().logEvent(
"---- Replacing existing instance "
402 "of " + d_resourceType +
" named '" +
object_name +
411 "an object of type '" + d_resourceType +
"' named '" +
412 object_name +
"' already exists in the collection."));
417 "Invalid CEGUI::XMLResourceExistsAction was specified."));
424 doPostObjectAdditionAction(*
object);
434template<
typename T,
typename U>
441template<
typename T,
typename U>
445 std::vector<String>
names;
449 for (
size_t i = 0;
i <
num; ++
i)
Exception class used when an attempt is made create a named object of a particular type when an objec...
Definition Exceptions.h:484
Interface providing event signaling and handling.
Definition EventSet.h:167
Exception class used when some impossible request was made of the system.
Definition Exceptions.h:305
Templatised manager class that loads and manages named XML based resources.
Definition NamedXMLResourceManager.h:109
virtual void doPostObjectAdditionAction(T &object)
Function called each time a new object is added to the collection.
Definition NamedXMLResourceManager.h:435
T & get(const String &object_name) const
Return a reference to the object named object_name.
Definition NamedXMLResourceManager.h:339
T & createFromContainer(const RawDataContainer &source, XMLResourceExistsAction action=XREA_RETURN)
Creates a new T object from a RawDataContainer and adds it to the collection.
Definition NamedXMLResourceManager.h:266
void destroyObject(typename ObjectRegistry::iterator ob)
implementation of object destruction.
Definition NamedXMLResourceManager.h:360
void destroy(const String &object_name)
Destroy the object named object_name, or do nothing if such an object does not exist in the collectio...
Definition NamedXMLResourceManager.h:303
NamedXMLResourceManager(const String &resource_type)
Constructor.
Definition NamedXMLResourceManager.h:252
T & createFromFile(const String &xml_filename, const String &resource_group="", XMLResourceExistsAction action=XREA_RETURN)
Creates a new T object from an XML file and adds it to the collection.
Definition NamedXMLResourceManager.h:278
const String d_resourceType
String holding the text for the resource type managed.
Definition NamedXMLResourceManager.h:245
std::map< String, T *, StringFastLessCompare CEGUI_MAP_ALLOC(String, T *)> ObjectRegistry
type of collection used to store and manage objects
Definition NamedXMLResourceManager.h:236
T & createFromString(const String &source, XMLResourceExistsAction action=XREA_RETURN)
Creates a new T object from a string and adds it to the collection.
Definition NamedXMLResourceManager.h:291
void createAll(const String &pattern, const String &resource_group)
Create a new T object from files with names matching pattern in resource_group.
Definition NamedXMLResourceManager.h:442
ObjectRegistry d_objects
the collection of objects
Definition NamedXMLResourceManager.h:247
void destroyAll()
Destroy all objects.
Definition NamedXMLResourceManager.h:331
virtual ~NamedXMLResourceManager()
Destructor.
Definition NamedXMLResourceManager.h:260
bool isDefined(const String &object_name) const
Return whether an object named object_name exists.
Definition NamedXMLResourceManager.h:353
T & doExistingObjectAction(const String object_name, T *object, const XMLResourceExistsAction action)
function to enforce XMLResourceExistsAction policy.
Definition NamedXMLResourceManager.h:381
void destroy(const T &object)
Destroy the object object, or do nothing if such an object does not exist in the collection.
Definition NamedXMLResourceManager.h:316
Class used as the databuffer for loading files throughout the library.
Definition DataContainer.h:44
EventArgs based class that is used for notifications regarding resources.
Definition InputEvent.h:366
implementation class to gather EventSet parts for all template instances.
Definition NamedXMLResourceManager.h:56
static const String EventNamespace
Namespace name for all resource managers.
Definition NamedXMLResourceManager.h:59
static const String EventResourceCreated
Definition NamedXMLResourceManager.h:66
static const String EventResourceReplaced
Definition NamedXMLResourceManager.h:80
static const String EventResourceDestroyed
Definition NamedXMLResourceManager.h:73
String class used within the GUI system.
Definition String.h:64
static System & getSingleton(void)
Return singleton System object.
base class for properties able to do native set/get
Definition TypedProperty.h:50
Exception class used when a request was made for an unknown object.
Definition Exceptions.h:247
Main namespace for Crazy Eddie's GUI Library.
Definition arch_overview.dox:1
XMLResourceExistsAction
Possible actions when loading an XML resource that already exists.
Definition NamedXMLResourceManager.h:43
@ XREA_THROW
Throw an AlreadyExistsException.
Definition NamedXMLResourceManager.h:49
@ XREA_RETURN
Do not load the resource, return the existing instance.
Definition NamedXMLResourceManager.h:45
@ XREA_REPLACE
Destroy the existing instance and replace with the newly loaded one.
Definition NamedXMLResourceManager.h:47
@ Informative
Useful tracing (object creations etc) information will be logged.
Definition Logger.h:61
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition String.h:5580