Flecs
v4.1
A fast entity component system (ECS) for C & C++
Toggle main menu visibility
Loading...
Searching...
No Matches
signature.hpp
Go to the documentation of this file.
1
5
6
#pragma once
7
8
namespace
flecs {
9
namespace
_
{
10
11
template <typename T, if_t< is_const_p<T>::value > = 0>
12
constexpr
flecs::inout_kind_t
type_to_inout() {
13
return
flecs::In
;
14
}
15
16
template <typename T, if_t< is_reference<T>::value > = 0>
17
constexpr
flecs::inout_kind_t
type_to_inout() {
18
return
flecs::InOut
;
19
}
20
21
template
<
typename
T,
if_not_t
<
22
is_const_p<T>::value || is_reference<T>::value > = 0>
23
constexpr
flecs::inout_kind_t
type_to_inout() {
24
return
flecs::InOutDefault
;
25
}
26
27
template <typename T, if_t< is_pointer<T>::value > = 0>
28
constexpr
flecs::oper_kind_t
type_to_oper() {
29
return
flecs::Optional
;
30
}
31
32
template <typename T, if_not_t< is_pointer<T>::value > = 0>
33
constexpr
flecs::oper_kind_t
type_to_oper() {
34
return
flecs::And
;
35
}
36
37
template
<
typename
... Components>
38
struct
sig {
39
sig(
flecs::world_t
*
world
)
40
: world_(
world
)
41
, ids({ (
_::type<remove_pointer_t<Components>
>
::id
(
world
))... })
42
, inout ({ (type_to_inout<Components>())... })
43
, oper ({ (type_to_oper<Components>())... })
44
{ }
45
46
flecs::world_t
*world_;
47
flecs::array
<
flecs::id_t
,
sizeof
...(Components)> ids;
48
flecs::array
<
flecs::inout_kind_t
,
sizeof
...(Components)> inout;
49
flecs::array
<
flecs::oper_kind_t
,
sizeof
...(Components)> oper;
50
51
template
<
typename
Builder>
52
void
populate(
const
Builder& b) {
53
size_t
i = 0;
54
for
(
auto
id
: ids) {
55
b->with(
id
).inout(inout[i]).oper(oper[i]);
56
i ++;
57
}
58
}
59
};
60
61
}
// namespace _
62
}
// namespace flecs
flecs::id_t
ecs_id_t id_t
ID type.
Definition
c_types.hpp:20
flecs::oper_kind_t
oper_kind_t
Operator kind.
Definition
c_types.hpp:49
flecs::world_t
ecs_world_t world_t
World type.
Definition
c_types.hpp:18
flecs::inout_kind_t
inout_kind_t
Inout kind.
Definition
c_types.hpp:39
flecs::And
@ And
And operator.
Definition
c_types.hpp:50
flecs::Optional
@ Optional
Optional operator.
Definition
c_types.hpp:53
flecs::In
@ In
In.
Definition
c_types.hpp:44
flecs::InOutDefault
@ InOutDefault
InOutDefault.
Definition
c_types.hpp:40
flecs::InOut
@ InOut
InOut.
Definition
c_types.hpp:43
flecs::_
Int to enum.
Definition
component.hpp:18
flecs::_::type
Definition
flecs.hpp:39
flecs::array
Array class (primary template, disabled).
Definition
array.hpp:47
flecs::id
Class that wraps around a flecs::id_t.
Definition
decl.hpp:27
flecs::world
The world.
Definition
world.hpp:246
flecs::if_not_t
enable_if_t< false==V, int > if_not_t
Convenience enable_if alias for negated conditions.
Definition
utils.hpp:172