8#include <boost/asio.hpp>
9#include <boost/asio/any_io_executor.hpp>
10#include <boost/asio/use_awaitable.hpp>
11#include <boost/asio/use_future.hpp>
12#include <boost/thread/future.hpp>
18#include <magic_enum/magic_enum.hpp>
27 template <std::
size_t bit_size, std::
size_t max, std::
size_t min = 0>
28 constexpr auto subset(
const std::bitset<bit_size>& bits) -> std::bitset<max - min>
30 constexpr auto max_size = 64;
31 static_assert(max > min);
32 static_assert(max_size >= (max - min));
33 constexpr auto ignore_high = bit_size - max;
35 auto new_bits = (bits << ignore_high) >> (ignore_high + min);
36 return std::bitset<max - min>{ new_bits.to_ullong() };
39 template <std::
size_t high_size, std::
size_t low_size>
40 constexpr auto merge_bits(
const std::bitset<high_size>& high_bits,
const std::bitset<low_size>& low_bits)
41 -> std::bitset<high_size + low_size>
43 using NewBit = std::bitset<high_size + low_size>;
44 constexpr auto max_size = 64;
45 static_assert(max_size >= high_size + low_size);
47 auto high_bits_part = NewBit(high_bits.to_ullong());
48 auto low_bits_part = NewBit(low_bits.to_ullong());
49 auto new_bits = (high_bits_part << low_size) | low_bits_part;
50 return std::bitset<high_size + low_size>(new_bits.to_ullong());
53 template <std::
size_t low_size, std::
size_t total_size>
55 constexpr auto get_low_bits(
const std::bitset<total_size>& bits) -> std::bitset<low_size>
57 constexpr auto high_size = total_size - low_size;
58 const auto low_bits = std::bitset<low_size>{ ((bits << high_size) >> high_size).to_ullong() };
62 template <std::
size_t high_size, std::
size_t total_size>
64 constexpr auto get_high_bits(
const std::bitset<total_size>& bits) -> std::bitset<high_size>
66 constexpr auto low_size = total_size - high_size;
67 const auto high_bits = std::bitset<high_size>{ (bits >> low_size).to_ullong() };
71 template <std::
size_t bit_size>
72 constexpr auto byte_swap(
const std::bitset<bit_size>& bits)
74 auto val = bits.to_ullong();
76 val = std::byteswap(val);
77 return std::bitset<bit_size>(val);
83 auto bin_val = T{ gray_val };
95 return bin_val ^ (bin_val >> 1U);
100 return std::static_pointer_cast<std::remove_cvref_t<
decltype(obj)>>(obj.shared_from_this());
103 template <
typename Enum>
106 auto names = magic_enum::enum_names<srs::common::ActionMode>();
112 auto filepath = std::filesystem::path{ native_name };
113 auto extension = filepath.extension().string();
114 auto file_basename = filepath.replace_extension().string();
115 return std::format(
"{}_{}{}", file_basename, idx, extension);
121 auto task_handle = task();
122 using input_type =
decltype(task_handle)::input_type;
123 asio::co_spawn(executor, task_handle.async_resume(input_type{}, asio::use_awaitable), asio::use_future).get();
constexpr auto binary_to_gray(T bin_val)
constexpr auto get_low_bits(const std::bitset< total_size > &bits) -> std::bitset< low_size >
constexpr auto gray_to_binary(T gray_val)
constexpr auto subset(const std::bitset< bit_size > &bits) -> std::bitset< max - min >
constexpr auto merge_bits(const std::bitset< high_size > &high_bits, const std::bitset< low_size > &low_bits) -> std::bitset< high_size+low_size >
constexpr auto BYTE_BIT_LENGTH
constexpr auto insert_index_to_filename(std::string_view native_name, int idx) -> std::string
constexpr auto byte_swap(const std::bitset< bit_size > &bits)
auto create_coro_task(auto task, const asio::any_io_executor &executor)
consteval auto get_enum_names()
constexpr auto get_shared_from_this(auto &&obj)
constexpr auto get_high_bits(const std::bitset< total_size > &bits) -> std::bitset< high_size >