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/module.hpp"
8
9namespace hi::inline v1 {
10
11enum class callback_flags {
14 synchronous = 0x00,
15
18 local = 0x01,
19
22 main = 0x02,
23
26 timer = 0x03,
27
30 once = 0x1'00,
31};
32
33[[nodiscard]] constexpr callback_flags operator|(callback_flags const &lhs, callback_flags const &rhs) noexcept
34{
35 hi_assert((to_underlying(lhs) & 0xff) == 0 or (to_underlying(rhs) & 0xff) == 0);
36 return static_cast<callback_flags>(to_underlying(lhs) | to_underlying(rhs));
37}
38
39[[nodiscard]] constexpr bool is_once(callback_flags const &rhs) noexcept
40{
41 return to_bool(to_underlying(rhs) & to_underlying(callback_flags::once));
42}
43
44[[nodiscard]] constexpr bool is_synchronous(callback_flags const& rhs) noexcept
45{
46 return to_bool((to_underlying(rhs) & 0xff) == to_underlying(callback_flags::synchronous));
47}
48
49[[nodiscard]] constexpr bool is_local(callback_flags const& rhs) noexcept
50{
51 return to_bool((to_underlying(rhs) & 0xff) == to_underlying(callback_flags::local));
52}
53
54[[nodiscard]] constexpr bool is_main(callback_flags const& rhs) noexcept
55{
56 return to_bool((to_underlying(rhs) & 0xff) == to_underlying(callback_flags::main));
57}
58
59[[nodiscard]] constexpr bool is_timer(callback_flags const& rhs) noexcept
60{
61 return to_bool((to_underlying(rhs) & 0xff) == to_underlying(callback_flags::timer));
62}
63
64}
#define hi_assert(expression,...)
Assert if expression is true.
Definition assert.hpp:199
DOXYGEN BUG.
Definition algorithm.hpp:13
callback_flags
Definition callback_flags.hpp:11
@ 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.