Flecs v4.0
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() {
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)
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
The world.
Definition world.hpp:150