Menge
Modular Pedestrian Simulation Framework for Research and Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Static Public Member Functions | Static Protected Attributes | List of all members
Menge::ResourceManager Class Reference

Class to handle management of on-disk resources. More...

#include <ResourceManager.h>

Static Public Member Functions

static ResourcegetResource (const std::string &fileName, Resource *(*reader)(const std::string &), const std::string &suffix)
 Retrieve a resource from the manager. More...
 
static void cleanup ()
 Passes through the resources and removes all unreferenced resources.
 
static bool removeResource (Resource *rsrc)
 Remove the given resource. More...
 

Static Protected Attributes

static ResourceMap _resources
 Mapping from resource name to resource.
 

Detailed Description

Class to handle management of on-disk resources.

Member Function Documentation

Resource * Menge::ResourceManager::getResource ( const std::string &  fileName,
Resource *(*)(const std::string &)  reader,
const std::string &  suffix 
)
static

Retrieve a resource from the manager.

Parameters
fileNameThe name of the file associated with the resource.
readerPointer to a function for parsing the given file and producing a resource instance.
suffixThe string to append to the file name. This allows different types of resources basedon on the same file resource to be distinguished. It is the burden of the programmer to make sure each type provides a unique suffix, otherwise problems will arise between suffix collisions.
Returns
A pointer to the reference, if it is loaded, NULL otherwise. The caller is responsible for knowing what type of resource it should be and test it using a dynamic-cast.
bool Menge::ResourceManager::removeResource ( Resource rsrc)
static

Remove the given resource.

Parameters
rsrcA pointer to the resource to remove.
Returns
True if the pointer is successfully removed, false otherwise. It can fail if the resource doesn't belong to the manager or if the resources reference count is not zero.

The documentation for this class was generated from the following files: