Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
signature.hpp
Go to the documentation of this file.
1
6#pragma once
7
8namespace flecs {
9namespace _ {
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() {
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 {
40 : world_(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
ecs_id_t id_t
ID type.
Definition c_types.hpp:20
oper_kind_t
Operator kind.
Definition c_types.hpp:49
ecs_world_t world_t
World type.
Definition c_types.hpp:18
inout_kind_t
Inout kind.
Definition c_types.hpp:39
@ And
And operator.
Definition c_types.hpp:50
@ Optional
Optional operator.
Definition c_types.hpp:53
@ In
In.
Definition c_types.hpp:44
@ InOutDefault
InOutDefault.
Definition c_types.hpp:40
@ InOut
InOut.
Definition c_types.hpp:43
Array class (primary template, disabled).
Definition array.hpp:47
The world.
Definition world.hpp:246
enable_if_t< false==V, int > if_not_t
Convenience enable_if alias for negated conditions.
Definition utils.hpp:172