Om  1.0.0
A universal framework for multimedia simulation
Classes | Public Member Functions | List of all members
om::resources::ResourceManager Class Reference

A class that manages resources for a set of formats that it can handle. More...

#include <omResourceManager.h>

Public Member Functions

 ResourceManager ()
 Create a new empty resource manager with no formats it can manage. More...
 
 ResourceManager (const ResourceManager &other)
 Create a new resource manager that is a copy of the other resource manager. More...
 
virtual ~ResourceManager ()
 Destroy this resource manager and release all associated resources. More...
 
ResourceManageroperator= (const ResourceManager &other)
 Assign the state of another resource manager to this one. More...
 
template<typename DataType >
Resource< DataType > load (const Char *filePath)
 Load a resource object for the specified file path. More...
 
template<typename DataType >
Resource< DataType > load (const UTF8String &filePath)
 Load a resource object for the specified file path. More...
 
template<typename DataType >
Resource< DataType > load (const Path &filePath)
 Load a resource object for the specified file path. More...
 
template<typename DataType >
Resource< DataType > load (const ResourceID &identifier)
 Load a resource object for the specified resource identifier. More...
 
template<typename DataType >
Bool load (Resource< DataType > &resource)
 Load a resource object for the specified resource identifier. More...
 
template<typename DataType >
Resource< DataType > load (const Char *filePath, ResourceSet *resourceSet)
 Load a resource object for the specified file path. More...
 
template<typename DataType >
Resource< DataType > load (const data::UTF8String &filePath, ResourceSet *resourceSet)
 Load a resource object for the specified file path. More...
 
template<typename DataType >
Resource< DataType > load (const Path &filePath, ResourceSet *resourceSet)
 Load a resource object for the specified file path. More...
 
template<typename DataType >
Resource< DataType > load (const ResourceID &identifier, ResourceSet *resourceSet)
 Load a resource object for the specified resource identifier. More...
 
template<typename DataType >
Bool load (Resource< DataType > &resource, ResourceSet *resourceSet)
 Load a resource object for the specified resource identifier. More...
 
void * load (const ResourceID &identifier, ResourceSet &resourceSet)
 Load an opaque resource object for the specified resource identifier into a resource set. More...
 
template<typename DataType >
Bool save (const Char *filePath, const DataType &data, const ResourceSet *resourceSet=((void *) 0))
 Save resource data to the location specified by the given file path. More...
 
template<typename DataType >
Bool save (const UTF8String &filePath, const DataType &data, const ResourceSet *resourceSet=((void *) 0))
 Save resource data to the location specified by the given file path. More...
 
template<typename DataType >
Bool save (const Path &filePath, const DataType &data, const ResourceSet *resourceSet=((void *) 0))
 Save resource data to the location specified by the given file path. More...
 
template<typename DataType >
Bool save (const ResourceID &identifier, const DataType &data, const ResourceSet *resourceSet=((void *) 0))
 Save resource data to the location specified by the given resource ID. More...
 
Bool save (const ResourceID &identifier, const void *data, const ResourceSet &resourceSet)
 Save resource data to the location specified by the given resource ID. More...
 
Size getTypeCount () const
 Return the number of resource types that this manager can load. More...
 
Size getFormatCount () const
 Return the number of resource formats that this manager can load. More...
 
const ResourceFormatgetFormat (Index formatIndex) const
 Return the resource format that the manager has at the specified index. More...
 
const ResourceTypegetFormatType (Index formatIndex) const
 Return the resource type for the format that the manager has at the specified index. More...
 
void addModule (ResourceModule &module)
 Add all of the resource formats from the specified module to this resource manager. More...
 
template<typename DataType >
Bool addFormat (ResourceTypeTranscoder< DataType > *transcoder)
 Add a new resource format to this manager. More...
 
template<typename DataType >
Bool removeFormat (const ResourceFormat &format)
 Remove the transcoder for the templated type and format from this resource manager. More...
 
void clearFormats ()
 Remove all formats from this resource manager. More...
 
ResourceSetgetResources ()
 Return a reference to the internal resource set for this manager. More...
 
const ResourceSetgetResources () const
 Return a const reference to the internal resource set for this manager. More...
 
void clearResources ()
 Clear this resource manager's cached resources. More...
 
const ResourceModegetMode () const
 Return the current mode that the resource manager is loading resources in. More...
 
void setMode (const ResourceMode &newMode)
 Set the current mode that the resource manager is loading resources in. More...
 

Detailed Description

A class that manages resources for a set of formats that it can handle.

A resource manager contains ResourceTranscoder objects that enable it to load and save resources of the corresponding types. A resource manager is able to cache resources that have been previously loaded so that duplicates are not loaded.

Constructor & Destructor Documentation

om::resources::ResourceManager::ResourceManager ( )

Create a new empty resource manager with no formats it can manage.

om::resources::ResourceManager::ResourceManager ( const ResourceManager other)

Create a new resource manager that is a copy of the other resource manager.

virtual om::resources::ResourceManager::~ResourceManager ( )
virtual

Destroy this resource manager and release all associated resources.

Member Function Documentation

ResourceManager& om::resources::ResourceManager::operator= ( const ResourceManager other)

Assign the state of another resource manager to this one.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const Char filePath)
inline

Load a resource object for the specified file path.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const UTF8String &  filePath)
inline

Load a resource object for the specified file path.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const Path filePath)
inline

Load a resource object for the specified file path.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const ResourceID identifier)
inline

Load a resource object for the specified resource identifier.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Bool om::resources::ResourceManager::load ( Resource< DataType > &  resource)
inline

Load a resource object for the specified resource identifier.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const Char filePath,
ResourceSet resourceSet 
)
inline

Load a resource object for the specified file path.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const data::UTF8String filePath,
ResourceSet resourceSet 
)
inline

Load a resource object for the specified file path.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const Path filePath,
ResourceSet resourceSet 
)
inline

Load a resource object for the specified file path.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Resource<DataType> om::resources::ResourceManager::load ( const ResourceID identifier,
ResourceSet resourceSet 
)
inline

Load a resource object for the specified resource identifier.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

template<typename DataType >
Bool om::resources::ResourceManager::load ( Resource< DataType > &  resource,
ResourceSet resourceSet 
)
inline

Load a resource object for the specified resource identifier.

If loaded successfully, the resource is inserted into the resource set parameter if it is not NULL.

void* om::resources::ResourceManager::load ( const ResourceID identifier,
ResourceSet resourceSet 
)

Load an opaque resource object for the specified resource identifier into a resource set.

This function loads a resource without requiring the user to have knowledge of its concrete data type. The resource format and type is inferred from the identifier and then the resource is loaded into the resource set for the inferred data type.

If loaded successfully, the resource is inserted into the resource set parameter and a void pointer to the resource is returned. If loading fails, a NULL pointer is returned.

template<typename DataType >
Bool om::resources::ResourceManager::save ( const Char filePath,
const DataType &  data,
const ResourceSet resourceSet = ((void *)0) 
)
inline

Save resource data to the location specified by the given file path.

The method returns whether or not the resource data was able to be successfully saved.

template<typename DataType >
Bool om::resources::ResourceManager::save ( const UTF8String &  filePath,
const DataType &  data,
const ResourceSet resourceSet = ((void *)0) 
)
inline

Save resource data to the location specified by the given file path.

The method returns whether or not the resource data was able to be successfully saved.

template<typename DataType >
Bool om::resources::ResourceManager::save ( const Path filePath,
const DataType &  data,
const ResourceSet resourceSet = ((void *)0) 
)
inline

Save resource data to the location specified by the given file path.

The method returns whether or not the resource data was able to be successfully saved.

template<typename DataType >
Bool om::resources::ResourceManager::save ( const ResourceID identifier,
const DataType &  data,
const ResourceSet resourceSet = ((void *)0) 
)
inline

Save resource data to the location specified by the given resource ID.

The method returns whether or not the resource data was able to be successfully saved.

Bool om::resources::ResourceManager::save ( const ResourceID identifier,
const void *  data,
const ResourceSet resourceSet 
)

Save resource data to the location specified by the given resource ID.

This function saves a resource without requiring the user to have knowledge of its concrete data type. The resource format and type is inferred from the identifier and then the resource is queried from the resource set for the inferred data type. The resource is then written at the specified location.

The method returns whether or not the resource data was able to be successfully saved.

Size om::resources::ResourceManager::getTypeCount ( ) const
inline

Return the number of resource types that this manager can load.

Size om::resources::ResourceManager::getFormatCount ( ) const
inline

Return the number of resource formats that this manager can load.

const ResourceFormat& om::resources::ResourceManager::getFormat ( Index  formatIndex) const
inline

Return the resource format that the manager has at the specified index.

const ResourceType& om::resources::ResourceManager::getFormatType ( Index  formatIndex) const
inline

Return the resource type for the format that the manager has at the specified index.

void om::resources::ResourceManager::addModule ( ResourceModule module)

Add all of the resource formats from the specified module to this resource manager.

template<typename DataType >
Bool om::resources::ResourceManager::addFormat ( ResourceTypeTranscoder< DataType > *  transcoder)
inline

Add a new resource format to this manager.

The method fails if the format transcoder is NULL or if its format is not valid. The new transcoder replaces any previously existing transcoder for its format.

template<typename DataType >
Bool om::resources::ResourceManager::removeFormat ( const ResourceFormat format)
inline

Remove the transcoder for the templated type and format from this resource manager.

The method returns whether or not the specified format was found and removed.

void om::resources::ResourceManager::clearFormats ( )

Remove all formats from this resource manager.

ResourceSet& om::resources::ResourceManager::getResources ( )
inline

Return a reference to the internal resource set for this manager.

This resource set is used to store resources whenever no other resource set is provided when loading resources. The resources are stored here to avoid being leaked or prematurely released.

const ResourceSet& om::resources::ResourceManager::getResources ( ) const
inline

Return a const reference to the internal resource set for this manager.

This resource set is used to store resources whenever no other resource set is provided when loading resources. The resources are stored here to avoid being leaked or prematurely released.

void om::resources::ResourceManager::clearResources ( )
inline

Clear this resource manager's cached resources.

const ResourceMode& om::resources::ResourceManager::getMode ( ) const
inline

Return the current mode that the resource manager is loading resources in.

void om::resources::ResourceManager::setMode ( const ResourceMode newMode)
inline

Set the current mode that the resource manager is loading resources in.


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