00001 /* 00002 $Id: resourcetype_sample.h,v 1.1 2001/03/06 15:09:26 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 File purpose: 00015 Sample resourcetype header file 00016 00017 */ 00018 00020 00021 #ifndef header_resourcetype_sample 00022 #define header_resourcetype_sample 00023 00024 #include "API/Core/Resources/resource_manager.h" 00025 #include "API/Core/System/clanstring.h" 00026 #include "API/Sound/soundbuffer.h" 00027 #include "API/Sound/static_soundprovider.h" 00028 00029 class CL_Res_Sample : public CL_ResourceType 00030 //: The sound sample resource type. 00031 // This class is used to load sample resources from a resource source 00032 // (datafile or script file). 00033 // <br> 00034 // Use the CL_ResourceManager to get an instance to the resource source, and 00035 // then call one of the static functions here to load the resource: 00036 // <code> 00037 // CL_ResourceManager res_manager("my_datafile.dat", true); 00038 // CL_SoundBuffer *my_sample = CL_Res_Sample::load("my_sample", res_manager); 00039 // </code> 00046 { 00047 public: 00048 CL_Res_Sample(); 00049 00050 private: 00051 friend CL_ResourceManager; 00052 virtual CL_Resource *create_from_location( 00053 std::string name, 00054 std::string location, 00055 CL_ResourceOptions *options, 00056 CL_ResourceManager *parent); 00057 00058 virtual CL_Resource *create_from_serialization( 00059 std::string name, 00060 CL_ResourceManager *parent); 00061 }; 00062 00063 class CL_WritableSampleResource : public CL_Resource 00064 { 00065 protected: 00066 CL_SoundBuffer *loaded_sample; 00067 bool loaded; 00068 CL_String sample_location; 00069 CL_ResourceOptions *options; 00070 CL_ResourceManager *parent; 00071 int load_count; 00072 public: 00073 CL_WritableSampleResource(std::string name); 00074 virtual ~CL_WritableSampleResource() { ; } 00075 00076 virtual void serialize_save(CL_OutputSource *output); 00077 virtual void load(); 00078 virtual void unload(); 00079 virtual int get_load_count() { return load_count; } 00080 00081 virtual CL_SoundBuffer *create_sample()=0; 00082 }; 00083 00084 class CL_SampleFileResource : public CL_WritableSampleResource 00085 { 00086 public: 00087 CL_SampleFileResource( 00088 std::string name, 00089 std::string location, 00090 CL_ResourceOptions *options, 00091 CL_ResourceManager *parent); 00092 00093 ~CL_SampleFileResource(); 00094 00095 virtual CL_SoundBuffer *create_sample(); 00096 }; 00097 00098 class CL_SampleDatafileResource : public CL_WritableSampleResource 00099 { 00100 public: 00101 CL_SampleDatafileResource( 00102 std::string name, 00103 CL_ResourceManager *parent); 00104 00105 ~CL_SampleDatafileResource(); 00106 00107 virtual CL_SoundBuffer *create_sample(); 00108 }; 00109 00110 00111 #endif
1.2.6 written by Dimitri van Heesch,
© 1997-2001