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
utils.h
Go to the documentation of this file.
1 #ifndef __AUDIO_UTILS_H__INCLUDED__
2 #define __AUDIO_UTILS_H__INCLUDED__
3 
4 #include "Types.h"
5 #include "Exceptions.h"
6 #include <map>
7 
8 namespace Audio {
9 
10  // Forward declarations
11  class Listener;
12  class Source;
13 
15  Timestamp getGameTime() throw();
16 
18  Timestamp getRealTime() throw();
19 
27  Scalar estimateGain(const Source &src, const Listener &listener) throw();
28 
35  void sleep(unsigned int ms);
36 
42  template<typename T> T parseEnum(const std::string &s, const std::map<std::string, T> &enumMap)
43  {
44  typename std::map<std::string, T>::const_iterator it = enumMap.find(s);
45  if (it != enumMap.end())
46  return it->second; else
47  throw InvalidParametersException("Enumerated value \"" + s + "\" not recognized");
48  }
49 
56  template<typename T> T parseEnum(const std::string &s, const std::map<std::string, T> &enumMap, T deflt)
57  {
58  typename std::map<std::string, T>::const_iterator it = enumMap.find(s);
59  if (it != enumMap.end())
60  return it->second; else
61  return deflt;
62  }
63 
64 
65 }
66 
67 #endif//__AUDIO_UTILS_H__INCLUDED__
68