7 GAIA_NODISCARD
inline Entity typed_query_raw_entity(World& world) {
8 using U =
typename component_type_t<T>::Type;
9 static_assert(core::is_raw_v<U>,
"Use raw types only");
11 const auto& desc = comp_cache_add<T>(world);
15 template <
typename Rel,
typename Tgt>
16 GAIA_NODISCARD
inline Entity typed_query_pair_entity(World& world) {
17 using URel =
typename component_type_t<Rel>::Type;
18 using UTgt =
typename component_type_t<Tgt>::Type;
19 static_assert(core::is_raw_v<URel>,
"Use raw relation types only");
20 static_assert(core::is_raw_v<UTgt>,
"Use raw target types only");
22 const auto& descRel = comp_cache_add<Rel>(world);
23 const auto& descTgt = comp_cache_add<Tgt>(world);
24 return Pair(descRel.entity, descTgt.entity);
28 GAIA_NODISCARD
inline Entity typed_query_term_entity(World& world) {
29 using FT =
typename component_type_t<T>::TypeFull;
30 if constexpr (is_pair<FT>::value)
31 return typed_query_pair_entity<typename FT::rel_type, typename FT::tgt_type>(world);
33 return typed_query_raw_entity<T>(world);
37 GAIA_NODISCARD
inline QueryTermOptions typed_query_term_options(QueryOpKind op, QueryTermOptions options) {
38 if (op != QueryOpKind::Not && op != QueryOpKind::Any && options.access == QueryAccess::None) {
39 constexpr auto isReadWrite = core::is_mut_v<T>;
40 options.
access = isReadWrite ? QueryAccess::Write : QueryAccess::Read;
48 typed_query_term_entity<T>(*m_storage.
world()), typed_query_term_options<T>(QueryOpKind::All, options));
59 typed_query_term_entity<T>(*m_storage.
world()), typed_query_term_options<T>(QueryOpKind::Any, options));
70 typed_query_term_entity<T>(*m_storage.
world()), typed_query_term_options<T>(QueryOpKind::Or, options));
81 typed_query_term_entity<T>(*m_storage.
world()), typed_query_term_options<T>(QueryOpKind::Not, options));
91 return changed(typed_query_raw_entity<T>(*m_storage.
world()));
96 using UO =
typename component_type_t<T>::TypeOriginal;
97 if constexpr (std::is_same_v<UO, Entity>)
98 return sort_by(EntityBad, func);
100 return sort_by(typed_query_raw_entity<T>(*m_storage.
world()), func);
103 template <
typename Rel,
typename Tgt>
105 return sort_by(typed_query_pair_entity<Rel, Tgt>(*m_storage.
world()), func);
108 template <
typename Rel>
113 template <
typename Rel>
115 return order_by(typed_query_raw_entity<Rel>(*m_storage.
world()), order);
118 template <
typename T>
120 return group_by(typed_query_raw_entity<T>(*m_storage.
world()), func);
123 template <
typename Rel,
typename Tgt>
125 return group_by(typed_query_pair_entity<Rel, Tgt>(*m_storage.
world()), func);
128 template <
typename Rel>
130 return group_dep(typed_query_raw_entity<Rel>(*m_storage.
world()));
133 template <
typename T>
135 return group_id(typed_query_raw_entity<T>(*m_storage.
world()));
QueryImpl & sort_by(Entity entity, TSortByFunc func)
Sorts the query by the specified entity and function.
Definition query.h:5709
QueryImpl & or_()
Adds an OR typed term.
Definition query_builder_typed.inl:74
QueryImpl & any()
Adds an optional typed term.
Definition query_builder_typed.inl:63
QueryImpl & all()
Adds a required typed term.
Definition query_builder_typed.inl:52
GAIA_NODISCARD OrderByTravView order_by(Entity relation, TravOrder order)
Iterates matching entities in an explicit relation traversal order.
Definition query.h:5769
QueryImpl & group_dep()
Declares an explicit relation dependency for grouped cache invalidation. Useful for custom group_by c...
Definition query_builder_typed.inl:129
QueryImpl & no()
Adds an excluded typed term.
Definition query_builder_typed.inl:85
QueryImpl & group_id()
Selects the group to iterate over.
Definition query_builder_typed.inl:134
QueryImpl & changed()
Marks a typed term for changed() filtering.
Definition query_builder_typed.inl:90
QueryImpl & depth_order()
Orders cached query entries by fragmenting relation depth so iteration runs breadth-first top-down.
Definition query_builder_typed.inl:109
QueryImpl & group_by(Entity entity, TGroupByFunc func=group_by_func_default)
Organizes matching archetypes into groups according to the grouping function and entity....
Definition query.h:5811
Checks if endianess was detected correctly at compile-time.
Definition bitset.h:9
Additional options for query terms. This can be used to configure source lookup, traversal and access...
Definition query_common.h:271
QueryAccess access
Access mode for the term. When None, typed query terms infer read/write access from template mutabili...
Definition query_common.h:285
GAIA_NODISCARD World * world()
Returns the world associated with this query storage.
Definition query.h:389