diff options
author | Egor Tensin <Egor.Tensin@gmail.com> | 2015-05-11 13:32:30 +0300 |
---|---|---|
committer | Egor Tensin <Egor.Tensin@gmail.com> | 2015-05-11 13:32:30 +0300 |
commit | 9bf7f2bfeb3057ad8b49fc0361fee5036639dfe1 (patch) | |
tree | 5b13e2c7a9ec6298da8050c217009517e25f10c4 /utils/libservice/include/libservice/device.hpp | |
parent | nt_path_converter: logging & \0-termination (diff) | |
download | windows7-drivers-9bf7f2bfeb3057ad8b49fc0361fee5036639dfe1.tar.gz windows7-drivers-9bf7f2bfeb3057ad8b49fc0361fee5036639dfe1.zip |
libservice: add virtual device wrappers
Diffstat (limited to '')
-rw-r--r-- | utils/libservice/include/libservice/device.hpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/utils/libservice/include/libservice/device.hpp b/utils/libservice/include/libservice/device.hpp new file mode 100644 index 0000000..3a9540e --- /dev/null +++ b/utils/libservice/include/libservice/device.hpp @@ -0,0 +1,71 @@ +/** + * \file + * \author Egor Tensin <Egor.Tensin@gmail.com> + * \date 2015 + * \copyright This file is licensed under the terms of the MIT License. + * See LICENSE.txt for details. + */ + +#pragma once + +#include "common.hpp" +#include "handle.hpp" + +#include <Windows.h> + +#include <string> +#include <utility> + +namespace libservice +{ + class Device + { + public: + static Device open(const std::string& path); + + Device(Device&& other) LIBSERVICE_NOEXCEPT + { + swap(other); + } + + Device& operator=(Device other) LIBSERVICE_NOEXCEPT + { + swap(other); + return *this; + } + + void swap(Device& other) LIBSERVICE_NOEXCEPT + { + using std::swap; + swap(m_handle, other.m_handle); + } + + DWORD get_required_output_size(DWORD code, + const void* in_buf, + DWORD in_buf_size) const; + + DWORD send_control_code(DWORD code, + const void* in_buf, + DWORD in_buf_size, + void* out_buf, + DWORD out_buf_size) const; + + private: + explicit Device(Handle h) + : m_handle(std::move(h)) + { } + + Handle m_handle; + + Device(const Device&) = delete; + }; + + void swap(libservice::Device&, libservice::Device&) LIBSERVICE_NOEXCEPT; +} + +namespace std +{ + template <> + void swap<libservice::Device>( + libservice::Device&, libservice::Device&) LIBSERVICE_NOEXCEPT; +} |