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"
93 template<
typename T,
typename U>
170 T&
get(
const String& object_name)
const;
195 template<
typename T,
typename U>
197 const String& resource_type) :
198 d_resourceType(resource_type)
203 template<
typename T,
typename U>
209 template<
typename T,
typename U>
211 const String& resource_group,
214 U xml_loader(xml_filename, resource_group);
215 return doExistingObjectAction(xml_loader.getObjectName(),
216 &xml_loader.getObject(), action);
220 template<
typename T,
typename U>
223 typename ObjectRegistry::iterator i(d_objects.find(object_name));
226 if (i == d_objects.end())
233 template<
typename T,
typename U>
238 typename ObjectRegistry::iterator i(d_objects.begin());
239 for (; i != d_objects.end(); ++i)
240 if (i->second == &
object)
248 template<
typename T,
typename U>
251 while (!d_objects.empty())
252 destroyObject(d_objects.begin());
256 template<
typename T,
typename U>
259 typename ObjectRegistry::const_iterator i(d_objects.find(object_name));
261 if (i == d_objects.end())
263 "No object of type '" + d_resourceType +
"' named '" + object_name +
264 "' is present in the collection.");
270 template<
typename T,
typename U>
273 return d_objects.find(object_name) != d_objects.end();
277 template<
typename T,
typename U>
279 typename ObjectRegistry::iterator ob)
282 sprintf(addr_buff,
"(%p)", static_cast<void*>(ob->second));
283 Logger::getSingleton().logEvent(
"Object of type '" + d_resourceType +
284 "' named '" + ob->first +
"' has been destroyed. " +
294 fireEvent(EventResourceDestroyed, args, EventNamespace);
298 template<
typename T,
typename U>
306 if (isDefined(object_name))
311 Logger::getSingleton().logEvent(
"---- Returning existing instance "
312 "of " + d_resourceType +
" named '" + object_name +
"'.");
316 return *d_objects[object_name];
319 Logger::getSingleton().logEvent(
"---- Replacing existing instance "
320 "of " + d_resourceType +
" named '" + object_name +
322 destroy(object_name);
323 event_name = EventResourceReplaced;
329 "NamedXMLResourceManager::checkExistingObjectAction: "
330 "an object of type '" + d_resourceType +
"' named '" +
331 object_name +
"' already exists in the collection.");
336 "NamedXMLResourceManager::checkExistingObjectAction: "
337 "Invalid CEGUI::XMLResourceExistsAction was specified.");
341 event_name = EventResourceCreated;
343 d_objects[object_name] = object;
344 doPostObjectAdditionAction(*
object);
348 fireEvent(event_name, args, EventNamespace);
354 template<
typename T,
typename U>
361 template<
typename T,
typename U>
363 const String& resource_group)
365 std::vector<String> names;
367 getResourceGroupFileNames(names, pattern, resource_group);
369 for (
size_t i = 0; i < num; ++i)
370 create(names[i], resource_group);
377 #endif // end of guard _CEGUINamedXMLResourceManager_h_