Make Sound and Stream sibling types

To avoid being able to accidentally cast a Stream* to a Sound*, or vice-versa.
This commit is contained in:
Chris Robinson 2017-09-12 01:19:26 -07:00
parent 9e45f6d05f
commit 617c05f557

View file

@ -7,9 +7,10 @@
namespace MWSound namespace MWSound
{ {
class Sound { class SoundBase {
Sound& operator=(const Sound &rhs); SoundBase& operator=(const SoundBase&) = delete;
Sound(const Sound &rhs); SoundBase(const SoundBase&) = delete;
SoundBase(SoundBase&&) = delete;
osg::Vec3f mPos; osg::Vec3f mPos;
float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */ float mVolume; /* NOTE: Real volume = mVolume*mBaseVolume */
@ -80,17 +81,26 @@ namespace MWSound
mHandle = nullptr; mHandle = nullptr;
} }
Sound() SoundBase()
: mPos(0.0f, 0.0f, 0.0f), mVolume(1.0f), mBaseVolume(1.0f), mPitch(1.0f) : mPos(0.0f, 0.0f, 0.0f), mVolume(1.0f), mBaseVolume(1.0f), mPitch(1.0f)
, mMinDistance(1.0f), mMaxDistance(1000.0f), mFlags(0), mFadeOutTime(0.0f) , mMinDistance(1.0f), mMaxDistance(1000.0f), mFlags(0), mFadeOutTime(0.0f)
, mHandle(0) , mHandle(nullptr)
{ } { }
}; };
// Same as above, but it's a different type since the output handles them differently class Sound : public SoundBase {
class Stream : public Sound { Sound& operator=(const Sound&) = delete;
Stream& operator=(const Stream &rhs); Sound(const Sound&) = delete;
Stream(const Stream &rhs); Sound(Sound&&) = delete;
public:
Sound() { }
};
class Stream : public SoundBase {
Stream& operator=(const Stream&) = delete;
Stream(const Stream&) = delete;
Stream(Stream&&) = delete;
public: public:
Stream() { } Stream() { }