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