Aria
2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Toggle main menu visibility
Loading...
Searching...
No Matches
slot.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
export.hpp
"
4
#include <cstddef>
5
#include <cstdint>
6
#include <utility>
7
8
namespace
aria::abi
{
9
12
struct
SlotId
{
13
std::uint64_t
value
= 0;
14
[[nodiscard]]
constexpr
bool
valid
() const noexcept {
return
value
!= 0; }
15
constexpr
bool
operator==
(
SlotId
rhs)
const
noexcept
{
return
value
== rhs.value; }
16
constexpr
bool
operator!=
(
SlotId
rhs)
const
noexcept
{
return
value
!= rhs.value; }
17
};
18
35
class
ARIA_ABI_API
SlotErased
{
36
public
:
37
using
Invoker
= void (*)(
void
* state,
void
* args)
noexcept
;
38
using
Destroyer
= void (*)(
void
* state)
noexcept
;
39
40
SlotErased
() noexcept = default;
41
42
SlotErased
(
Invoker
inv,
Destroyer
dtor,
void
* state) noexcept
43
: invoker_(inv), destroyer_(dtor), state_(state) {}
44
45
~SlotErased
() noexcept;
46
47
SlotErased
(
SlotErased
&& o) noexcept;
48
SlotErased
& operator=(
SlotErased
&& o) noexcept;
49
50
SlotErased
(const
SlotErased
&) = delete;
51
SlotErased
& operator=(const
SlotErased
&) = delete;
52
53
void
invoke
(
void
* args) const noexcept {
54
if
(
ARIA_LIKELY
(invoker_)) invoker_(state_, args);
55
}
56
57
[[nodiscard]]
bool
empty
() const noexcept {
return
invoker_ ==
nullptr
; }
58
59
private
:
60
Invoker invoker_ =
nullptr
;
61
Destroyer destroyer_ =
nullptr
;
62
void
* state_ =
nullptr
;
63
};
64
65
}
// namespace aria::abi
aria::abi::SlotErased::Destroyer
void(*)(void *state) noexcept Destroyer
Definition
slot.hpp:38
aria::abi::SlotErased::Invoker
void(*)(void *state, void *args) noexcept Invoker
Definition
slot.hpp:37
aria::abi::SlotErased::~SlotErased
~SlotErased() noexcept
aria::abi::SlotErased::empty
bool empty() const noexcept
Definition
slot.hpp:57
aria::abi::SlotErased::invoke
void invoke(void *args) const noexcept
Definition
slot.hpp:53
aria::abi::SlotErased::SlotErased
SlotErased() noexcept=default
export.hpp
ARIA_ABI_API
#define ARIA_ABI_API
Definition
export.hpp:21
ARIA_LIKELY
#define ARIA_LIKELY(x)
Definition
export.hpp:96
aria::abi
Definition
signal.hpp:12
aria::abi::SlotId
Opaque slot identifier returned when a callback is registered with a Signal.
Definition
slot.hpp:12
aria::abi::SlotId::operator==
constexpr bool operator==(SlotId rhs) const noexcept
Definition
slot.hpp:15
aria::abi::SlotId::valid
constexpr bool valid() const noexcept
Definition
slot.hpp:14
aria::abi::SlotId::operator!=
constexpr bool operator!=(SlotId rhs) const noexcept
Definition
slot.hpp:16
aria::abi::SlotId::value
std::uint64_t value
Definition
slot.hpp:13
modules
abi
include
aria
abi
slot.hpp
Generated by
1.18.0