Skip to content
Flecs v4.1
signature.hpp
Go to the documentation of this file.
1/**
2 * @file addons/cpp/utils/signature.hpp
3 * @brief Compile-time utilities for deriving query attributes from a parameter pack.
4 */
5
6#pragma once
7
8namespace flecs {
9namespace _ {
10
11 template <typename T>
12 constexpr flecs::inout_kind_t type_to_inout() {
13 return is_const_p<T>::value ? flecs::In :
14 (is_reference<T>::value ? flecs::InOut : flecs::InOutDefault);
15 }
16
17 template <typename T>
18 constexpr flecs::oper_kind_t type_to_oper() {
19 return is_pointer<T>::value ? flecs::Optional : flecs::And;
20 }
21
22 template <typename... Components, typename Builder>
23 void populate_signature(flecs::world_t *world, Builder *builder) {
24 (void)world;
25 (void)builder;
26 (builder->with(_::type<remove_pointer_t<Components>>::id(world))
27 .inout(type_to_inout<Components>()).oper(type_to_oper<Components>()), ...);
28 }
29
30} // namespace _
31} // namespace flecs
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
Int to enum.
Definition component.hpp:18