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" 107 template<
typename T,
typename U>
167 T& createFromFile(
const String& xml_filename,
const String& resource_group =
"",
187 T& createFromString(
const String& source,
198 void destroy(
const String& object_name);
209 void destroy(
const T&
object);
224 T&
get(
const String& object_name)
const;
227 bool isDefined(
const String& object_name)
const;
230 void createAll(
const String& pattern,
const String& resource_group);
238 void destroyObject(
typename ObjectRegistry::iterator ob);
240 T& doExistingObjectAction(
const String object_name, T*
object,
243 virtual void doPostObjectAdditionAction(T&
object);
251 template<
typename T,
typename U>
253 const String& resource_type) :
254 d_resourceType(resource_type)
259 template<
typename T,
typename U>
265 template<
typename T,
typename U>
271 xml_loader.handleContainer(source);
273 &xml_loader.getObject(), action);
277 template<
typename T,
typename U>
279 const String& resource_group,
284 xml_loader.handleFile(xml_filename, resource_group);
286 &xml_loader.getObject(), action);
290 template<
typename T,
typename U>
296 xml_loader.handleString(source);
298 &xml_loader.getObject(), action);
302 template<
typename T,
typename U>
305 typename ObjectRegistry::iterator i(
d_objects.find(object_name));
315 template<
typename T,
typename U>
320 typename ObjectRegistry::iterator i(
d_objects.begin());
322 if (i->second == &
object)
330 template<
typename T,
typename U>
338 template<
typename T,
typename U>
341 typename ObjectRegistry::const_iterator i(
d_objects.find(object_name));
345 "No object of type '" +
d_resourceType +
"' named '" + object_name +
346 "' is present in the collection."));
352 template<
typename T,
typename U>
359 template<
typename T,
typename U>
361 typename ObjectRegistry::iterator ob)
364 sprintf(addr_buff,
"(%p)", static_cast<void*>(ob->second));
365 Logger::getSingleton().logEvent(
"Object of type '" +
d_resourceType +
366 "' named '" + ob->first +
"' has been destroyed. " +
372 CEGUI_DELETE_AO ob->second;
380 template<
typename T,
typename U>
393 Logger::getSingleton().logEvent(
"---- Returning existing instance " 396 CEGUI_DELETE_AO object;
401 Logger::getSingleton().logEvent(
"---- Replacing existing instance " 409 CEGUI_DELETE_AO object;
412 object_name +
"' already exists in the collection."));
415 CEGUI_DELETE_AO object;
417 "Invalid CEGUI::XMLResourceExistsAction was specified."));
434 template<
typename T,
typename U>
441 template<
typename T,
typename U>
443 const String& resource_group)
445 std::vector<String> names;
447 getResourceGroupFileNames(names, pattern, resource_group);
449 for (
size_t i = 0; i < num; ++i)
457 #endif // end of guard _CEGUINamedXMLResourceManager_h_ static const String EventResourceCreated
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:66
Exception class used when a request was made for an unknown object.
Definition: cegui/include/CEGUI/Exceptions.h:240
Functor that can be used as comparator in a std::map with String keys. It's faster than using the def...
Definition: cegui/include/CEGUI/String.h:5579
EventArgs based class that is used for notifications regarding resources.
Definition: cegui/include/CEGUI/InputEvent.h:365
static const String EventNamespace
Namespace name for all resource managers.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:59
Useful tracing (object creations etc) information will be logged.
Definition: cegui/include/CEGUI/Logger.h:61
Main namespace for Crazy Eddie's GUI Library.
Definition: cegui/include/CEGUI/Affector.h:42
Exception class used when an attempt is made create a named object of a particular type when an objec...
Definition: cegui/include/CEGUI/Exceptions.h:477
void destroyAll()
Destroy all objects.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:331
virtual void doPostObjectAdditionAction(T &object)
Function called each time a new object is added to the collection.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:435
static const String EventResourceDestroyed
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:73
ResourceProvider * getResourceProvider(void) const
Return a pointer to the ResourceProvider being used within the GUI system.
Definition: System.cpp:458
T & get(const String &object_name) const
Return a reference to the object named object_name.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:339
void createAll(const String &pattern, const String &resource_group)
Create a new T object from files with names matching pattern in resource_group.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:442
T & doExistingObjectAction(const String object_name, T *object, const XMLResourceExistsAction action)
function to enforce XMLResourceExistsAction policy.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:381
Class used as the databuffer for loading files throughout the library.
Definition: cegui/include/CEGUI/DataContainer.h:42
Throw an AlreadyExistsException.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:49
void destroyObject(typename ObjectRegistry::iterator ob)
implementation of object destruction.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:360
std::map< String, T *, StringFastLessCompare CEGUI_MAP_ALLOC(String, T *)> ObjectRegistry
type of collection used to store and manage objects
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:236
NamedXMLResourceManager(const String &resource_type)
Constructor.
Definition: cegui/include/CEGUI/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: cegui/include/CEGUI/NamedXMLResourceManager.h:278
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: cegui/include/CEGUI/NamedXMLResourceManager.h:303
Class that collects together a set of Event objects.
Definition: cegui/include/CEGUI/EventSet.h:64
Destroy the existing instance and replace with the newly loaded one.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:47
virtual void fireEvent(const String &name, EventArgs &args, const String &eventNamespace="")
Fires the named event passing the given EventArgs object.
Definition: cegui/src/EventSet.cpp:151
Templatised manager class that loads and manages named XML based resources.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:108
T & createFromString(const String &source, XMLResourceExistsAction action=XREA_RETURN)
Creates a new T object from a string and adds it to the collection.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:291
Exception class used when some impossible request was made of the system.
Definition: cegui/include/CEGUI/Exceptions.h:298
XMLResourceExistsAction
Possible actions when loading an XML resource that already exists.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:42
static const String EventResourceReplaced
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:80
Do not load the resource, return the existing instance.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:45
implementation class to gather EventSet parts for all template instances.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:55
static System & getSingleton(void)
Return singleton System object.
Definition: System.cpp:566
T & createFromContainer(const RawDataContainer &source, XMLResourceExistsAction action=XREA_RETURN)
Creates a new T object from a RawDataContainer and adds it to the collection.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:266
virtual ~NamedXMLResourceManager()
Destructor.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:260
bool isDefined(const String &object_name) const
Return whether an object named object_name exists.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:353
const String d_resourceType
String holding the text for the resource type managed.
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:245
String class used within the GUI system.
Definition: cegui/include/CEGUI/String.h:62
ObjectRegistry d_objects
the collection of objects
Definition: cegui/include/CEGUI/NamedXMLResourceManager.h:247