Skip to content
Flecs v4.1
mixin.inl
Go to the documentation of this file.
1/**
2 * @file addons/cpp/mixins/query/mixin.inl
3 * @brief Query world mixin.
4 */
5
6/**
7 * @memberof flecs::world
8 * @ingroup cpp_core_queries
9 *
10 * @{
11 */
12
13/** Create a query.
14 * Returns a flecs::sparse_query when all components have the dont_fragment
15 * trait and don't declare the on_instantiate::inherit policy.
16 *
17 * @see ecs_query_init()
18 */
19template <typename... Comps, typename... Args>
20conditional_t<sizeof...(Args) == 0 && _::is_sparse_query<Comps...>::value,
22query(Args &&... args) const;
23
24/** Create a query from an entity.
25 *
26 * @see ecs_query_init()
27 */
29
30/** Create a query builder.
31 *
32 * @see ecs_query_init()
33 */
34template <typename... Comps, typename... Args>
35flecs::query_builder<Comps...> query_builder(Args &&... args) const;
36
37/** Iterate over all entities with components in the argument list of the function.
38 * The function parameter must match the following signature:
39 *
40 * @code
41 * void(*)(flecs::entity)
42 * @endcode
43 *
44 * or:
45 *
46 * @code
47 * void(*)(T&, U&, ...)
48 * @endcode
49 *
50 * or:
51 *
52 * @code
53 * void(*)(flecs::entity, T&, U&, ...)
54 * @endcode
55 *
56 */
57template <typename Func>
58void each(Func&& func) const;
59
60/** Iterate over all entities with the provided component.
61 * The function parameter must match the following signature:
62 *
63 * @code
64 * void(*)(T&)
65 * @endcode
66 *
67 * or:
68 *
69 * @code
70 * void(*)(flecs::entity, T&)
71 * @endcode
72 *
73 */
74template <typename T, typename Func>
75void each(Func&& func) const;
76
77/** Iterate over all entities with the provided (component) ID. */
78template <typename Func>
79void each(flecs::id_t term_id, Func&& func) const;
80
81/** @} */
ecs_id_t id_t
ID type.
Definition c_types.hpp:20
Entity.
Definition entity.hpp:30
Query builder.
Definition builder.hpp:24
Typed query.
Definition impl.hpp:266
Query that iterates sparse component storages directly.
flecs::query_builder< Comps... > query_builder(Args &&... args) const
Create a query builder.
void each(Func &&func) const
Iterate over all entities with components in the argument list of the function.
void each(flecs::id_t term_id, Func &&func) const
Iterate over all entities with the provided (component) ID.
void each(Func &&func) const
Iterate over all entities with the provided component.
flecs::query query(flecs::entity query_entity) const
Create a query from an entity.
conditional_t< sizeof...(Args)==0 &&_::is_sparse_query< Comps... >::value, flecs::sparse_query< Comps... >, flecs::query< Comps... > > query(Args &&... args) const
Create a query.