28 #ifndef _CEGUINamedXMLResourceManager_h_
29 #define _CEGUINamedXMLResourceManager_h_
31 #include "CEGUIEventSet.h"
32 #include "CEGUIString.h"
33 #include "CEGUIExceptions.h"
34 #include "CEGUILogger.h"
35 #include "CEGUIInputEvent.h"
36 #include "CEGUISystem.h"
108 template<
typename T,
typename U>
185 T&
get(
const String& object_name)
const;
210 template<
typename T,
typename U>
212 const String& resource_type) :
213 d_resourceType(resource_type)
218 template<
typename T,
typename U>
224 template<
typename T,
typename U>
226 const String& resource_group,
229 U xml_loader(xml_filename, resource_group);
230 return doExistingObjectAction(xml_loader.getObjectName(),
231 &xml_loader.getObject(), action);
235 template<
typename T,
typename U>
238 typename ObjectRegistry::iterator i(d_objects.find(object_name));
241 if (i == d_objects.end())
248 template<
typename T,
typename U>
253 typename ObjectRegistry::iterator i(d_objects.begin());
254 for (; i != d_objects.end(); ++i)
255 if (i->second == &
object)
263 template<
typename T,
typename U>
266 while (!d_objects.empty())
267 destroyObject(d_objects.begin());
271 template<
typename T,
typename U>
274 typename ObjectRegistry::const_iterator i(d_objects.find(object_name));
276 if (i == d_objects.end())
278 "No object of type '" + d_resourceType +
"' named '" + object_name +
279 "' is present in the collection."));
285 template<
typename T,
typename U>
288 return d_objects.find(object_name) != d_objects.end();
292 template<
typename T,
typename U>
294 typename ObjectRegistry::iterator ob)
297 sprintf(addr_buff,
"(%p)", static_cast<void*>(ob->second));
298 Logger::getSingleton().logEvent(
"Object of type '" + d_resourceType +
299 "' named '" + ob->first +
"' has been destroyed. " +
309 fireEvent(EventResourceDestroyed, args, EventNamespace);
313 template<
typename T,
typename U>
321 if (isDefined(object_name))
326 Logger::getSingleton().logEvent(
"---- Returning existing instance "
327 "of " + d_resourceType +
" named '" + object_name +
"'.");
331 return *d_objects[object_name];
334 Logger::getSingleton().logEvent(
"---- Replacing existing instance "
335 "of " + d_resourceType +
" named '" + object_name +
337 destroy(object_name);
338 event_name = EventResourceReplaced;
344 "NamedXMLResourceManager::checkExistingObjectAction: "
345 "an object of type '" + d_resourceType +
"' named '" +
346 object_name +
"' already exists in the collection."));
351 "NamedXMLResourceManager::checkExistingObjectAction: "
352 "Invalid CEGUI::XMLResourceExistsAction was specified."));
356 event_name = EventResourceCreated;
358 d_objects[object_name] = object;
359 doPostObjectAdditionAction(*
object);
363 fireEvent(event_name, args, EventNamespace);
369 template<
typename T,
typename U>
376 template<
typename T,
typename U>
378 const String& resource_group)
380 std::vector<String> names;
382 getResourceGroupFileNames(names, pattern, resource_group);
384 for (
size_t i = 0; i < num; ++i)
385 create(names[i], resource_group);
392 #endif // end of guard _CEGUINamedXMLResourceManager_h_