HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
callback_flags.hpp
1// Copyright Take Vos 2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../utility/utility.hpp"
8#include "../macros.hpp"
9
10
11
12namespace hi::inline v1 {
13
14enum class callback_flags {
17 synchronous = 0x00,
18
21 local = 0x01,
22
25 main = 0x02,
26
29 timer = 0x03,
30
33 once = 0x1'00,
34};
35
36[[nodiscard]] constexpr callback_flags operator|(callback_flags const &lhs, callback_flags const &rhs) noexcept
37{
38 hi_assert((std::to_underlying(lhs) & 0xff) == 0 or (std::to_underlying(rhs) & 0xff) == 0);
39 return static_cast<callback_flags>(std::to_underlying(lhs) | std::to_underlying(rhs));
40}
41
42[[nodiscard]] constexpr bool is_once(callback_flags const &rhs) noexcept
43{
44 return to_bool(std::to_underlying(rhs) & std::to_underlying(callback_flags::once));
45}
46
47[[nodiscard]] constexpr bool is_synchronous(callback_flags const& rhs) noexcept
48{
49 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::synchronous));
50}
51
52[[nodiscard]] constexpr bool is_local(callback_flags const& rhs) noexcept
53{
54 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::local));
55}
56
57[[nodiscard]] constexpr bool is_main(callback_flags const& rhs) noexcept
58{
59 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::main));
60}
61
62[[nodiscard]] constexpr bool is_timer(callback_flags const& rhs) noexcept
63{
64 return to_bool((std::to_underlying(rhs) & 0xff) == std::to_underlying(callback_flags::timer));
65}
66
67}
DOXYGEN BUG.
Definition algorithm.hpp:16
callback_flags
Definition callback_flags.hpp:14
@ synchronous
Call the function synchronously.
@ timer
Call the function asynchronously from the timer thread's loop.
@ once
Call the function once, then automatically unsubscribe.
@ local
Call the function asynchronously from the current thread's loop.
@ main
Call the function asynchronously from the main thread's loop.
constexpr Out narrow_cast(In const &rhs) noexcept
Cast numeric values without loss of precision.
Definition cast.hpp:377