diff --git a/src/platform.cpp b/src/platform.cpp index 0bf89bd..a8a00c4 100644 --- a/src/platform.cpp +++ b/src/platform.cpp @@ -33,6 +33,16 @@ namespace cloonel { assert(m_surface); } + ///-------------------------------------------------------------------------- + ///-------------------------------------------------------------------------- + Platform::Platform (Platform&& parOther) : + m_screenRatio(std::move(parOther.m_screenRatio)), + m_position(parOther.m_position), + m_size(parOther.m_size), + m_surface(parOther.m_surface) + { + } + ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- void Platform::Draw() const { diff --git a/src/platform.hpp b/src/platform.hpp index 988b3a1..c099299 100644 --- a/src/platform.hpp +++ b/src/platform.hpp @@ -30,8 +30,10 @@ namespace cloonel { class Platform : public Drawable { public: Platform ( SDLMain* parSdlMain, const float2& parPos, Texture* parTexture, const float2& parSize ); + Platform ( Platform&& parOther ); + Platform ( const Platform& ) = delete; virtual ~Platform ( void ) noexcept = default; - Platform& operator= ( Platform&& parOther ); + Platform& operator= ( Platform&& parOther ) = delete; virtual void Draw ( void ) const; diff --git a/src/sizenotifiable.cpp b/src/sizenotifiable.cpp index 3ba17ad..f600379 100644 --- a/src/sizenotifiable.cpp +++ b/src/sizenotifiable.cpp @@ -25,16 +25,24 @@ namespace cloonel { ///---------------------------------------------------------------------- void AutoRegister::Unregister() noexcept { #if !defined(NDEBUG) - assert(m_registered); + assert(m_registered or not m_sdlmain); m_registered = false; #endif - assert(m_sdlmain); - m_sdlmain->UnregisterForResChange(m_id); + if (m_registered) { + assert(m_sdlmain); + m_sdlmain->UnregisterForResChange(m_id); + } } ///---------------------------------------------------------------------- ///---------------------------------------------------------------------- - void AutoRegister::Swap (AutoRegister& parOther) noexcept { + AutoRegister::AutoRegister (AutoRegister&& parOther) : + m_sdlmain(nullptr), + m_id(0) +#if !defined(NDEBUG) + , m_registered(false) +#endif + { std::swap(m_sdlmain, parOther.m_sdlmain); std::swap(m_id, parOther.m_id); #if !defined(NDEBUG) @@ -48,11 +56,4 @@ namespace cloonel { void SizeNotifiableBase::NotifyResChanged (const SizeRatio& parSize) { m_scaleRatio = parSize.Ratio(); } - - ///-------------------------------------------------------------------------- - ///-------------------------------------------------------------------------- - void SizeNotifiableBase::swap (SizeNotifiableBase& parOther) noexcept { - std::swap(m_scaleRatio.x(), parOther.m_scaleRatio.x()); - std::swap(m_scaleRatio.y(), parOther.m_scaleRatio.y()); - } } //namespace cloonel diff --git a/src/sizenotifiable.hpp b/src/sizenotifiable.hpp index 0dea646..27fdc11 100644 --- a/src/sizenotifiable.hpp +++ b/src/sizenotifiable.hpp @@ -34,17 +34,18 @@ namespace cloonel { enum { SDLMAIN_NEEDED = false }; DontRegister ( void ) = default; + DontRegister ( DontRegister&& ) { } ~DontRegister ( void ) noexcept = default; void Register ( SizeNotifiableBase* ) const noexcept { return; } void Unregister ( void ) const noexcept { return; } - void Swap ( DontRegister& ) noexcept { return; } }; class AutoRegister { public: enum { SDLMAIN_NEEDED = true }; + AutoRegister ( AutoRegister&& parOther ); explicit AutoRegister ( SDLMain* parMain ) : m_sdlmain(parMain) #if !defined(NDEBUG) @@ -56,7 +57,6 @@ namespace cloonel { void Register ( SizeNotifiableBase* parNotifiable ); void Unregister ( void ) noexcept; - void Swap ( AutoRegister& parOther ) noexcept; private: SDLMain* m_sdlmain; @@ -73,7 +73,7 @@ namespace cloonel { class SizeNotifiableBase { protected: SizeNotifiableBase ( void ) = default; - SizeNotifiableBase ( const SizeNotifiableBase& ) = delete; + SizeNotifiableBase ( const SizeNotifiableBase& ) = default; virtual ~SizeNotifiableBase ( void ) noexcept = default; SizeNotifiableBase& operator= ( const SizeNotifiableBase& ) = delete; @@ -81,9 +81,6 @@ namespace cloonel { virtual void NotifyResChanged ( const SizeRatio& parSize ); const float2& Ratio ( void ) const noexcept { return m_scaleRatio; } - protected: - void swap ( SizeNotifiableBase& parOther ) noexcept; - private: float2 m_scaleRatio; }; @@ -95,20 +92,30 @@ namespace cloonel { class SizeNotifiable : private RegisterBehaviour, public SizeNotifiableBase { static_assert(RegisterBehaviour::SDLMAIN_NEEDED == false, "SdlMainNeeded mismatches expected value"); public: + SizeNotifiable ( const SizeNotifiable& ) = delete; + SizeNotifiable ( SizeNotifiable&& parOther ) : + RegisterBehaviour(parOther), + SizeNotifiableBase(parOther) + { + } SizeNotifiable ( void ) { this->Register(this); } virtual ~SizeNotifiable ( void ) noexcept { this->Unregister(); } - - void swap ( SizeNotifiable& parOther ) noexcept { SizeNotifiableBase::swap(parOther); RegisterBehaviour::swap(parOther); } }; template class SizeNotifiable : private RegisterBehaviour, public SizeNotifiableBase { static_assert(RegisterBehaviour::SDLMAIN_NEEDED == true, "SdlMainNeeded mismatches expected value"); public: + SizeNotifiable ( const SizeNotifiable& ) = delete; + SizeNotifiable ( SizeNotifiable&& parOther ) : + RegisterBehaviour(std::move(parOther)), + SizeNotifiableBase(parOther) + { + } explicit SizeNotifiable ( SDLMain* parSdlMain ) : RegisterBehaviour(parSdlMain) { @@ -117,8 +124,6 @@ namespace cloonel { virtual ~SizeNotifiable ( void ) noexcept { this->Unregister(); } - - void swap ( SizeNotifiable& parOther ) noexcept { SizeNotifiableBase::swap(parOther); RegisterBehaviour::swap(parOther); } }; } //namespace cloonel