00001 /* 00002 $Id: resource_manager.h,v 1.4 2001/03/04 17:54:47 mbn Exp $ 00003 00004 ------------------------------------------------------------------------ 00005 ClanLib, the platform independent game SDK. 00006 00007 This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE 00008 version 2. See COPYING for details. 00009 00010 For a total list of contributers see CREDITS. 00011 00012 ------------------------------------------------------------------------ 00013 */ 00014 00016 00017 #ifndef header_resource_manager 00018 #define header_resource_manager 00019 00020 #include "resource.h" 00021 #include "resourcetype.h" 00022 #include "resourceoptions.h" 00023 #include "resourceoption.h" 00024 #include "../IOData/inputsource_provider.h" 00025 00026 class CL_ResourceOption; 00027 class CL_ResourceOptions; 00028 class CL_ResourceManager; 00029 00030 class CL_ResourceManager 00031 //: The ClanLib resource manager. 00032 // The resource manager is used to retrieve resources from a given resource source. 00033 // This can either be a resource script file (used as input to the 00034 // datafile compiler), or a datafile with all the resources included into 00035 // one large gzipped resource file. 00036 // <br> 00037 // To speedup loading of resources in a game, you can load entire sections 00038 // of resources at once. When a resource in the section is requested, it is 00039 // returned instantly without having to access the disk. This is especially 00040 // useful to make sure all the game resources are loaded before the game is 00041 // started. 00042 // <br> 00043 // Resources are normally not retrieved using the get_resource() function. 00044 // Instead, you should load the resource using the appropiate resource type 00045 // class. For instance, a surface is easiest loaded like this: 00046 // <code> 00047 // CL_ResourceManager res_manager("my_datafile.dat", true); 00048 // CL_Surface *my_surface = CL_Res_Surface::load("my_surface", res_manager); 00049 // </code> 00050 // <br> 00051 // Getting the same resource twice won't create a new instance of the 00052 // resource, but you will still have to clean up the resource after 00053 // yourself. In other words: If you load a resource twice, you only have to 00054 // delete it once. 00055 { 00056 public: 00057 static CL_ResourceManager *create( 00058 const char *config_file, 00059 CL_InputSourceProvider *provider = NULL, 00060 bool read_directly_from_source=false, 00061 bool delete_inputsource_provider=false); 00062 //: Resource Manager constructor. 00066 00067 static CL_ResourceManager *create( 00068 const char *file_name, 00069 const bool is_datafile ); 00070 //: Resource Manager constructor. 00073 00074 virtual ~CL_ResourceManager() { return; } 00075 00076 virtual void load_all_resources()=0; 00077 //: Loads all resources into memory. 00078 00079 virtual void unload_all_resources()=0; 00080 //: Unloads all resources from memory. 00081 00082 virtual void load_section(const char *section_name)=0; 00083 //: Loads all resources in a given section into memory. 00085 00086 virtual void unload_section(const char *section_name)=0; 00087 //: Unloads all resources in a given section into memory. 00089 00090 virtual CL_Resource *get_resource(std::string res_id)=0; 00091 //: Returns a pointer to the CL_Resource representing the given resource 00093 00094 virtual std::list<std::string> *get_all_resources()=0; 00095 //: Returns a list of all resources available. Primarily used by the ClanCompiler to 00096 //: build datafiles from resources. 00099 00100 virtual std::list<std::string> *get_resources_of_type(std::string type_id)=0; 00101 //: Returns a list of all resources available matching a given type. 00102 //: Primarily used by the ClanCompiler to build datafiles from resources. 00105 00106 virtual CL_InputSourceProvider *get_resource_provider()=0; 00107 //: Returns a pointer to the inputsourceprovider, in which all resources are stored 00108 //: (this can be a fileprovider or a datafileprovider depending on method used to load the script file) 00110 }; 00111 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001