Move semantics for IntrusiveAudioGroupData

This commit is contained in:
Jack Andersen 2016-05-17 14:59:44 -10:00
parent b2fa66b738
commit a893ee61bb
2 changed files with 34 additions and 4 deletions

View File

@ -30,9 +30,16 @@ public:
*/
class IntrusiveAudioGroupData : public AudioGroupData
{
bool m_owns = true;
public:
using AudioGroupData::AudioGroupData;
~IntrusiveAudioGroupData();
IntrusiveAudioGroupData(const IntrusiveAudioGroupData&)=delete;
IntrusiveAudioGroupData& operator=(const IntrusiveAudioGroupData&)=delete;
IntrusiveAudioGroupData(IntrusiveAudioGroupData&& other);
IntrusiveAudioGroupData& operator=(IntrusiveAudioGroupData&& other);
};
}

View File

@ -5,10 +5,33 @@ namespace amuse
IntrusiveAudioGroupData::~IntrusiveAudioGroupData()
{
delete m_pool;
delete m_proj;
delete m_sdir;
delete m_samp;
if (m_owns)
{
delete m_pool;
delete m_proj;
delete m_sdir;
delete m_samp;
}
}
IntrusiveAudioGroupData::IntrusiveAudioGroupData(IntrusiveAudioGroupData&& other)
: AudioGroupData(other.m_proj, other.m_pool, other.m_sdir, other.m_samp)
{
m_owns = other.m_owns;
other.m_owns = false;
}
IntrusiveAudioGroupData& IntrusiveAudioGroupData::operator=(IntrusiveAudioGroupData&& other)
{
m_owns = other.m_owns;
other.m_owns = false;
m_proj = other.m_proj;
m_pool = other.m_pool;
m_sdir = other.m_sdir;
m_samp = other.m_samp;
return *this;
}
}