AppEasy Core SDK  1.5.0
Cross platform mobile and desktop app and game development SDK - The easy way to make apps
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines
CzXomlResourceManager Class Reference

CzResourceManager manages a collection of resource groups. More...

#include <CzXomlResourceManager.h>

List of all members.

Public Types

typedef CzList< IzXomlResource * >
::iterator 
_Iterator

Public Member Functions

_Iterator begin ()
_Iterator end ()
void setParent (IzXomlResource *scene)
IzXomlResourcegetParent ()
 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.
IzXomlResourcefindResource (unsigned int name_hash, unsigned int type_hash, bool global_search=true)
 Searches for the named resource.
IzXomlResourcefindResource (const char *name, unsigned int type_hash, bool global_search=true)
 Searches for the named resource.
IzXomlResourcefindResource (const char *name, const char *type, bool global_search=true)
 Searches for the named resource.
CzFontfindFontWithFilename (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 IzXomlResourceFindResource (unsigned int name_hash, unsigned int type_hash, IzXomlResource *container=NULL)
 Searches for the named resource.
static IzXomlResourceFindResource (const char *name, unsigned int type_hash, IzXomlResource *container=NULL)
 Searches for the named resource.

Protected Attributes

IzXomlResourceParent
 Parent container scene.
CzList< IzXomlResource * > Resources
 A collection of resources.

Detailed Description

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:

  • Global - The global resource manager contains resources that are global to the entire app and will persist until the resources are manually removed or until the app closes down.
  • Scene local - Scenes have their own local resource manager which manage resources that are local to the scene. When the scene is destroyed, all resources managed by the scene will also be destroyed. This enables you to free up memory by simply managing scenes.
  • Actor local - Some types of resource are local to an actor and will be destroyed when the actor is destroyed. These types include actions, timelines and modifiers.

For optimal searching generally the following types of resources will have their own managers and will not be managed by the resource system:

  • Actions (managed by action managers)
  • Timelines (managed by timeline managers)
  • Actors (managed by scenes)
  • Scenes (managed by the main CzApp singleton)
  • XOML Variables (managed by variable managers)
  • XOML Programs (managed by program managers)

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.


Member Typedef Documentation


Constructor & Destructor Documentation

virtual CzXomlResourceManager::~CzXomlResourceManager ( ) [inline, virtual]

Member Function Documentation

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.

Parameters:
[in]resourceIf non-null, the resource.
Returns:
true if it succeeds, false if it fails.

Clears and destroys all resources.

CzFont * CzXomlResourceManager::findFontWithFilename ( const char *  filename,
bool  global_search = true 
)

Searches for the first font with specified filename.

Parameters:
filenameFilename of the file.
global_searchtrue to do a global search.
Returns:
null if it fails, else the found font with filename.
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.

Parameters:
name_hashThe resource name as a string hash.
type_hashThe resource type as a string hash.
global_searchtrue to do a global search.
Returns:
null if it fails, else the found resource.
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.

Parameters:
nameThe resource name.
type_hashThe resource type as a string hash.
global_searchtrue to do a global search.
Returns:
null if it fails, else the found resource.
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.

Parameters:
nameThe resource name.
typeThe resource type.
global_searchtrue to do a global search.
Returns:
null if it fails, else the found resource.
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.

Parameters:
name_hashThe resource name as a string hash.
type_hashThe resource type as a string hash.
[in]containerIf non-null, the container.
Returns:
null if it fails, else the found resource.
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.

Parameters:
nameThe resource name.
type_hashThe resource type as a string hash.
[in]containerIf non-null, the container.
Returns:
null if it fails, else the found resource.
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.

Parameters:
type_hashThe resource type as a string hash.
global_searchtrue to do a global search.
[out]resources[out] If non-null, the resources found.
Returns:
Number of found resources.
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.

Parameters:
name_hashThe resource name as a string hash.
type_hashThe resource type as a string hash.
[out]resources[out] If non-null, the resources found.
Returns:
Number of found resources.

Removes the resource described by resource.

Removes the specified resource from this resource manager and deletes it from memory.

Parameters:
[in]resourceIf 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.

Parameters:
name_hashThe name of the resource as a string hash.
type_hashThe type of the resource as a string hash.

Removes the tagged resources.

Removes all resources that belong to the specified tag group and deletes them.

Parameters:
tagThe 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.

Parameters:
tag_hashThe group tag name as a string hash.

Member Data Documentation

Parent container scene.

A collection of resources.


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