http://prdownloads.sourceforge.net/lufs/lufs-0.9.6.tar.gz?download
[lufs.git] / filesystems / wavfs / fs_modules.h
1 // Base class for a filesystem hook module which depends on filename.
2 // default behaviour filters on extension.
3 class FSModule
4 {
5 public:
6         // call this function with true it the file we are looking at has already been processed by another
7         // filter. Returns true if this filter wants to process it too.
8         virtual bool CanAdd( bool already_added ) { return !already_added; };
9
10         /*      If this module can process this file, this method will return a "virtual"
11                 file name for the processed file. Else, returns empty string.
12                 example : fname = "music.flac" => returns "music.flac$.wav" */
13         virtual string GetVirtualFilename(const char* fname);
14
15         // returns true if it is this module which generated this virtual filename
16         virtual bool IsMyVirtualFilename(const char* fname);
17
18         // returns real filename from virtual filename, or empty string if impossible
19         virtual string GetRealFilename( const char* virtuel );
20
21         //      Opens a file and returns a handle to it. NULL if error.
22         virtual FileHandle*     Open( const char* path );
23
24         // this is ".flac"
25         virtual const char* GetRealExtension() { return ""; }
26
27         // this is "$.wav"
28         virtual const char* GetVirtualExtension() { return ""; }
29         
30         typedef vector<FSModule*> Array;
31         
32         virtual const char* Identity() { return "FSModule"; }
33 protected:
34         // instanciate handle
35         virtual FileHandle* CreateHandle(const char* name, const char* real_name) =0;
36         
37 };
38
39 class FSModule_Default : public FSModule
40 {
41 public:
42         virtual string GetVirtualFilename(const char* fname);
43         bool IsMyVirtualFilename(const char* fname);
44         string GetRealFilename( const char* virtuel );
45         FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_Default(name,real_name); }
46         virtual const char* Identity() { return "FSModule_Default"; }
47 };
48
49 class FSModule_Flac : public FSModule
50 {
51 public:
52         const char* GetRealExtension() { return ".flac"; }
53         const char* GetVirtualExtension() { return ".wav"; }
54         FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_Flac(name,real_name); }
55         virtual const char* Identity() { return "FSModule_Flac"; }
56 };
57
58 /*
59 class FSModule_Ogg : public FSModule
60 {
61 public:
62         const char* GetRealExtension() { return ".ogg"; }
63         const char* GetVirtualExtension() { return ".wav"; }
64         FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_Ogg(name,real_name); }
65         virtual const char* Identity() { return "FSModule_Ogg"; }
66 };
67
68 class FSModule_MP3 : public FSModule
69 {
70 public:
71         const char* GetRealExtension() { return ".mp3"; }
72         const char* GetVirtualExtension() { return ".wav"; }
73         FileHandle* CreateHandle(const char* name, const char* real_name) { return new FileHandle_MP3(name,real_name); }
74         virtual const char* Identity() { return "FSModule_MP3"; }
75 };
76 */