ClanSoft logo
ClanSoft logo

    CL_ResourceManager

The ClanLib resource manager.

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 = CL_Res_Surface::load("my_surface", res_manager);
 

Getting the same resource twice won't create a new instance of the resource, but you will still have to clean up the resource after yourself. In other words: If you load a resource twice, you only have to delete it once.

Class members

CL_ResourceManager(
        const char *config_file,
        CL_InputSourceProvider *provider = NULL,
        bool read_directly_from_source=false,
        bool delete_inputsource_provider=false)
CL_ResourceManager( const char *file_name, const bool is_datafile )
CL_ResourceManager( const char *file_name, const bool is_datafile )
virtual ~CL_ResourceManager()
bool load_all_resources()
bool load_section(const char *section_name)
CL_Resource *get_resource(CL_String res_id)
CL_List<CL_String> *get_all_resources()
CL_List<CL_String> *get_resources_of_type(CL_String type_id)
CL_InputSourceProvider *get_resource_provider()

See Also

None


Back to index



This page was built using the Perceps documentation system.