diff --git a/include/amuse/AudioGroupData.hpp b/include/amuse/AudioGroupData.hpp index 1c93a8f..acecb4d 100644 --- a/include/amuse/AudioGroupData.hpp +++ b/include/amuse/AudioGroupData.hpp @@ -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); }; } diff --git a/lib/AudioGroupData.cpp b/lib/AudioGroupData.cpp index eff86f4..92d245d 100644 --- a/lib/AudioGroupData.cpp +++ b/lib/AudioGroupData.cpp @@ -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; } }