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

A class that represents a generic collection of arbitrarily-typed resource objects. More...

#include <omResourceSet.h>

Public Member Functions

 ResourceSet ()
 Create a new empty resource set that has no stored resources. More...
 
 ResourceSet (const ResourceSet &other)
 Create a copy of another resource set, copying all of its stored resources. More...
 
virtual ~ResourceSet ()
 Destroy an resource set, deallocating all stored resources. More...
 
ResourceSetoperator= (const ResourceSet &other)
 Assign the contents of one resource set to another, copying all stored resources. More...
 
Size getTypeCount () const
 Return the number of resource types that this resource set contains. More...
 
ResourceTypeSetBasegetType (Index typeIndex)
 Return a pointer to the object that manages the resource type at the specified index. More...
 
const ResourceTypeSetBasegetType (Index typeIndex) const
 Return a pointer to the object that manages the resource type at the specified index. More...
 
Bool getTypeIndex (const ResourceType &type, ResourceLocalID &typeIndex) const
 Get the index of the specified resource type within this resource set. More...
 
template<typename DataType >
Resource< DataType > * getResource ()
 Return a pointer to the first resource that the resource set has for the specified type. More...
 
template<typename DataType >
const Resource< DataType > * getResource () const
 Return a const pointer to the first resource that the resource set has for the specified type. More...
 
template<typename DataType >
Resource< DataType > * getResource (const UTF8String &name)
 Return a pointer to the resource that the resource set has for the specified type and with the given name. More...
 
template<typename DataType >
const Resource< DataType > * getResource (const UTF8String &name) const
 Return a const pointer to the resource that the resource set has for the specified type and with the given name. More...
 
template<typename DataType >
Resource< DataType > * getResource (const ResourceID &identifier)
 Return a const pointer to the resource that the resource set has for the specified type and with the given ID. More...
 
template<typename DataType >
const Resource< DataType > * getResource (const ResourceID &identifier) const
 Return a const pointer to the resource that the resource set has for the specified type and with the given ID. More...
 
template<typename DataType >
Resource< DataType > * getResource (ResourceLocalID localID)
 Return a const pointer to the resource of the templated type at the given index within its type set. More...
 
template<typename DataType >
const Resource< DataType > * getResource (ResourceLocalID localID) const
 Return a const pointer to the resource of the templated type at the given index within its type set. More...
 
void * getResourceData (const ResourceType &type, ResourceLocalID localID) const
 Return a an opaque pointer to the resource data at the given index within its type set. More...
 
OpaqueResource getResource (const ResourceType &type, ResourceLocalID localID) const
 Return an opaque resource at the given local ID within its type set. More...
 
OpaqueResource getResource (ResourceLocalID localTypeID, ResourceLocalID localID) const
 Return an opaque resource at the given local IDs within its type set. More...
 
const ResourceIDgetResourceID (const ResourceType &type, const void *resource) const
 Return a pointer to the ID for the resource with the given type and opaque data pointer. More...
 
template<typename DataType >
Bool getResourceLocalID (const DataType *resource, ResourceLocalID &localID) const
 Get the index within its data type for the resource with the given raw data pointer in the output parameter. More...
 
template<typename DataType >
ResourceLocalID getResourceLocalID (const DataType *resource) const
 Return the index for the resource with the given raw data pointer. More...
 
Bool getResourceLocalID (const ResourceType &type, const void *resource, ResourceLocalID &localID) const
 Get the index for the resource with the given type and opaque data pointer in the output parameter. More...
 
ResourceLocalID getResourceLocalID (const ResourceType &type, const void *resource) const
 Return the index for the resource with the given resource type and raw data pointer. More...
 
Bool getResourceLocalIDs (const ResourceType &type, const void *resource, ResourceLocalID &typeID, ResourceLocalID &localID) const
 Get the type index and local index for the resource with the given type and opaque data pointer in the output parameter. More...
 
template<typename DataType >
ResourceTypeSet< DataType > * getResources ()
 Return a pointer to a set of resources of the specified template type. More...
 
template<typename DataType >
const ResourceTypeSet< DataType > * getResources () const
 Return a const pointer to a set of resources of the specified template type. More...
 
ResourceTypeSetBasegetResources (const ResourceType &type)
 Return a pointer to a set of resources of the specified resource type. More...
 
const ResourceTypeSetBasegetResources (const ResourceType &type) const
 Return a const pointer to a set of resources of the specified resource type. More...
 
const ResourceTypegetResourceType (const ResourceType &type) const
 Return a pointer to a global resource type object that matches the specified resource type. More...
 
template<typename DataType >
Bool addResource (const Resource< DataType > &resource)
 Add the specified resource to this resource set. More...
 
void addResources (const ResourceSet &resources)
 Add all resources from another resource set to this one. More...
 
template<typename DataType >
Bool removeResource (const DataType *resource)
 Remove the specified resource from this resource set if it exists. More...
 
template<typename DataType >
Bool removeResource (const UTF8String &name)
 Remove the resource with the specified name from this resource set if it exists. More...
 
Bool removeResource (const OpaqueResource &resource)
 Remove the specified opaque resource from this resource set. More...
 
template<typename DataType >
Bool removeResources ()
 Remove all resources with the specified resource type from this resource set. More...
 
void clearResources ()
 Remove all resources from this resource set. More...
 
const UTF8String & getName () const
 Return a reference to a string representing the name of this resource set. More...
 
void setName (const UTF8String &newName)
 Return a reference to a string representing the name of this resource set. More...
 
const UTF8String & getDescription () const
 Return a reference to a string representing the name of this resource set. More...
 
void setDescription (const UTF8String &newDescription)
 Return a reference to a string representing the name of this resource set. More...
 

Static Public Attributes

static const ResourceType RESOURCE_TYPE
 The resource type for a resource set. More...
 

Detailed Description

A class that represents a generic collection of arbitrarily-typed resource objects.

Constructor & Destructor Documentation

om::resources::ResourceSet::ResourceSet ( )

Create a new empty resource set that has no stored resources.

om::resources::ResourceSet::ResourceSet ( const ResourceSet other)

Create a copy of another resource set, copying all of its stored resources.

virtual om::resources::ResourceSet::~ResourceSet ( )
virtual

Destroy an resource set, deallocating all stored resources.

Member Function Documentation

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

Assign the contents of one resource set to another, copying all stored resources.

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

Return the number of resource types that this resource set contains.

ResourceTypeSetBase* om::resources::ResourceSet::getType ( Index  typeIndex)
inline

Return a pointer to the object that manages the resource type at the specified index.

const ResourceTypeSetBase* om::resources::ResourceSet::getType ( Index  typeIndex) const
inline

Return a pointer to the object that manages the resource type at the specified index.

Bool om::resources::ResourceSet::getTypeIndex ( const ResourceType type,
ResourceLocalID typeIndex 
) const

Get the index of the specified resource type within this resource set.

template<typename DataType >
Resource<DataType>* om::resources::ResourceSet::getResource ( )
inline

Return a pointer to the first resource that the resource set has for the specified type.

If the resource set does not have any resources for the specified template type, NULL is returned.

template<typename DataType >
const Resource<DataType>* om::resources::ResourceSet::getResource ( ) const
inline

Return a const pointer to the first resource that the resource set has for the specified type.

If the resource set does not have any resources for the specified template type, NULL is returned.

template<typename DataType >
Resource<DataType>* om::resources::ResourceSet::getResource ( const UTF8String &  name)
inline

Return a pointer to the resource that the resource set has for the specified type and with the given name.

If the resource set does not have any resources for the specified template type and a matching name string, NULL is returned.

template<typename DataType >
const Resource<DataType>* om::resources::ResourceSet::getResource ( const UTF8String &  name) const
inline

Return a const pointer to the resource that the resource set has for the specified type and with the given name.

If the resource set does not have any resources for the specified template type and a matching name string, NULL is returned.

template<typename DataType >
Resource<DataType>* om::resources::ResourceSet::getResource ( const ResourceID identifier)
inline

Return a const pointer to the resource that the resource set has for the specified type and with the given ID.

If the resource set does not have any resources for the specified template type and a matching ID, NULL is returned.

template<typename DataType >
const Resource<DataType>* om::resources::ResourceSet::getResource ( const ResourceID identifier) const
inline

Return a const pointer to the resource that the resource set has for the specified type and with the given ID.

If the resource set does not have any resources for the specified template type and a matching ID, NULL is returned.

template<typename DataType >
Resource<DataType>* om::resources::ResourceSet::getResource ( ResourceLocalID  localID)
inline

Return a const pointer to the resource of the templated type at the given index within its type set.

If there is no resource of the templated type or index, NULL is returned.

template<typename DataType >
const Resource<DataType>* om::resources::ResourceSet::getResource ( ResourceLocalID  localID) const
inline

Return a const pointer to the resource of the templated type at the given index within its type set.

If there is no resource of the templated type or index, NULL is returned.

void* om::resources::ResourceSet::getResourceData ( const ResourceType type,
ResourceLocalID  localID 
) const

Return a an opaque pointer to the resource data at the given index within its type set.

If there is no resource of the specified type or index, NULL is returned.

OpaqueResource om::resources::ResourceSet::getResource ( const ResourceType type,
ResourceLocalID  localID 
) const

Return an opaque resource at the given local ID within its type set.

If there is no resource of the specified type or index, a NULL resource is returned.

OpaqueResource om::resources::ResourceSet::getResource ( ResourceLocalID  localTypeID,
ResourceLocalID  localID 
) const

Return an opaque resource at the given local IDs within its type set.

If there is no resource of the specified type or index, a NULL resource is returned.

const ResourceID* om::resources::ResourceSet::getResourceID ( const ResourceType type,
const void *  resource 
) const

Return a pointer to the ID for the resource with the given type and opaque data pointer.

If the resource set does not contain the given resource type or resource, the method fails and NULL is returned.

template<typename DataType >
Bool om::resources::ResourceSet::getResourceLocalID ( const DataType *  resource,
ResourceLocalID localID 
) const
inline

Get the index within its data type for the resource with the given raw data pointer in the output parameter.

If the resource set does not contain the given resource, the method fails and FALSE is returned.

template<typename DataType >
ResourceLocalID om::resources::ResourceSet::getResourceLocalID ( const DataType *  resource) const
inline

Return the index for the resource with the given raw data pointer.

If the resource set does not contain the given resource, the method returns ResourceID::INVALID_LOCAL_ID.

Bool om::resources::ResourceSet::getResourceLocalID ( const ResourceType type,
const void *  resource,
ResourceLocalID localID 
) const

Get the index for the resource with the given type and opaque data pointer in the output parameter.

If the resource set does not contain the given resource type or resource, the method fails and FALSE is returned.

ResourceLocalID om::resources::ResourceSet::getResourceLocalID ( const ResourceType type,
const void *  resource 
) const

Return the index for the resource with the given resource type and raw data pointer.

If the resource set does not contain the given resource, the method returns ResourceID::INVALID_LOCAL_ID.

Bool om::resources::ResourceSet::getResourceLocalIDs ( const ResourceType type,
const void *  resource,
ResourceLocalID typeID,
ResourceLocalID localID 
) const

Get the type index and local index for the resource with the given type and opaque data pointer in the output parameter.

If the resource set does not contain the given resource type or resource, the method fails and FALSE is returned.

template<typename DataType >
ResourceTypeSet<DataType>* om::resources::ResourceSet::getResources ( )
inline

Return a pointer to a set of resources of the specified template type.

If the resource set does not have any resources for the specified template type, NULL is returned.

template<typename DataType >
const ResourceTypeSet<DataType>* om::resources::ResourceSet::getResources ( ) const
inline

Return a const pointer to a set of resources of the specified template type.

If the resource set does not have any resources for the specified template type, NULL is returned.

ResourceTypeSetBase* om::resources::ResourceSet::getResources ( const ResourceType type)

Return a pointer to a set of resources of the specified resource type.

If the resource set does not have any resources for the specified resource type, NULL is returned.

const ResourceTypeSetBase* om::resources::ResourceSet::getResources ( const ResourceType type) const

Return a const pointer to a set of resources of the specified resource type.

If the resource set does not have any resources for the specified resource type, NULL is returned.

const ResourceType* om::resources::ResourceSet::getResourceType ( const ResourceType type) const

Return a pointer to a global resource type object that matches the specified resource type.

If there is no valid resource type, NULL is returned.

template<typename DataType >
Bool om::resources::ResourceSet::addResource ( const Resource< DataType > &  resource)
inline

Add the specified resource to this resource set.

The method returns whether or not adding the resource was successful.

void om::resources::ResourceSet::addResources ( const ResourceSet resources)

Add all resources from another resource set to this one.

template<typename DataType >
Bool om::resources::ResourceSet::removeResource ( const DataType *  resource)
inline

Remove the specified resource from this resource set if it exists.

If the resource set contains a resource that is equal in type and value to the specified resource, the resource is removed and TRUE is returned. Otherwise, FALSE is returned and the resource set is unchanged.

template<typename DataType >
Bool om::resources::ResourceSet::removeResource ( const UTF8String &  name)
inline

Remove the resource with the specified name from this resource set if it exists.

If the resource set contains a resource that is equal in type and has the specified name, the resource is removed and TRUE is returned. Otherwise, FALSE is returned and the resource set is unchanged.

Bool om::resources::ResourceSet::removeResource ( const OpaqueResource resource)

Remove the specified opaque resource from this resource set.

If the resource set contains a resource that is equal in type and has the specified name, the resource is removed and TRUE is returned. Otherwise, FALSE is returned and the resource set is unchanged.

template<typename DataType >
Bool om::resources::ResourceSet::removeResources ( )
inline

Remove all resources with the specified resource type from this resource set.

If the resource set contains any resources that have the specified type, the resources are removed and TRUE is returned. Otherwise, FALSE is returned and the resource set is unchanged.

void om::resources::ResourceSet::clearResources ( )

Remove all resources from this resource set.

const UTF8String& om::resources::ResourceSet::getName ( ) const
inline

Return a reference to a string representing the name of this resource set.

void om::resources::ResourceSet::setName ( const UTF8String &  newName)
inline

Return a reference to a string representing the name of this resource set.

const UTF8String& om::resources::ResourceSet::getDescription ( ) const
inline

Return a reference to a string representing the name of this resource set.

void om::resources::ResourceSet::setDescription ( const UTF8String &  newDescription)
inline

Return a reference to a string representing the name of this resource set.

Member Data Documentation

const ResourceType om::resources::ResourceSet::RESOURCE_TYPE
static

The resource type for a resource set.


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