Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CodecRegistry.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Audio::CodecRegistry
3 //
4 #ifndef __AUDIO_CODECREGISTRY_H__INCLUDED__
5 #define __AUDIO_CODECREGISTRY_H__INCLUDED__
6 
7 #include <string>
8 #include <map>
9 #include <set>
10 #include "Exceptions.h"
11 #include "Singleton.h"
12 
13 #include "vsfilesystem.h"
14 
15 namespace Audio {
16 
17  // The registry needs not know what it's managing... right?
18  // At least not its interface.
19  class Codec;
20  class Stream;
21 
30  class CodecRegistry : public Singleton<CodecRegistry>
31  {
32  private:
33  // The many required indexes
34  typedef std::set<Codec*> CodecSet;
35  typedef std::map<Codec*,int> CodecPriority;
36  typedef std::map<std::string, CodecSet> ExtensionCodecs;
37  typedef std::map<std::string, Codec*> NameCodec;
38 
39  CodecPriority codecPriority;
40  ExtensionCodecs extensionCodecs;
41  CodecSet universalCodecs;
42  NameCodec nameCodec;
43 
44  public:
47  CodecRegistry() throw();
48 
50 
57  void add(Codec* codec, int priority = 0) throw();
58 
64  void remove(Codec* codec) throw();
65 
74  Codec* findByName(const std::string& name) const throw(CodecNotFoundException);
75 
86  Codec* findByFile(const std::string& path, VSFileSystem::VSFileType type = VSFileSystem::UnknownFile) const throw(CodecNotFoundException);
87 
92  Stream* open(const std::string& path, VSFileSystem::VSFileType type = VSFileSystem::UnknownFile) const throw(Exception);
93 
94  };
95 
97  {
98  Codec *codec;
99  public:
100  CodecRegistration(Codec* codec, int priority = 0) throw();
102  };
103 
104 };
105 
106 #endif//__AUDIO_CODECREGISTRY_H__INCLUDED__