AppEasy Core SDK
1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
|
CzResourceManager manages a collection of resource groups. More...
#include <CzXomlResourceManager.h>
Public Types | |
typedef CzList< IzXomlResource * > ::iterator | _Iterator |
Public Member Functions | |
_Iterator | begin () |
_Iterator | end () |
void | setParent (IzXomlResource *scene) |
IzXomlResource * | getParent () |
CzXomlResourceManager () | |
virtual | ~CzXomlResourceManager () |
bool | addResource (IzXomlResource *resource) |
Adds a resource to the resource manager. | |
void | removeResource (IzXomlResource *resource) |
Removes the resource described by resource. | |
void | removeResource (unsigned int name_hash, unsigned int type_hash) |
Removes the resource described by resource. | |
void | removeTaggedResources (const char *tag) |
Removes the tagged resources. | |
void | removeTaggedResources (unsigned int tag_hash) |
Removes the tagged resources. | |
int | findResourcesOfType (unsigned int type_hash, bool global_search, CzVector< IzXomlResource * > &resources) |
Buiilds a list of resources of the specified type. | |
IzXomlResource * | findResource (unsigned int name_hash, unsigned int type_hash, bool global_search=true) |
Searches for the named resource. | |
IzXomlResource * | findResource (const char *name, unsigned int type_hash, bool global_search=true) |
Searches for the named resource. | |
IzXomlResource * | findResource (const char *name, const char *type, bool global_search=true) |
Searches for the named resource. | |
CzFont * | findFontWithFilename (const char *filename, bool global_search=true) |
Searches for the first font with specified filename. | |
void | clearResources () |
Clears and destroys all resources. | |
Static Public Member Functions | |
static int | FindResourcesOfType (unsigned int type_hash, IzXomlResource *container, CzVector< IzXomlResource * > &resources) |
Builda a list of resources of the specified type. | |
static IzXomlResource * | FindResource (unsigned int name_hash, unsigned int type_hash, IzXomlResource *container=NULL) |
Searches for the named resource. | |
static IzXomlResource * | FindResource (const char *name, unsigned int type_hash, IzXomlResource *container=NULL) |
Searches for the named resource. | |
Protected Attributes | |
IzXomlResource * | Parent |
Parent container scene. | |
CzList< IzXomlResource * > | Resources |
A collection of resources. |
CzResourceManager manages a collection of resource groups.
The CzXomlResourceManager manages the lifetime of a collection of IzXomlResource derived resources. When the manager is deleted all resources contained with the resource manager will be destroyed.
Resource management is split into 3 types:
For optimal searching generally the following types of resources will have their own managers and will not be managed by the resource system:
To access a scnes resource manager call CzScene::getResourceManager() To access the global resource managers resources use the CZ_GLOBAL_RESOURCE_MANAGER macro or call CZ_GLOBAL_RESOURCES->getResourceManager()
For more information on the global resource manager see CzGlobalResources.
typedef CzList<IzXomlResource*>::iterator CzXomlResourceManager::_Iterator |
CzXomlResourceManager::CzXomlResourceManager | ( | ) | [inline] |
virtual CzXomlResourceManager::~CzXomlResourceManager | ( | ) | [inline, virtual] |
bool CzXomlResourceManager::addResource | ( | IzXomlResource * | resource | ) |
Adds a resource to the resource manager.
Adds the specified resource to this resource manager and manages it. If this resource manager is later deleted then so will any of its managed resources. Note that you should not add the same resource to multiple resource managers as the system will attempt to clean them up multiple times.
[in] | resource | If non-null, the resource. |
_Iterator CzXomlResourceManager::begin | ( | ) | [inline] |
Clears and destroys all resources.
_Iterator CzXomlResourceManager::end | ( | ) | [inline] |
CzFont * CzXomlResourceManager::findFontWithFilename | ( | const char * | filename, |
bool | global_search = true |
||
) |
Searches for the first font with specified filename.
filename | Filename of the file. |
global_search | true to do a global search. |
IzXomlResource * CzXomlResourceManager::findResource | ( | unsigned int | name_hash, |
unsigned int | type_hash, | ||
bool | global_search = true |
||
) |
Searches for the named resource.
Searches the resource manager for the named resource of the specified type. If global_search is true and the resource was not found in this resource manager then the global resource manager will also be searched.
name_hash | The resource name as a string hash. |
type_hash | The resource type as a string hash. |
global_search | true to do a global search. |
IzXomlResource * CzXomlResourceManager::findResource | ( | const char * | name, |
unsigned int | type_hash, | ||
bool | global_search = true |
||
) |
Searches for the named resource.
Searches the resource manager for the named resource of the specified type. If global_search is true and the resource was not found in this resource manager then the global resource manager will also be searched.
name | The resource name. |
type_hash | The resource type as a string hash. |
global_search | true to do a global search. |
IzXomlResource * CzXomlResourceManager::findResource | ( | const char * | name, |
const char * | type, | ||
bool | global_search = true |
||
) |
Searches for the named resource.
Searches the resource manager for the named resource of the specified type. If global_search is true and the resource was not found in this resource manager then the global resource manager will also be searched.
name | The resource name. |
type | The resource type. |
global_search | true to do a global search. |
IzXomlResource * CzXomlResourceManager::FindResource | ( | unsigned int | name_hash, |
unsigned int | type_hash, | ||
IzXomlResource * | container = NULL |
||
) | [static] |
Searches for the named resource.
Static method that searches the supplied containers resource manager for the named resource of the specified type. If the resource was not found in this resource manager then the global resource manager will also be searched.
name_hash | The resource name as a string hash. | |
type_hash | The resource type as a string hash. | |
[in] | container | If non-null, the container. |
IzXomlResource * CzXomlResourceManager::FindResource | ( | const char * | name, |
unsigned int | type_hash, | ||
IzXomlResource * | container = NULL |
||
) | [static] |
Searches for the named resource.
Static method that searches the supplied containers resource manager for the named resource of the specified type. If the resource was not found in this resource manager then the global resource manager will also be searched.
name | The resource name. | |
type_hash | The resource type as a string hash. | |
[in] | container | If non-null, the container. |
int CzXomlResourceManager::findResourcesOfType | ( | unsigned int | type_hash, |
bool | global_search, | ||
CzVector< IzXomlResource * > & | resources | ||
) |
Buiilds a list of resources of the specified type.
Searches the resource manager for resource of the specified type adding them to the supplied list. If global_search is true and the resource was not found in this resource manager then the global resource manager will also be searched.
type_hash | The resource type as a string hash. | |
global_search | true to do a global search. | |
[out] | resources | [out] If non-null, the resources found. |
int CzXomlResourceManager::FindResourcesOfType | ( | unsigned int | type_hash, |
IzXomlResource * | container, | ||
CzVector< IzXomlResource * > & | resources | ||
) | [static] |
Builda a list of resources of the specified type.
Searches the resource manager for resource of the specified type adding them to the supplied list. If global_search is true and the resource was not found in this resource manager then the global resource manager will also be searched.
name_hash | The resource name as a string hash. | |
type_hash | The resource type as a string hash. | |
[out] | resources | [out] If non-null, the resources found. |
IzXomlResource* CzXomlResourceManager::getParent | ( | ) | [inline] |
void CzXomlResourceManager::removeResource | ( | IzXomlResource * | resource | ) |
Removes the resource described by resource.
Removes the specified resource from this resource manager and deletes it from memory.
[in] | resource | If non-null, the resource. |
void CzXomlResourceManager::removeResource | ( | unsigned int | name_hash, |
unsigned int | type_hash | ||
) |
Removes the resource described by resource.
Removes the named resource of the specified type from this resource manager and deletes it from memory.
name_hash | The name of the resource as a string hash. |
type_hash | The type of the resource as a string hash. |
void CzXomlResourceManager::removeTaggedResources | ( | const char * | tag | ) |
Removes the tagged resources.
Removes all resources that belong to the specified tag group and deletes them.
tag | The tag name. |
void CzXomlResourceManager::removeTaggedResources | ( | unsigned int | tag_hash | ) |
Removes the tagged resources.
Removes all resources that belong to the specified tag group and deletes them.
tag_hash | The group tag name as a string hash. |
void CzXomlResourceManager::setParent | ( | IzXomlResource * | scene | ) | [inline] |
IzXomlResource* CzXomlResourceManager::Parent [protected] |
Parent container scene.
CzList<IzXomlResource*> CzXomlResourceManager::Resources [protected] |
A collection of resources.