NAME
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()
MEMBERS WITH DESCRIPTIONS
- static CL_ResourceManager *create(
-
const char *config_file, CL_InputSourceProvider *provider = NULL, bool read_directly_from_source=false, bool delete_inputsource_provider=false)
Parameters: config_file - the name of the file in which the resources are defined provider - the optional inputprovider in which, the resource file is stored read_directly_from_source - if true, any resources are loaded directly from their source, meaning that any datafile-directive is ignored.
Description:
Resource Manager constructor.
- static CL_ResourceManager *create(
-
const char *file_name, const bool is_datafile )
Parameters: file_name - the name of the file to open is_datafile - indicates if the file is a scriptfile or a datafile
Description:
Resource Manager constructor.
- virtual ~CL_ResourceManager()
-
Description:
- virtual void load_all_resources()
-
Description:
Loads all resources into memory.
- virtual void unload_all_resources()
-
Description:
Unloads all resources from memory.
- virtual void load_section(
-
const char *section_name)
Parameters: section_name - the section to be loaded
Description:
Loads all resources in a given section into memory.
- virtual void unload_section(
-
const char *section_name)
Parameters: section_name - the section to be unloaded
Description:
Unloads all resources in a given section into memory.
- virtual CL_Resource *get_resource(
-
std::string res_id)
Parameters: Name of the resource in the configuration file - note: the name of resources are absolute, eg. including section names with slashes (Graphics/Pacman/sur_pacman)
Description:
Returns a pointer to the CL_Resource representing the given resource
- virtual std::list<std::string> *get_all_resources()
-
Description:
Returns a list of all resources available. Primarily used by the ClanCompiler to build datafiles from resources.
Return value:
The list of resources available. You'll have to delete all strings in the returned list manually (including the list-instance itself).
- virtual std::list<std::string> *get_resources_of_type(
-
std::string type_id)
Description:
Returns a list of all resources available matching a given type. Primarily used by the ClanCompiler to build datafiles from resources.
Return value:
The list of resources available. You'll have to delete all strings in the list manually (including the list-instance itself).
- virtual CL_InputSourceProvider *get_resource_provider()
-
Description:
Returns a pointer to the inputsourceprovider, in which all resources are stored(this can be a fileprovider or a datafileprovider depending on method used to load the script file)
Return value:
Pointer to inputsourceprovider containing resource data.
SEE ALSO
All ClanLib API classes can be found in clanlib (3).
AUTHORS
Originally written by Magnus Norddahl <[email protected]> and Martin Starch <[email protected]>. ClanLib is now developed by the ClanLib Development team as an Open Source project.
The ClanLib man pages was created using the Perceps documentation system (another excellent piece of Open Source software, available at http://somewhere.in.the.world.org).
See clanlib (3) to find out how to get a full list of contributors and details on how to submit bug reports, comments etc.