Home | All Classes | Grouped Classes | Index | Search

Class CL_ResourceManager

The ClanLib resource manager. More...

Derived from: none
Derived by: none
Group: Core (Resources)

#include <ClanLib/core.h>

Construction:

CL_ResourceManager

Resource Manager constructor.

Attributes:

get_resource

Returns a pointer to the CL_Resource representing the given resource.

get_all_resources

Returns a list of all resources available.

get_resources_of_type

Returns a list of all resources available matching a given type.

get_resource_provider

Returns a pointer to the input source provider, in which all resources are stored.

is_from_source

Returns true if the resources are loaded from source. False if loaded from a datafile.

Operations:

operator =

Copy a resource manager.

add_resources

Add resources from an other resource manager.

remove_resources

Remove resources from an other resource manager.

load_all

Loads all resources into memory.

unload_all

Unloads all resources from memory.

load_section

Loads all resources in a given section into memory.

unload_section

Unloads all resources in a given section into memory.

Implementation:

impl

Pointer to the implementation

Detailed description:

The resource manager is used to retrieve resources from a given resource source.

This can either be a resource script file (used as input to the datafile compiler), or a datafile with all the resources included into one large gzipped resource file.

To speedup loading of resources in a game, you can load entire sections of resources at once. When a resource in the section is requested, it is returned instantly without having to access the disk. This is especially useful to make sure all the game resources are loaded before the game is started.

Resources are normally not retrieved using the get_resource() function. Instead, you should load the resource using the appropiate resource type class. For instance, a surface is easiest loaded like this:

  CL_ResourceManager res_manager("my_datafile.dat", true);
  CL_Surface my_surface("my_surface", &res_manager);
  

Getting the same resource twice won't create a new instance of the resource; they are reference counted.



Questions or comments, write to the
ClanLib mailing list.