isound.h

Go to the documentation of this file.
00001 #ifndef ISOUND_H_
00002 #define ISOUND_H_
00003 
00004 #include "modulesystem.h"
00005 #include "modulesystem/moduleregistry.h"
00006 #include "generic/constant.h"
00007 #include "generic/callbackfwd.h"
00008 #include "AutoPtr.h"
00009 #include <vector>
00010 #include <string>
00011 #include "debugging/debugging.h"
00012 #include "ifilesystem.h"
00013 
00014 const float METERS_PER_UNIT = 0.0254f;
00015 const float UNITS_PER_METER = 1 / METERS_PER_UNIT;
00016 
00017 // The min and max radii of a misc_sound entity
00018 class SoundRadii
00019 {
00020         float minRad, maxRad;
00021     public:
00022         //set sound radii either in metres or in inch on initialization might cause a conversion
00023         SoundRadii (float min = 0, float max = 0, bool inMetres = false)
00024         {
00025             if (inMetres) {
00026                 minRad = min * UNITS_PER_METER;
00027                 maxRad = max * UNITS_PER_METER;
00028             } else {
00029                 minRad = min;
00030                 maxRad = max;
00031             }
00032         }
00033 
00034         // set the sound radii in metres or in inch, might cause a conversion
00035         void setMin (float min, bool inMetres = false)
00036         {
00037             if (inMetres) {
00038                 minRad = min * UNITS_PER_METER;
00039             } else {
00040                 minRad = min;
00041             }
00042         }
00043 
00044         void setMax (float max, bool inMetres = false)
00045         {
00046             if (inMetres) {
00047                 maxRad = max * UNITS_PER_METER;
00048             } else {
00049                 maxRad = max;
00050             }
00051         }
00052 
00053         float getMin (bool inMetres = false) const
00054         {
00055             return (inMetres) ? minRad * METERS_PER_UNIT : minRad;
00056         }
00057 
00058         float getMax (bool inMetres = false) const
00059         {
00060             return (inMetres) ? maxRad * METERS_PER_UNIT : maxRad;
00061         }
00062 };
00063 
00064 class SoundManagerDependencies: public GlobalFileSystemModuleRef
00065 {
00066 };
00067 
00071 class ISoundManager
00072 {
00073     public:
00074         INTEGER_CONSTANT(Version, 1);
00075         STRING_CONSTANT(Name, "sound");
00076 
00077         virtual ~ISoundManager ()
00078         {
00079         }
00080 
00086         virtual bool playSound (const std::string& fileName) = 0;
00087 
00090         virtual void stopSound () = 0;
00091 
00094         virtual void switchPlaybackEnabledFlag () = 0;
00095 
00098         virtual bool isPlaybackEnabled () = 0;
00099 };
00100 
00101 // This is needed to be registered as a Radiant dependency
00102 template<typename Type>
00103 class GlobalModule;
00104 typedef GlobalModule<ISoundManager> GlobalSoundManagerModule;
00105 
00106 // A reference to the call above.
00107 template<typename Type>
00108 class GlobalModuleRef;
00109 typedef GlobalModuleRef<ISoundManager> GlobalSoundManagerModuleRef;
00110 
00111 // Accessor method
00112 inline ISoundManager * GlobalSoundManager ()
00113 {
00114     Module * soundmodule = globalModuleServer().findModule(ISoundManager::Name_CONSTANT_::evaluate(),
00115             ISoundManager::Version_CONSTANT_::evaluate(), "*");
00116     ASSERT_MESSAGE(soundmodule,
00117             "Couldn't retrieve GlobalSoundManager, is not registered and/or initialized.");
00118     return (ISoundManager *) soundmodule->getTable(); // findModule returns the pointer to the valid value, DO NOT DELETE!
00119 }
00120 
00121 #endif /*ISOUND_H_*/

Generated by  doxygen 1.6.2