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

static CL_ResourceManager *create(
         const char *config_file,
        CL_InputSourceProvider *provider = NULL,
        bool read_directly_from_source=false,
        bool delete_inputsource_provider=false)
static CL_ResourceManager *create( const char *file_name, const bool is_datafile )
virtual ~CL_ResourceManager()
virtual void load_all_resources()
virtual void unload_all_resources()
virtual void load_section(const char *section_name)
virtual void unload_section(const char *section_name)
virtual CL_Resource *get_resource(std::string res_id)
virtual std::list<std::string> *get_all_resources()
virtual std::list<std::string> *get_resources_of_type(std::string type_id)
virtual CL_InputSourceProvider *get_resource_provider()

See Also

None


Back to index



This page was built using the Perceps documentation system.