From 0c62070b24273e565cce112ab061df6665d3ae8c Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 27 Oct 2020 13:17:26 +0300 Subject: code style Don't use brace initialization in constructors, VS 2013 doesn't like that. --- test/unit_tests/shared/command.hpp | 21 ++++++++++----------- test/unit_tests/shared/console.hpp | 4 ++-- test/unit_tests/shared/fixed_size.hpp | 2 -- test/unit_tests/shared/worker.hpp | 33 ++++++++++++++++++++++++++++++++- 4 files changed, 44 insertions(+), 16 deletions(-) (limited to 'test/unit_tests/shared') diff --git a/test/unit_tests/shared/command.hpp b/test/unit_tests/shared/command.hpp index 266903f..4a91370 100644 --- a/test/unit_tests/shared/command.hpp +++ b/test/unit_tests/shared/command.hpp @@ -33,15 +33,6 @@ BOOST_STATIC_CONSTEXPR auto COMMAND_SHMEM_NAME = "shmem-test-cmd"; class Command { public: - typedef winapi::SharedObject Shared; - - static Shared create() { return Shared::create(COMMAND_SHMEM_NAME); } - static Shared open() { return Shared::open(COMMAND_SHMEM_NAME); } - - typedef boost::interprocess::interprocess_mutex mutex; - typedef boost::interprocess::interprocess_condition condition_variable; - typedef boost::interprocess::scoped_lock lock; - enum Action { EXIT = 1, GET_CONSOLE_WINDOW, @@ -62,8 +53,18 @@ public: fixed_size::StringList<> console_buffer; }; + typedef winapi::SharedObject Shared; + + typedef boost::interprocess::interprocess_mutex mutex; + typedef boost::interprocess::interprocess_condition condition_variable; + typedef boost::interprocess::scoped_lock lock; + typedef std::function SetArgs; typedef std::function ReadResult; + typedef std::function ProcessAction; + + static Shared create() { return Shared::create(COMMAND_SHMEM_NAME); } + static Shared open() { return Shared::open(COMMAND_SHMEM_NAME); } void get_result(Action action, const SetArgs& set_args, const ReadResult& read_result) { { @@ -104,8 +105,6 @@ public: return get_result(action, [](const Result&) {}); } - typedef std::function ProcessAction; - void process_action(const ProcessAction& callback) { { lock lck{m_mtx}; diff --git a/test/unit_tests/shared/console.hpp b/test/unit_tests/shared/console.hpp index faa887c..274c232 100644 --- a/test/unit_tests/shared/console.hpp +++ b/test/unit_tests/shared/console.hpp @@ -26,9 +26,9 @@ class Buffer { public: typedef CONSOLE_SCREEN_BUFFER_INFO Info; - Buffer() : m_handle{winapi::Handle::std_out()}, m_info(get_info(m_handle)) {} + Buffer() : m_handle(winapi::Handle::std_out()), m_info(get_info(m_handle)) {} - Buffer(winapi::Handle&& handle) : m_handle{std::move(handle)}, m_info(get_info(m_handle)) {} + Buffer(winapi::Handle&& handle) : m_handle(std::move(handle)), m_info(get_info(m_handle)) {} std::size_t get_columns() const { return m_info.dwSize.X; } diff --git a/test/unit_tests/shared/fixed_size.hpp b/test/unit_tests/shared/fixed_size.hpp index e4b11c7..ba9a128 100644 --- a/test/unit_tests/shared/fixed_size.hpp +++ b/test/unit_tests/shared/fixed_size.hpp @@ -38,8 +38,6 @@ public: // Lines are null-terminated, and don't store their lenghts, so... return data(); } - -private: }; // 5 lines to store is also arbitrary, set it higher if needed. diff --git a/test/unit_tests/shared/worker.hpp b/test/unit_tests/shared/worker.hpp index 320a924..a1067ac 100644 --- a/test/unit_tests/shared/worker.hpp +++ b/test/unit_tests/shared/worker.hpp @@ -9,6 +9,8 @@ #include +#include + #include #include @@ -20,7 +22,23 @@ namespace worker { class Worker { public: - Worker(winapi::Process&& process) : m_cmd{Command::create()}, m_process{std::move(process)} {} + Worker(winapi::Process&& process) : m_cmd(Command::create()), m_process(std::move(process)) {} + + Worker(Worker&& other) BOOST_NOEXCEPT_OR_NOTHROW : m_cmd(std::move(other.m_cmd)), + m_process(std::move(other.m_process)) {} + + Worker& operator=(Worker other) BOOST_NOEXCEPT_OR_NOTHROW { + swap(other); + return *this; + } + + void swap(Worker& other) BOOST_NOEXCEPT_OR_NOTHROW { + using std::swap; + swap(m_cmd, other.m_cmd); + swap(m_process, other.m_process); + } + + Worker(const Worker&) = delete; ~Worker() { try { @@ -83,4 +101,17 @@ private: winapi::Process m_process; }; +inline void swap(Worker& a, Worker& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + } // namespace worker + +namespace std { + +template <> +inline void swap(worker::Worker& a, worker::Worker& b) BOOST_NOEXCEPT_OR_NOTHROW { + a.swap(b); +} + +} // namespace std -- cgit v1.2.3