Om
1.0.0
A universal framework for multimedia simulation
|
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... | |
ResourceManager & | operator= (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 ResourceFormat & | getFormat (Index formatIndex) const |
Return the resource format that the manager has at the specified index. More... | |
const ResourceType & | getFormatType (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... | |
ResourceSet & | getResources () |
Return a reference to the internal resource set for this manager. More... | |
const ResourceSet & | getResources () 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 ResourceMode & | getMode () 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... | |
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.
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 |
Destroy this resource manager and release all associated resources.
ResourceManager& om::resources::ResourceManager::operator= | ( | const ResourceManager & | other | ) |
Assign the state of another resource manager to this one.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
inline |
Return the number of resource types that this manager can load.
|
inline |
Return the number of resource formats that this manager can load.
|
inline |
Return the resource format that the manager has at the specified index.
|
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.
|
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.
|
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.
|
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.
|
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.
|
inline |
Clear this resource manager's cached resources.
|
inline |
Return the current mode that the resource manager is loading resources in.
|
inline |
Set the current mode that the resource manager is loading resources in.