Om
1.0.0
A universal framework for multimedia simulation
|
A class that encapsulates a handle to resource data. More...
#include <omResource.h>
Public Types | |
typedef lang::Function< lang::Shared< DataType > const ResourceID &) > | LoadCallback |
Define the type for a resource loading callback function. More... | |
Public Member Functions | |
Resource () | |
Create a new default resource with no data and no resource identifier or loader. More... | |
Resource (const lang::Shared< DataType > &newData) | |
Create a new resource for the specified data pointer. More... | |
Resource (const lang::Shared< DataType > &newData, const ResourceID &newIdentifier) | |
Create a new resource for the specified data that is associated with the specified unique identifier. More... | |
Resource (const ResourceID &newIdentifier) | |
Create a new resource for the specified unique resource identifier. More... | |
Resource (const ResourceID &newIdentifier, const LoadCallback &newLoadCallback) | |
Create a new resource for the specified unique resource identifier using the specified loader object. More... | |
Resource (const Resource &other) | |
~Resource () | |
Resource & | operator= (const Resource &other) |
Bool | operator== (const Resource &other) const |
Return whether or not this resource refers to the same resource as another. More... | |
Bool | operator!= (const Resource &other) const |
Return whether or not this resource refers to a different resource than another. More... | |
lang::Shared< DataType > | getData () const |
Return a pointer to the data associated with this resource. More... | |
void | setData (const lang::Shared< DataType > &newData) |
Set a pointer to the data associated with this resource. More... | |
DataType * | getPointer () const |
Return a pointer to the data associated with this resource. More... | |
operator DataType * () const | |
Cast this Resource object to a raw pointer. More... | |
template<typename U > | |
operator U * () const | |
Cast this Resource object to a raw pointer of a different type to allow polymorphism. More... | |
operator lang::Shared< DataType > () const | |
Cast this Resource object to a reference-counted pointer. More... | |
DataType & | operator* () const |
Return a reference to the data associated with this resource. More... | |
DataType * | operator-> () const |
Return a pointer to the data associated with this resource. More... | |
Bool | hasID () const |
Return whether or not this resource has a unique identifier associated with it. More... | |
ResourceID * | getID () const |
Return a pointer to the unique identifier associated with this resource. More... | |
void | setID (const ResourceID &newID) |
Set the unique identifier associated with this resource. More... | |
const data::UTF8String * | getName () const |
Return a pointer to the name associated with this resource. More... | |
void | setName (const data::UTF8String &newName) |
Set the name associated with this resource. More... | |
Bool | hadLoadCallback () const |
Return whether or not this resource has a ResourceLoader object associated with it. More... | |
const LoadCallback * | getLoadCallback () const |
Return a pointer to the resource loading callback function associated with this resource. More... | |
void | setLoadCallback (const LoadCallback &newLoadCallback) |
Set the resource loading callback function associated with this resource. More... | |
Bool | load () const |
Attempt to load the data for this resource if necessary. More... | |
void | release () |
Release the data assoicated with this resource, but keep the same resource ID and loader. More... | |
Bool | isNull () const |
Return whether or not the data associated with this resource is currently NULL. More... | |
Bool | isSet () const |
Return whether or not the data associated with this resource is currently set. More... | |
Size | getReferenceCount () const |
Return the number of shared references that there are to this resource's data. More... | |
Static Public Member Functions | |
static Resource | construct () |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 > | |
static Resource | construct (P1 p1) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 , typename P2 > | |
static Resource | construct (P1 p1, P2 p2) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 , typename P2 , typename P3 > | |
static Resource | construct (P1 p1, P2 p2, P3 p3) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 , typename P2 , typename P3 , typename P4 > | |
static Resource | construct (P1 p1, P2 p2, P3 p3, P4 p4) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 > | |
static Resource | construct (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 > | |
static Resource | construct (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
template<typename P1 , typename P2 , typename P3 , typename P4 , typename P5 , typename P6 , typename P7 > | |
static Resource | construct (P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7) |
Construct a resource object of the templated type with the specified arguments for its constructor. More... | |
A class that encapsulates a handle to resource data.
The class allows the user to either load the resource data manually, or to provide a unique identifier and ResourceLoader object to defer loading the resource until it is needed.
typedef lang::Function< lang::Shared<DataType> const ResourceID& ) > om::resources::Resource< DataType >::LoadCallback |
Define the type for a resource loading callback function.
|
inline |
Create a new default resource with no data and no resource identifier or loader.
The created resource is essentially unuseable and can be used to indicate an invalid resource or a resource that has not yet been set.
|
inline |
Create a new resource for the specified data pointer.
If the specified data pointer is NULL, the resource is unusable because it has no way to load any data for the resource.
|
inline |
Create a new resource for the specified data that is associated with the specified unique identifier.
If the specified data pointer is NULL, the resource is unusable because it has no way to load the resource associated with the given ID.
|
inline |
Create a new resource for the specified unique resource identifier.
|
inline |
Create a new resource for the specified unique resource identifier using the specified loader object.
A resource created using this constructor will lazily load the resource when it is first dereferenced. The specified ID is used to load the resource using the given ResourceLoader object. If the loader object pointer is NULL, the new resource will be useless because it has no way to load any data for the resource.
|
inline |
|
inline |
|
inline |
|
inline |
Return whether or not this resource refers to the same resource as another.
This operator returns TRUE if the data pointer they refer to is equal, or if they both have the same resource identifier/loader. Otherwise FALSE is returned.
|
inline |
Return whether or not this resource refers to a different resource than another.
This operator returns FALSE if the data pointer they refer to is equal, or if they both have the same resource identifier/loader. Otherwise TRUE is returned.
|
inline |
Return a pointer to the data associated with this resource.
The method can return NULL if the resource's data has not yet been loaded.
|
inline |
Set a pointer to the data associated with this resource.
|
inline |
Return a pointer to the data associated with this resource.
The method can return NULL if the resource's data has not yet been loaded.
|
inline |
Cast this Resource object to a raw pointer.
|
inline |
Cast this Resource object to a raw pointer of a different type to allow polymorphism.
|
inline |
Cast this Resource object to a reference-counted pointer.
|
inline |
Return a reference to the data associated with this resource.
This operator dereferences the data for the resource. If the data pointer is currently NULL, the resource attempts to use the associated resource loader to load the resource data. An assertion is raised if there is no identifier or loader for the resource if the data is NULL.
|
inline |
Return a pointer to the data associated with this resource.
This operator dereferences the data for the resource. If the data pointer is currently NULL, the resource attempts to use the associated resource loader to load the resource data. An assertion is raised if there is no identifier or loader for the resource if the data is NULL.
|
inline |
Return whether or not this resource has a unique identifier associated with it.
|
inline |
Return a pointer to the unique identifier associated with this resource.
If the resource has no identifier associated with it, NULL is returned.
|
inline |
Set the unique identifier associated with this resource.
|
inline |
Return a pointer to the name associated with this resource.
|
inline |
Set the name associated with this resource.
|
inline |
Return whether or not this resource has a ResourceLoader object associated with it.
|
inline |
Return a pointer to the resource loading callback function associated with this resource.
If the resource has no callback function associated with it, NULL is returned.
|
inline |
Set the resource loading callback function associated with this resource.
If the resource has no callback function associated with it, an assertion is raised.
|
inline |
Attempt to load the data for this resource if necessary.
This method tries to ensure that the resource data is loaded and available for use. If the data is already loaded, the method returns TRUE. Otherwise, the method loads the data using the resource's ID and loader object and returns TRUE. If there is no loader or ID for this resource, FALSE is returned, indicating that the resource was unable to be loaded.
|
inline |
Release the data assoicated with this resource, but keep the same resource ID and loader.
This method just releases the reference to the data. If other resource objects reference the same data, the data is not deallocated until they all release their data.
|
inline |
Return whether or not the data associated with this resource is currently NULL.
The data can be NULL if the resource has not yet been loaded, or if the resource is itself invalid.
|
inline |
Return whether or not the data associated with this resource is currently set.
The data can be NULL if the resource has not yet been loaded, or if the resource is itself invalid.
|
inline |
Return the number of shared references that there are to this resource's data.
If the returned value is 1, this means that this resource is the only object which owns the data associated with it.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.
|
inlinestatic |
Construct a resource object of the templated type with the specified arguments for its constructor.