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
Sound.h
Go to the documentation of this file.
1 //
2 // C++ Interface: Audio::Sound
3 //
4 #ifndef __AUDIO_SOUND_H__INCLUDED__
5 #define __AUDIO_SOUND_H__INCLUDED__
6 
7 #include "Exceptions.h"
8 #include "Types.h"
9 #include "Format.h"
10 
11 namespace Audio {
12 
13  // Forward declaration of Streams
14  class Stream;
15 
23  class Sound
24  {
25  private:
26  std::string name;
27  Format format;
28 
29  protected:
31  struct Flags {
34  int loaded : 1;
35 
39  int loading : 1;
40 
44  int streaming : 1;
45  } flags;
46 
47  protected:
49  Sound(const std::string& name, bool streaming) throw();
50 
52  Format& getFormat() throw() { return format; };
53 
54 
55  public:
56  virtual ~Sound();
57 
59  const std::string& getName() const throw() { return name; };
60 
62  const Format& getFormat() const throw() { return format; };
63 
65  bool isLoaded() const throw() { return flags.loaded; }
66 
68  bool isLoading() const throw() { return flags.loading; }
69 
71  bool isStreaming() const throw() { return flags.streaming; }
72 
86  void load(bool wait = true) throw(Exception);
87 
89  void unload() throw();
90 
91  // The following section contains all the virtual functions that need be implemented
92  // by a concrete Sound class. All are protected, so the stream interface is independent
93  // of implementations.
94  protected:
95 
102  virtual void onLoaded(bool success) throw();
103 
109  virtual void waitLoad() throw(Exception);
110 
114  virtual void loadImpl(bool wait) throw(Exception) = 0;
115 
121  virtual void abortLoad() throw() = 0;
122 
123 
127  virtual void unloadImpl() throw() = 0;
128 
129  };
130 
131 };
132 
133 #endif//__AUDIO_SOUND_H__INCLUDED__