1#ifndef MSTL_CORE_SYSTEM_DEVICE_DEVICE_CONSTANTS_HPP__
2#define MSTL_CORE_SYSTEM_DEVICE_DEVICE_CONSTANTS_HPP__
3#include "MSTL/core/file/path.hpp"
7enum class DEVICE_TYPE {
18string MSTL_API to_string(DEVICE_TYPE type);
20DEVICE_TYPE MSTL_API to_device_t(
const string& str);
23enum class DEVICE_OPEN_MODE {
30enum class DEVICE_OPEN_FLAG :
uint32_t {
40constexpr DEVICE_OPEN_FLAG
operator|(DEVICE_OPEN_FLAG a, DEVICE_OPEN_FLAG b) {
41 return static_cast<DEVICE_OPEN_FLAG
>(
45constexpr DEVICE_OPEN_FLAG
operator&(DEVICE_OPEN_FLAG a, DEVICE_OPEN_FLAG b) {
46 return static_cast<DEVICE_OPEN_FLAG
>(
50enum class DEVICE_IO_DIRECT {
56enum class DEVICE_EVENT {
70 DEVICE_TYPE type{DEVICE_TYPE::UNKNOWN};
76 bool removable{
false};
78 bool exclusive{
false};
84#ifdef MSTL_PLATFORM_WINDOWS__
85 using native_type = ::DWORD;
87 using native_type =
unsigned long;
90 explicit ioctl_command(native_type code,
const void* in_data =
nullptr,
91 size_t in_size = 0,
void* out_data =
nullptr,
size_t out_size = 0)
92 : code_(code), in_data_(in_data), in_size_(in_size),
93 out_data_(out_data), out_size_(out_size) {}
95 MSTL_NODISCARD native_type code() const noexcept {
return code_; }
96 MSTL_NODISCARD
const void* in_data() const noexcept {
return in_data_; }
97 MSTL_NODISCARD
size_t in_size() const noexcept {
return in_size_; }
98 MSTL_NODISCARD
void* out_data() const noexcept {
return out_data_; }
99 MSTL_NODISCARD
size_t out_size() const noexcept {
return out_size_; }
101 template <
typename T>
102 static ioctl_command make(native_type code,
const T&
data) {
103 return ioctl_command(code, &
data,
sizeof(T));
106 template <
typename T>
107 static ioctl_command make_with_output(native_type code, T& output) {
108 return ioctl_command(code,
nullptr, 0, &output,
sizeof(T));
113 const void* in_data_;
120using device_event_callback =
function<void(DEVICE_EVENT)>;
121using data_received_callback =
function<void(
const void*,
size_t)>;
122using io_completion_callback =
function<void(
size_t,
int)>;
unsigned int uint32_t
32位无符号整数类型
unsigned short uint16_t
16位无符号整数类型
unsigned long long uint64_t
64位无符号整数类型
constexpr memory_order operator|(memory_order mo, memory_order_modifier mod) noexcept
内存顺序与修饰符的或操作符
constexpr memory_order operator&(memory_order mo, memory_order_modifier mod) noexcept
内存顺序与修饰符的与操作符
#define _MSTL
全局命名空间MSTL前缀
#define MSTL_END_NAMESPACE__
结束全局命名空间MSTL
#define MSTL_BEGIN_NAMESPACE__
开始全局命名空间MSTL
MSTL_NODISCARD MSTL_ALWAYS_INLINE constexpr decltype(auto) data(Container &cont) noexcept(noexcept(cont.data()))
获取容器的底层数据指针