8 GAIA_NODISCARD
inline Entity typed_query_raw_entity(World& world) {
9 using U =
typename component_type_t<T>::Type;
10 static_assert(core::is_raw_v<U>,
"Use raw types only");
12 const auto& desc = comp_cache_add<T>(world);
16 template <
typename Rel,
typename Tgt>
17 GAIA_NODISCARD
inline Entity typed_query_pair_entity(World& world) {
18 using URel =
typename component_type_t<Rel>::Type;
19 using UTgt =
typename component_type_t<Tgt>::Type;
20 static_assert(core::is_raw_v<URel>,
"Use raw relation types only");
21 static_assert(core::is_raw_v<UTgt>,
"Use raw target types only");
23 const auto& descRel = comp_cache_add<Rel>(world);
24 const auto& descTgt = comp_cache_add<Tgt>(world);
25 return Pair(descRel.entity, descTgt.entity);
29 GAIA_NODISCARD
inline Entity typed_query_term_entity(World& world) {
30 using FT =
typename component_type_t<T>::TypeFull;
32 return typed_query_pair_entity<typename FT::rel_type, typename FT::tgt_type>(world);
34 return typed_query_raw_entity<T>(world);
38 GAIA_NODISCARD
inline QueryTermOptions typed_query_term_options(QueryOpKind op, QueryTermOptions options) {
39 if (op != QueryOpKind::Not && op != QueryOpKind::Any && options.access == QueryAccess::None) {
40 constexpr auto isReadWrite = core::is_mut_v<T>;
41 options.access = isReadWrite ? QueryAccess::Write : QueryAccess::Read;
47 inline QueryImpl&
QueryImpl::all(
const QueryTermOptions& options) {
49 typed_query_term_entity<T>(*m_storage.world()), typed_query_term_options<T>(QueryOpKind::All, options));
54 return all<T>(QueryTermOptions{});
58 inline QueryImpl&
QueryImpl::any(
const QueryTermOptions& options) {
60 typed_query_term_entity<T>(*m_storage.world()), typed_query_term_options<T>(QueryOpKind::Any, options));
65 return any<T>(QueryTermOptions{});
69 inline QueryImpl&
QueryImpl::or_(
const QueryTermOptions& options) {
71 typed_query_term_entity<T>(*m_storage.world()), typed_query_term_options<T>(QueryOpKind::Or, options));
76 return or_<T>(QueryTermOptions{});
80 inline QueryImpl&
QueryImpl::no(
const QueryTermOptions& options) {
82 typed_query_term_entity<T>(*m_storage.world()), typed_query_term_options<T>(QueryOpKind::Not, options));
87 return no<T>(QueryTermOptions{});
92 return changed(typed_query_raw_entity<T>(*m_storage.world()));
97 using UO =
typename component_type_t<T>::TypeOriginal;
98 if constexpr (std::is_same_v<UO, Entity>)
99 return sort_by(EntityBad, func);
101 return sort_by(typed_query_raw_entity<T>(*m_storage.world()), func);
104 template <
typename Rel,
typename Tgt>
106 return sort_by(typed_query_pair_entity<Rel, Tgt>(*m_storage.world()), func);
109 template <
typename Rel>
111 return depth_order(typed_query_raw_entity<Rel>(*m_storage.world()));
114 template <
typename Rel>
116 return order_by(typed_query_raw_entity<Rel>(*m_storage.world()), order);
119 template <
typename T>
121 return group_by(typed_query_raw_entity<T>(*m_storage.world()), func);
124 template <
typename Rel,
typename Tgt>
126 return group_by(typed_query_pair_entity<Rel, Tgt>(*m_storage.world()), func);
129 template <
typename Rel>
131 return group_dep(typed_query_raw_entity<Rel>(*m_storage.world()));
134 template <
typename T>
136 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:5915
QueryImpl & or_()
Adds an OR typed term.
QueryImpl & any()
Adds an optional typed term.
QueryImpl & all()
Adds a required typed term.
GAIA_NODISCARD OrderByTravView order_by(Entity relation, TravOrder order)
Iterates matching entities in an explicit relation traversal order.
Definition query.h:5978
QueryImpl & group_dep()
Declares an explicit relation dependency for grouped cache invalidation. Useful for custom group_by c...
QueryImpl & no()
Adds an excluded typed term.
QueryImpl & group_id()
Selects the group to iterate over.
QueryImpl & changed()
Marks a typed term for changed() filtering.
QueryImpl & depth_order()
Orders cached query entries by fragmenting relation depth so iteration runs breadth-first top-down.
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:6020
static constexpr bool value
True when the type derives from the pair base.
Definition id.h:287