Core: Add MovablePtr class

This commit is contained in:
Lynix
2017-09-30 13:57:25 +02:00
parent f95fc332f1
commit 2cd9fa2b7a
29 changed files with 157 additions and 259 deletions

View File

@@ -11,6 +11,7 @@
#include <Nazara/Prerequesites.hpp>
#include <Nazara/Core/ConditionVariable.hpp>
#include <Nazara/Core/MovablePtr.hpp>
#include <Nazara/Core/Mutex.hpp>
#include <Nazara/Core/String.hpp>
#include <Nazara/Math/Vector2.hpp>
@@ -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<WindowImpl> m_impl;
private:
void IgnoreNextMouseEvent(int mouseX, int mouseY) const;

View File

@@ -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 <Nazara/Platform/DebugOff.hpp>