diff --git a/include/Nazara/Audio/Music.hpp b/include/Nazara/Audio/Music.hpp index 86ccc6906..aa0ed9f06 100644 --- a/include/Nazara/Audio/Music.hpp +++ b/include/Nazara/Audio/Music.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -37,7 +38,7 @@ namespace Nz public: Music() = default; Music(const Music&) = delete; - Music(Music&&) = delete; ///TODO + Music(Music&&) noexcept = default; ~Music(); bool Create(SoundStream* soundStream); @@ -66,10 +67,10 @@ namespace Nz void Stop() override; Music& operator=(const Music&) = delete; - Music& operator=(Music&&) = delete; ///TODO + Music& operator=(Music&&) noexcept = default; private: - MusicImpl* m_impl = nullptr; + MovablePtr m_impl = nullptr; bool FillAndQueueBuffer(unsigned int buffer); void MusicThread(); diff --git a/include/Nazara/Audio/SoundBuffer.hpp b/include/Nazara/Audio/SoundBuffer.hpp index db38f780f..186ebd091 100644 --- a/include/Nazara/Audio/SoundBuffer.hpp +++ b/include/Nazara/Audio/SoundBuffer.hpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -52,7 +53,7 @@ namespace Nz SoundBuffer() = default; SoundBuffer(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples); SoundBuffer(const SoundBuffer&) = delete; - SoundBuffer(SoundBuffer&&) = delete; + SoundBuffer(SoundBuffer&&) noexcept = default; ~SoundBuffer(); bool Create(AudioFormat format, UInt64 sampleCount, UInt32 sampleRate, const Int16* samples); @@ -74,7 +75,7 @@ namespace Nz template static SoundBufferRef New(Args&&... args); SoundBuffer& operator=(const SoundBuffer&) = delete; - SoundBuffer& operator=(SoundBuffer&&) = delete; ///TODO + SoundBuffer& operator=(SoundBuffer&&) noexcept = default; // Signals: NazaraSignal(OnSoundBufferDestroy, const SoundBuffer* /*soundBuffer*/); @@ -86,7 +87,7 @@ namespace Nz static bool Initialize(); static void Uninitialize(); - SoundBufferImpl* m_impl = nullptr; + MovablePtr m_impl = nullptr; static SoundBufferLibrary::LibraryMap s_library; static SoundBufferLoader::LoaderList s_loaders; diff --git a/include/Nazara/Core/ConditionVariable.hpp b/include/Nazara/Core/ConditionVariable.hpp index d73cb0f8f..97d4ed10f 100644 --- a/include/Nazara/Core/ConditionVariable.hpp +++ b/include/Nazara/Core/ConditionVariable.hpp @@ -8,6 +8,7 @@ #define NAZARA_CONDITIONVARIABLE_HPP #include +#include namespace Nz { @@ -19,7 +20,7 @@ namespace Nz public: ConditionVariable(); ConditionVariable(const ConditionVariable&) = delete; - inline ConditionVariable(ConditionVariable&& condition) noexcept; + ConditionVariable(ConditionVariable&& condition) noexcept = default; ~ConditionVariable(); void Signal(); @@ -29,10 +30,10 @@ namespace Nz bool Wait(Mutex* mutex, UInt32 timeout); ConditionVariable& operator=(const ConditionVariable&) = delete; - ConditionVariable& operator=(ConditionVariable&& condition) noexcept; + ConditionVariable& operator=(ConditionVariable&& condition) noexcept = default; private: - ConditionVariableImpl* m_impl; + MovablePtr m_impl; }; } diff --git a/include/Nazara/Core/ConditionVariable.inl b/include/Nazara/Core/ConditionVariable.inl index f9603e1c1..f95cb3144 100644 --- a/include/Nazara/Core/ConditionVariable.inl +++ b/include/Nazara/Core/ConditionVariable.inl @@ -11,15 +11,6 @@ namespace Nz /*! * \class Nz::ConditionVariable */ - - /*! - * \brief Constructs a ConditionVariable object by moving another one - */ - inline ConditionVariable::ConditionVariable(ConditionVariable&& condition) noexcept : - m_impl(condition.m_impl) - { - condition.m_impl = nullptr; - } } #include diff --git a/include/Nazara/Core/Directory.hpp b/include/Nazara/Core/Directory.hpp index 21a1da8da..ea828fe45 100644 --- a/include/Nazara/Core/Directory.hpp +++ b/include/Nazara/Core/Directory.hpp @@ -8,6 +8,7 @@ #define NAZARA_DIRECTORY_HPP #include +#include #include #if defined(NAZARA_PLATFORM_WINDOWS) @@ -35,7 +36,7 @@ namespace Nz Directory(); Directory(const String& dirPath); Directory(const Directory&) = delete; - Directory(Directory&&) = delete; ///TODO + Directory(Directory&&) noexcept = default; ~Directory(); void Close(); @@ -67,14 +68,14 @@ namespace Nz static bool SetCurrent(const String& dirPath); Directory& operator=(const Directory&) = delete; - Directory& operator=(Directory&&) = delete; ///TODO + Directory& operator=(Directory&&) noexcept = delete; private: NazaraMutexAttrib(m_mutex, mutable) String m_dirPath; String m_pattern; - DirectoryImpl* m_impl; + MovablePtr m_impl; }; } diff --git a/include/Nazara/Core/DynLib.hpp b/include/Nazara/Core/DynLib.hpp index 2f4ccb530..edf8ed647 100644 --- a/include/Nazara/Core/DynLib.hpp +++ b/include/Nazara/Core/DynLib.hpp @@ -8,6 +8,7 @@ #define NAZARA_DYNLIB_HPP #include +#include #include #if defined(NAZARA_PLATFORM_WINDOWS) @@ -28,7 +29,7 @@ namespace Nz { - using DynLibFunc = int (*)(); // "Generic" type of poiter to function + using DynLibFunc = int (*)(); // "Generic" type of pointer to function class DynLibImpl; @@ -37,7 +38,7 @@ namespace Nz public: DynLib(); DynLib(const DynLib&) = delete; - DynLib(DynLib&& lib); + DynLib(DynLib&&) noexcept = default; ~DynLib(); String GetLastError() const; @@ -49,13 +50,13 @@ namespace Nz void Unload(); DynLib& operator=(const DynLib&) = delete; - DynLib& operator=(DynLib&& lib); + DynLib& operator=(DynLib&& lib) noexcept = default; private: NazaraMutexAttrib(m_mutex, mutable) mutable String m_lastError; - DynLibImpl* m_impl; + MovablePtr m_impl; }; } diff --git a/include/Nazara/Core/File.hpp b/include/Nazara/Core/File.hpp index 86a224314..5f7ffd741 100644 --- a/include/Nazara/Core/File.hpp +++ b/include/Nazara/Core/File.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -33,7 +34,7 @@ namespace Nz File(const String& filePath); File(const String& filePath, OpenModeFlags openMode); File(const File&) = delete; - File(File&& file) noexcept; + File(File&& file) noexcept = default; ~File(); bool Copy(const String& newFilePath); @@ -69,7 +70,7 @@ namespace Nz File& operator=(const String& filePath); File& operator=(const File&) = delete; - File& operator=(File&& file) noexcept; + File& operator=(File&& file) noexcept = default; static String AbsolutePath(const String& filePath); static inline ByteArray ComputeHash(HashType hash, const String& filePath); @@ -95,7 +96,7 @@ namespace Nz std::size_t WriteBlock(const void* buffer, std::size_t size) override; String m_filePath; - FileImpl* m_impl; + MovablePtr m_impl; }; NAZARA_CORE_API bool HashAppend(AbstractHash* hash, const File& originalFile); diff --git a/include/Nazara/Core/MovablePtr.hpp b/include/Nazara/Core/MovablePtr.hpp new file mode 100644 index 000000000..f27e365e6 --- /dev/null +++ b/include/Nazara/Core/MovablePtr.hpp @@ -0,0 +1,38 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#pragma once + +#ifndef NAZARA_MOVABLE_PTR_HPP +#define NAZARA_MOVABLE_PTR_HPP + +namespace Nz +{ + template + class MovablePtr + { + public: + MovablePtr(T* value = nullptr); + MovablePtr(const MovablePtr&) = default; + MovablePtr(MovablePtr&& ptr) noexcept; + ~MovablePtr() = default; + + T* Get() const; + + T* operator->() const; + + operator T*() const; + + MovablePtr& operator=(T* value); + MovablePtr& operator=(const MovablePtr&) = default; + MovablePtr& operator=(MovablePtr&& ptr) noexcept; + + private: + T* m_value; + }; +} + +#include + +#endif // NAZARA_MOVABLE_PTR_HPP diff --git a/include/Nazara/Core/MovablePtr.inl b/include/Nazara/Core/MovablePtr.inl new file mode 100644 index 000000000..10b1b26f8 --- /dev/null +++ b/include/Nazara/Core/MovablePtr.inl @@ -0,0 +1,61 @@ +// Copyright (C) 2017 Jérôme Leclercq +// This file is part of the "Nazara Engine - Core module" +// For conditions of distribution and use, see copyright notice in Config.hpp + +#include +#include + +namespace Nz +{ + /*! + * \ingroup core + * \class Nz::MovablePtr + * \brief Wraps a raw (non-proprietary) to allows it to be moved implicitly + */ + + template + MovablePtr::MovablePtr(T* value) : + m_value(value) + { + } + + template + MovablePtr::MovablePtr(MovablePtr&& ptr) noexcept : + m_value(ptr.m_value) + { + ptr.m_value = nullptr; + } + + template + inline T* MovablePtr::Get() const + { + return m_value; + } + + template + T* MovablePtr::operator->() const + { + return m_value; + } + + template + MovablePtr::operator T*() const + { + return m_value; + } + + template + inline MovablePtr& MovablePtr::operator=(T* value) + { + m_value = value; + + return *this; + } + + template + MovablePtr& MovablePtr::operator=(MovablePtr&& ptr) noexcept + { + std::swap(m_value, ptr.m_value); + return *this; + } +} diff --git a/include/Nazara/Core/Mutex.hpp b/include/Nazara/Core/Mutex.hpp index 303b163f1..b317cf58b 100644 --- a/include/Nazara/Core/Mutex.hpp +++ b/include/Nazara/Core/Mutex.hpp @@ -8,6 +8,7 @@ #define NAZARA_MUTEX_HPP #include +#include namespace Nz { @@ -20,7 +21,7 @@ namespace Nz public: Mutex(); Mutex(const Mutex&) = delete; - inline Mutex(Mutex&& mutex) noexcept; + Mutex(Mutex&&) noexcept = default; ~Mutex(); void Lock(); @@ -28,10 +29,10 @@ namespace Nz void Unlock(); Mutex& operator=(const Mutex&) = delete; - Mutex& operator=(Mutex&& mutex) noexcept; + Mutex& operator=(Mutex&&) noexcept = default; private: - MutexImpl* m_impl; + MovablePtr m_impl; }; } diff --git a/include/Nazara/Core/Mutex.inl b/include/Nazara/Core/Mutex.inl index 9e79fff02..ca9e5ec2f 100644 --- a/include/Nazara/Core/Mutex.inl +++ b/include/Nazara/Core/Mutex.inl @@ -12,15 +12,6 @@ namespace Nz * \ingroup core * \class Nz::Mutex */ - - /*! - * \brief Constructs a Mutex object by moving another one - */ - inline Mutex::Mutex(Mutex&& mutex) noexcept : - m_impl(mutex.m_impl) - { - mutex.m_impl = nullptr; - } } #include diff --git a/include/Nazara/Core/Thread.hpp b/include/Nazara/Core/Thread.hpp index e129cbe40..63460469d 100644 --- a/include/Nazara/Core/Thread.hpp +++ b/include/Nazara/Core/Thread.hpp @@ -9,6 +9,7 @@ #include #include +#include #include namespace Nz @@ -25,7 +26,7 @@ namespace Nz template Thread(F function, Args&&... args); template Thread(void (C::*function)(), C* object); Thread(const Thread&) = delete; - Thread(Thread&& other) noexcept; + Thread(Thread&& other) noexcept = default; ~Thread(); void Detach(); @@ -35,7 +36,7 @@ namespace Nz void SetName(const String& name); Thread& operator=(const Thread&) = delete; - Thread& operator=(Thread&& thread); + Thread& operator=(Thread&& thread) noexcept = default; static unsigned int HardwareConcurrency(); static void SetCurrentThreadName(const String& name); @@ -44,7 +45,7 @@ namespace Nz private: void CreateImpl(Functor* functor); - ThreadImpl* m_impl; + MovablePtr m_impl; }; class NAZARA_CORE_API Thread::Id diff --git a/include/Nazara/Network/SocketPoller.hpp b/include/Nazara/Network/SocketPoller.hpp index 5b583fa0f..170fd1a04 100644 --- a/include/Nazara/Network/SocketPoller.hpp +++ b/include/Nazara/Network/SocketPoller.hpp @@ -8,6 +8,7 @@ #define NAZARA_SOCKETPOLLER_HPP #include +#include #include #include @@ -19,7 +20,7 @@ namespace Nz { public: SocketPoller(); - inline SocketPoller(SocketPoller&& socketPoller); + SocketPoller(SocketPoller&&) noexcept = default; ~SocketPoller(); void Clear(); @@ -33,10 +34,10 @@ namespace Nz bool Wait(int msTimeout); - inline SocketPoller& operator=(SocketPoller&& socketPoller); + SocketPoller& operator=(SocketPoller&&) noexcept = default; private: - SocketPollerImpl* m_impl; + MovablePtr m_impl; }; } diff --git a/include/Nazara/Network/SocketPoller.inl b/include/Nazara/Network/SocketPoller.inl index 66331b9cb..b9e3a48e1 100644 --- a/include/Nazara/Network/SocketPoller.inl +++ b/include/Nazara/Network/SocketPoller.inl @@ -8,30 +8,6 @@ namespace Nz { - /*! - * \brief Constructs a SocketPoller object with another one by move semantic - * - * \param socketPoller SocketPoller to move into this - */ - inline SocketPoller::SocketPoller(SocketPoller&& socketPoller) : - m_impl(socketPoller.m_impl) - { - socketPoller.m_impl = nullptr; - } - - /*! - * \brief Moves the SocketPoller into this - * \return A reference to this - * - * \param socketPoller SocketPoller to move in this - */ - inline SocketPoller& SocketPoller::operator=(SocketPoller&& socketPoller) - { - m_impl = socketPoller.m_impl; - socketPoller.m_impl = nullptr; - - return *this; - } } #include diff --git a/include/Nazara/Platform/Window.hpp b/include/Nazara/Platform/Window.hpp index 3010bb91f..7611b68b0 100644 --- a/include/Nazara/Platform/Window.hpp +++ b/include/Nazara/Platform/Window.hpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -40,7 +41,7 @@ namespace Nz inline Window(VideoMode mode, const String& title, WindowStyleFlags style = WindowStyle_Default); inline explicit Window(WindowHandle handle); Window(const Window&) = delete; - inline Window(Window&& window) noexcept; + Window(Window&&) = default; virtual ~Window(); inline void Close(); @@ -103,14 +104,14 @@ namespace Nz bool WaitEvent(WindowEvent* event); Window& operator=(const Window&) = delete; - inline Window& operator=(Window&& window); + Window& operator=(Window&&) = default; protected: virtual bool OnWindowCreated(); virtual void OnWindowDestroy(); virtual void OnWindowResized(); - WindowImpl* m_impl; + MovablePtr m_impl; private: void IgnoreNextMouseEvent(int mouseX, int mouseY) const; diff --git a/include/Nazara/Platform/Window.inl b/include/Nazara/Platform/Window.inl index f217ac10c..cb929b8d7 100644 --- a/include/Nazara/Platform/Window.inl +++ b/include/Nazara/Platform/Window.inl @@ -27,26 +27,6 @@ namespace Nz Create(handle); } - /*! - * \brief Constructs a Window object by moving another one - */ - inline Window::Window(Window&& window) noexcept : - m_impl(window.m_impl), - m_events(std::move(window.m_events)), - m_pendingEvents(std::move(window.m_pendingEvents)), - m_eventCondition(std::move(window.m_eventCondition)), - m_eventHandler(std::move(window.m_eventHandler)), - m_eventMutex(std::move(window.m_eventMutex)), - m_eventConditionMutex(std::move(window.m_eventConditionMutex)), - m_closed(window.m_closed), - m_closeOnQuit(window.m_closeOnQuit), - m_eventPolling(window.m_eventPolling), - m_ownsWindow(window.m_ownsWindow), - m_waitForEvent(window.m_waitForEvent) - { - window.m_impl = nullptr; - } - inline void Window::Close() { m_closed = true; // The window will be closed at the next non-const IsOpen() call @@ -145,32 +125,6 @@ namespace Nz } } } - - /*! - * \brief Moves a window to another window object - * \return A reference to the object - */ - inline Window& Window::operator=(Window&& window) - { - Destroy(); - - m_closed = window.m_closed; - m_closeOnQuit = window.m_closeOnQuit; - m_eventCondition = std::move(window.m_eventCondition); - m_eventConditionMutex = std::move(window.m_eventConditionMutex); - m_eventHandler = std::move(window.m_eventHandler); - m_eventMutex = std::move(window.m_eventMutex); - m_eventPolling = window.m_eventPolling; - m_impl = window.m_impl; - m_events = std::move(window.m_events); - m_pendingEvents = std::move(window.m_pendingEvents); - m_ownsWindow = window.m_ownsWindow; - m_waitForEvent = window.m_waitForEvent; - - window.m_impl = nullptr; - - return *this; - } } #include diff --git a/include/Nazara/Renderer/Context.hpp b/include/Nazara/Renderer/Context.hpp index d9836cbe8..ebf36ee31 100644 --- a/include/Nazara/Renderer/Context.hpp +++ b/include/Nazara/Renderer/Context.hpp @@ -8,6 +8,7 @@ #define NAZARA_CONTEXT_HPP #include +#include #include #include #include @@ -35,7 +36,7 @@ namespace Nz public: Context() = default; Context(const Context&) = delete; - Context(Context&&) = delete; + Context(Context&&) noexcept = default; ~Context(); bool Create(const ContextParameters& parameters = ContextParameters()); @@ -52,7 +53,7 @@ namespace Nz void SwapBuffers(); Context& operator=(const Context&) = delete; - Context& operator=(Context&&) = delete; + Context& operator=(Context&&) noexcept = default; static bool EnsureContext(); @@ -69,7 +70,7 @@ namespace Nz static void Uninitialize(); ContextParameters m_parameters; - ContextImpl* m_impl = nullptr; + MovablePtr m_impl = nullptr; static std::unique_ptr s_reference; static std::vector> s_contexts; diff --git a/include/Nazara/Renderer/RenderTexture.hpp b/include/Nazara/Renderer/RenderTexture.hpp index ad340009e..253f4a680 100644 --- a/include/Nazara/Renderer/RenderTexture.hpp +++ b/include/Nazara/Renderer/RenderTexture.hpp @@ -8,6 +8,7 @@ #define NAZARA_RENDERTEXTURE_HPP #include +#include #include #include #include @@ -30,7 +31,7 @@ namespace Nz public: inline RenderTexture(); RenderTexture(const RenderTexture&) = delete; - RenderTexture(RenderTexture&&) = delete; ///TODO? + RenderTexture(RenderTexture&&) noexcept = default; inline ~RenderTexture(); bool AttachBuffer(AttachmentPoint attachmentPoint, UInt8 index, RenderBuffer* buffer); @@ -64,7 +65,7 @@ namespace Nz bool HasContext() const override; RenderTexture& operator=(const RenderTexture&) = delete; - RenderTexture& operator=(RenderTexture&&) = delete; ///TODO? + RenderTexture& operator=(RenderTexture&&) noexcept = default; static inline void Blit(RenderTexture* src, RenderTexture* dst, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false); static void Blit(RenderTexture* src, Rectui srcRect, RenderTexture* dst, Rectui dstRect, UInt32 buffers = RendererBuffer_Color | RendererBuffer_Depth | RendererBuffer_Stencil, bool bilinearFilter = false); @@ -85,7 +86,7 @@ namespace Nz void UpdateSize() const; void UpdateTargets() const; - RenderTextureImpl* m_impl; + MovablePtr m_impl; mutable bool m_checked ; mutable bool m_drawBuffersUpdated; mutable bool m_sizeUpdated; diff --git a/include/Nazara/Utility/Animation.hpp b/include/Nazara/Utility/Animation.hpp index 7f7595bbd..b0646292f 100644 --- a/include/Nazara/Utility/Animation.hpp +++ b/include/Nazara/Utility/Animation.hpp @@ -8,6 +8,7 @@ #define NAZARA_ANIMATION_HPP #include +#include #include #include #include @@ -98,7 +99,7 @@ namespace Nz static bool Initialize(); static void Uninitialize(); - AnimationImpl* m_impl = nullptr; + MovablePtr m_impl = nullptr; static AnimationLibrary::LibraryMap s_library; static AnimationLoader::LoaderList s_loaders; diff --git a/src/Nazara/Core/ConditionVariable.cpp b/src/Nazara/Core/ConditionVariable.cpp index 86ecb11ed..f4314870c 100644 --- a/src/Nazara/Core/ConditionVariable.cpp +++ b/src/Nazara/Core/ConditionVariable.cpp @@ -102,18 +102,4 @@ namespace Nz NazaraAssert(mutex != nullptr, "Mutex must be valid"); return m_impl->Wait(mutex->m_impl, timeout); } - - /*! - * \brief Moves a condition to another ConditionVariable object - * \return A reference to the object - */ - ConditionVariable& ConditionVariable::operator=(ConditionVariable&& condition) noexcept - { - delete m_impl; - - m_impl = condition.m_impl; - condition.m_impl = nullptr; - - return *this; - } } diff --git a/src/Nazara/Core/DynLib.cpp b/src/Nazara/Core/DynLib.cpp index 10e5d4247..1558f5a37 100644 --- a/src/Nazara/Core/DynLib.cpp +++ b/src/Nazara/Core/DynLib.cpp @@ -40,19 +40,6 @@ namespace Nz { } - /*! - * \brief Constructs a DynLib object by move semantic - * - * \param lib DynLib to move into this - */ - - DynLib::DynLib(DynLib&& lib) : - m_lastError(std::move(lib.m_lastError)), - m_impl(lib.m_impl) - { - lib.m_impl = nullptr; - } - /*! * \brief Destructs the object and calls Unload * @@ -150,23 +137,4 @@ namespace Nz m_impl = nullptr; } } - - /*! - * \brief Moves the other lib into this - * \return A reference to this - * - * \param lib DynLib to move in this - */ - - DynLib& DynLib::operator=(DynLib&& lib) - { - Unload(); - - m_impl = lib.m_impl; - m_lastError = std::move(lib.m_lastError); - - lib.m_impl = nullptr; - - return *this; - } } diff --git a/src/Nazara/Core/File.cpp b/src/Nazara/Core/File.cpp index 9aa9374e0..7ea5999eb 100644 --- a/src/Nazara/Core/File.cpp +++ b/src/Nazara/Core/File.cpp @@ -70,20 +70,6 @@ namespace Nz Open(filePath, openMode); } - /*! - * \brief Constructs a File object by move semantic - * - * \param file File to move into this - */ - - File::File(File&& file) noexcept : - Stream(std::move(file)), - m_filePath(std::move(file.m_filePath)), - m_impl(file.m_impl) - { - file.m_impl = nullptr; - } - /*! * \brief Destructs the object and calls Close * @@ -487,23 +473,6 @@ namespace Nz return *this; } - /*! - * \brief Moves the other file into this - * \return A reference to this - * - * \param file File to move in this - */ - - File& File::operator=(File&& file) noexcept - { - NazaraLock(m_mutex) - - std::swap(m_filePath, file.m_filePath); - std::swap(m_impl, file.m_impl); - - return *this; - } - /*! * \brief Gets the absolute path of the file * \return Absolute path of the file diff --git a/src/Nazara/Core/Mutex.cpp b/src/Nazara/Core/Mutex.cpp index 953568ecc..473ee233e 100644 --- a/src/Nazara/Core/Mutex.cpp +++ b/src/Nazara/Core/Mutex.cpp @@ -77,18 +77,4 @@ namespace Nz NazaraAssert(m_impl, "Cannot unlock a moved mutex"); m_impl->Unlock(); } - - /*! - * \brief Moves a mutex to another mutex object - * \return A reference to the object - */ - Mutex& Mutex::operator=(Mutex&& mutex) noexcept - { - delete m_impl; - - m_impl = mutex.m_impl; - mutex.m_impl = nullptr; - - return *this; - } } diff --git a/src/Nazara/Core/Thread.cpp b/src/Nazara/Core/Thread.cpp index d8b0ebd42..0f3e3dc78 100644 --- a/src/Nazara/Core/Thread.cpp +++ b/src/Nazara/Core/Thread.cpp @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -36,18 +37,6 @@ namespace Nz { } - /*! - * \brief Constructs a Thread object by move semantic - * - * \param other Thread to move into this - */ - - Thread::Thread(Thread&& other) noexcept : - m_impl(other.m_impl) - { - other.m_impl = nullptr; - } - /*! * \brief Waits that the thread ends and then destroys this */ @@ -136,30 +125,6 @@ namespace Nz m_impl->SetName(name); } - /*! - * \brief Moves the other thread into this - * \return A reference to this - * - * \param thread Thread to move in this - * - * \remark Produce a NazaraError if no functor was assigned and NAZARA_CORE_SAFE is defined - * \remark And call std::terminate if no functor was assigned and NAZARA_CORE_SAFE is defined - */ - - Thread& Thread::operator=(Thread&& thread) - { - #if NAZARA_CORE_SAFE - if (m_impl) - { - NazaraError("This thread cannot be joined"); - std::terminate(); - } - #endif - - std::swap(m_impl, thread.m_impl); - return *this; - } - /*! * \brief Gets the number of simulatenous threads that can run on the same cpu * \return The number of simulatenous threads diff --git a/src/Nazara/Renderer/GLX/ContextImpl.cpp b/src/Nazara/Renderer/GLX/ContextImpl.cpp index 8bff9793a..2f25e680d 100644 --- a/src/Nazara/Renderer/GLX/ContextImpl.cpp +++ b/src/Nazara/Renderer/GLX/ContextImpl.cpp @@ -50,7 +50,7 @@ namespace Nz } } - bool ContextImpl::Activate() + bool ContextImpl::Activate() const { return glXMakeCurrent(m_display, m_window, m_context) == true; } diff --git a/src/Nazara/Renderer/GLX/ContextImpl.hpp b/src/Nazara/Renderer/GLX/ContextImpl.hpp index 7508537d1..7aaf6409f 100644 --- a/src/Nazara/Renderer/GLX/ContextImpl.hpp +++ b/src/Nazara/Renderer/GLX/ContextImpl.hpp @@ -19,7 +19,7 @@ namespace Nz ContextImpl(); ~ContextImpl(); - bool Activate(); + bool Activate() const; bool Create(ContextParameters& parameters); diff --git a/src/Nazara/Renderer/Win32/ContextImpl.cpp b/src/Nazara/Renderer/Win32/ContextImpl.cpp index e99e672dc..9c50faabd 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.cpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.cpp @@ -20,7 +20,7 @@ namespace Nz { } - bool ContextImpl::Activate() + bool ContextImpl::Activate() const { return wglMakeCurrent(m_deviceContext, m_context) == TRUE; } diff --git a/src/Nazara/Renderer/Win32/ContextImpl.hpp b/src/Nazara/Renderer/Win32/ContextImpl.hpp index b9ac2c460..0f982f18c 100644 --- a/src/Nazara/Renderer/Win32/ContextImpl.hpp +++ b/src/Nazara/Renderer/Win32/ContextImpl.hpp @@ -18,7 +18,7 @@ namespace Nz public: ContextImpl(); - bool Activate(); + bool Activate() const; bool Create(ContextParameters& parameters); diff --git a/src/Nazara/Utility/Animation.cpp b/src/Nazara/Utility/Animation.cpp index eb53424fe..795604aff 100644 --- a/src/Nazara/Utility/Animation.cpp +++ b/src/Nazara/Utility/Animation.cpp @@ -88,8 +88,8 @@ namespace Nz { Joint* joint = targetSkeleton->GetJoint(i); - SequenceJoint& sequenceJointA = m_impl->sequenceJoints[frameA*m_impl->jointCount + i]; - SequenceJoint& sequenceJointB = m_impl->sequenceJoints[frameB*m_impl->jointCount + i]; + const SequenceJoint& sequenceJointA = m_impl->sequenceJoints[frameA*m_impl->jointCount + i]; + const SequenceJoint& sequenceJointB = m_impl->sequenceJoints[frameB*m_impl->jointCount + i]; joint->SetPosition(Vector3f::Lerp(sequenceJointA.position, sequenceJointB.position, interpolation)); joint->SetRotation(Quaternionf::Slerp(sequenceJointA.rotation, sequenceJointB.rotation, interpolation));