Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches
helios::ecs::BasicQuery< WorldT, Allocator, Args > Class Template Reference

Query result object for iterating over matching entities and components. More...

#include <query.hpp>

Public Types

using ComponentManagerType = typename TypeInfo::ComponentManagerType
using WithEntityIterator
using iterator = typename TypeInfo::template Iterator<kIsConst>
using const_iterator = typename TypeInfo::template Iterator<true>
using value_type = typename TypeInfo::ValueType
using difference_type = std::iter_difference_t<iterator>
using pointer = typename iterator::pointer
using reference = std::iter_reference_t<iterator>
using allocator_type = Allocator

Public Member Functions

 BasicQuery (ComponentManagerType &components, Allocator alloc={})
 Constructs query with the given component manager and allocator.
 BasicQuery (ComponentManagerType &components, std::pmr::memory_resource *resource)
 Constructs query from a PMR memory resource.
 BasicQuery (ComponentManagerType &, std::nullptr_t)=delete
 BasicQuery (const BasicQuery &)=delete
 BasicQuery (BasicQuery &&) noexcept=default
 ~BasicQuery ()=default
BasicQueryoperator= (const BasicQuery &)=delete
BasicQueryoperator= (BasicQuery &&) noexcept=default
auto WithEntity () &noexcept -> BasicQueryWithEntity< WorldT, Allocator, Args... >
 Creates wrapper for entity-aware iteration.
auto Get (Entity entity) const -> typename BasicQuery< WorldT, Allocator, Args... >::value_type
 Gets all query components for a specific entity (ignores query filters).
auto TryGet (Entity entity) const -> std::optional< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
 Tries to get all query components for a specific entity (ignores query filters).
auto TryGetFiltered (Entity entity) const -> std::optional< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
 Tries to get all query components for a specific entity while respecting query filters.
auto Collect () const -> std::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
 Collects all results into a vector.
template<typename ResultAlloc>
requires std::same_as< typename ResultAlloc::value_type, typename BasicQuery<WorldT, Allocator, Args...>::value_type> &&
(!std::derived_from<std::remove_pointer_t<ResultAlloc>, std::pmr::memory_resource>)
auto CollectWith (ResultAlloc alloc) const -> std::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type, ResultAlloc >
 Collects all results using a custom allocator.
auto CollectWith (std::pmr::memory_resource *resource) const -> std::pmr::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
 Collects all results using a memory resource.
auto CollectWith (std::nullptr_t) const -> std::pmr::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type >=delete
template<typename OutIt>
requires std::output_iterator< OutIt, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
void Into (OutIt out) const
 Writes all query results into an output iterator.
template<typename Action>
requires utils::ActionFor< Action, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
void ForEach (const Action &action) const
 Executes an action for each matching entity's components.
template<typename Action>
requires utils::ActionFor< Action, typename BasicQueryWithEntity<WorldT, Allocator, Args...>::value_type>
void ForEachWithEntity (const Action &action) const
 Executes an action for each entity and its components.
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto Filter (Pred predicate) const &-> utils::FilterAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Pred >
 Filters query results based on a predicate.
template<typename Func>
requires utils::TransformFor< Func, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto Map (Func transform) const &-> utils::MapAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Func >
 Transforms each element using a mapping function.
auto Take (size_t count) const &-> utils::TakeAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
 Takes only the first N elements.
auto Skip (size_t count) const &-> utils::SkipAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
 Skips the first N elements.
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto TakeWhile (Pred predicate) const &-> utils::TakeWhileAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Pred >
 Takes elements while a predicate is true.
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto SkipWhile (Pred predicate) const &-> utils::SkipWhileAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Pred >
 Skips elements while a predicate is true.
auto Enumerate () const &-> utils::EnumerateAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
 Adds an index to each element.
template<typename Func>
requires utils::InspectorFor< Func, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto Inspect (Func inspector) const &-> utils::InspectAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Func >
 Inspects each element without consuming it.
auto StepBy (size_t step) const &-> utils::StepByAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
 Yields every Nth element.
template<typename OtherIter>
requires utils::ChainAdapterRequirements<iterator, OtherIter>
auto Chain (OtherIter other_begin, OtherIter other_end) const &-> utils::ChainAdapter< iterator, OtherIter >
 Chains this query with another iterator range.
auto Chain (const BasicQuery &other) const &-> utils::ChainAdapter< iterator, iterator >
 Chains this query with another query of the same type.
template<std::ranges::input_range R>
requires utils::ChainAdapterRequirements<iterator, std::ranges::iterator_t<R>>
auto Chain (R &range) const &-> utils::ChainAdapter< iterator, std::ranges::iterator_t< R > >
 Chains this query with another range.
template<std::ranges::input_range R>
requires utils::ChainAdapterRequirements<iterator, std::ranges::iterator_t<const R>>
auto Chain (const R &range) const &-> utils::ChainAdapter< iterator, std::ranges::iterator_t< const R > >
 Chains this query with another const range.
auto Reverse () const &-> utils::ReverseAdapter< iterator >
 Reverses the order of iteration.
auto Slide (size_t window_size) const &-> utils::SlideAdapter< iterator >
 Creates sliding windows over query results.
auto Stride (size_t stride) const &-> utils::StrideAdapter< iterator >
 Takes every Nth element with stride.
template<typename OtherIter>
requires utils::ZipAdapterRequirements<iterator, OtherIter>
auto Zip (OtherIter other_begin, OtherIter other_end) const &-> utils::ZipAdapter< iterator, OtherIter >
 Zips this query with another iterator range.
auto Zip (const BasicQuery &other) const &-> utils::ZipAdapter< iterator, iterator >
 Zips this query with another query of the same type.
template<std::ranges::input_range R>
requires utils::ZipAdapterRequirements<iterator, std::ranges::iterator_t<R>>
auto Zip (R &range) const &-> utils::ZipAdapter< iterator, std::ranges::iterator_t< R > >
 Zips this query with another range.
template<std::ranges::input_range R>
requires utils::ZipAdapterRequirements<iterator, std::ranges::iterator_t<const R>>
auto Zip (const R &range) const &-> utils::ZipAdapter< iterator, std::ranges::iterator_t< const R > >
 Zips this query with another const range.
template<typename T, typename Func>
requires utils::FolderFor< Func, T, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
Fold (T init, const Func &folder) const
 Folds query results into a single value.
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
auto Find (const Pred &predicate) const -> std::optional< value_type >
 Finds the first element matching a predicate.
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
size_t CountIf (const Pred &predicate) const
 Counts elements matching a predicate.
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
auto Partition (const Pred &predicate) const -> std::pair< std::vector< value_type >, std::vector< value_type > >
 Partitions elements into two groups based on a predicate.
template<typename KeyFunc>
requires utils::TransformFor<KeyFunc, value_type>
auto MaxBy (const KeyFunc &key_func) const -> std::optional< value_type >
 Finds the element with the maximum key value.
template<typename KeyFunc>
requires utils::TransformFor<KeyFunc, value_type>
auto MinBy (const KeyFunc &key_func) const -> std::optional< value_type >
 Finds the element with the minimum key value.
template<typename KeyExtractor>
requires utils::TransformFor< KeyExtractor, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto GroupBy (const KeyExtractor &key_extractor) const -> std::unordered_map< std::decay_t< utils::details::call_or_apply_result_t< const KeyExtractor &, typename BasicQuery< WorldT, Allocator, Args... >::value_type > >, std::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type > >
 Groups elements by a key extracted from each result.
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
bool Any (const Pred &predicate) const
 Checks if any element matches the predicate.
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
bool All (const Pred &predicate) const
 Checks if all elements match the predicate.
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
bool None (const Pred &predicate) const
 Checks if no elements match the predicate.
bool Empty () const noexcept
 Checks if query matches no entities.
size_t Count () const noexcept
 Gets the number of matching entities.
iterator begin () const
 Gets iterator to the first matching entity and components.
iterator end () const
 Gets iterator past the last matching entity and components.
auto WithoutTypes () const noexcept -> std::span< const ComponentTypeIndex >
 Gets excluded component type indices for this query.
allocator_type get_allocator () const noexcept(std::is_nothrow_copy_constructible_v< allocator_type >)
 Gets the allocator used for internal storage.

Friends

class BasicQueryWithEntity< WorldT, Allocator, Args... >

Detailed Description

template<typename WorldT, typename Allocator, QueryArg... Args>
class helios::ecs::BasicQuery< WorldT, Allocator, Args >

Query result object for iterating over matching entities and components.

BasicQuery provides iteration and functional operations over entities matching specified component criteria. Supports const-qualified component access for read-only operations, optional components via pointer types, value copy, mutable reference, const reference, and rvalue reference (move) access patterns.

Note
Not thread-safe.
Template Parameters
WorldTWorld type (World or const World)
AllocatorAllocator type for internal storage
ArgsComponent access types and optional With/Without filters
auto query = world.Query<Transform&, const Velocity&, const Gravity*,
Health, With<Player>, Without<Dead>>();
for (auto&& [transform, velocity, gravity, health] : query) {
transform.position += velocity.direction * velocity.speed;
if (gravity) {
transform.position.y += gravity->force;
}
}
query.ForEach([](Transform& transform, const Velocity& velocity,
const Gravity* gravity, Health health) {
// ...
});

Definition at line 659 of file query.hpp.

Member Typedef Documentation

◆ allocator_type

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::allocator_type = Allocator

Definition at line 679 of file query.hpp.

◆ ComponentManagerType

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::ComponentManagerType = typename TypeInfo::ComponentManagerType

Definition at line 669 of file query.hpp.

◆ const_iterator

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::const_iterator = typename TypeInfo::template Iterator<true>

Definition at line 674 of file query.hpp.

◆ difference_type

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::difference_type = std::iter_difference_t<iterator>

Definition at line 676 of file query.hpp.

◆ iterator

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::iterator = typename TypeInfo::template Iterator<kIsConst>

Definition at line 673 of file query.hpp.

◆ pointer

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::pointer = typename iterator::pointer

Definition at line 677 of file query.hpp.

◆ reference

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::reference = std::iter_reference_t<iterator>

Definition at line 678 of file query.hpp.

◆ value_type

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::value_type = typename TypeInfo::ValueType

Definition at line 675 of file query.hpp.

◆ WithEntityIterator

template<typename WorldT, typename Allocator, QueryArg... Args>
using helios::ecs::BasicQuery< WorldT, Allocator, Args >::WithEntityIterator
Initial value:
typename TypeInfo::template WithEntityIterator<kIsConst>
typename TypeInfo::template WithEntityIterator< kIsConst > WithEntityIterator
Definition query.hpp:670

Definition at line 670 of file query.hpp.

Constructor & Destructor Documentation

◆ BasicQuery() [1/5]

template<typename WorldT, typename Allocator, QueryArg... Args>
helios::ecs::BasicQuery< WorldT, Allocator, Args >::BasicQuery ( ComponentManagerType & components,
Allocator alloc = {} )
inlineexplicit

Constructs query with the given component manager and allocator.

The With/Without component filters are derived at compile time from the template arguments (via With<> and Without<> filter types).

Parameters
componentsComponent manager reference
allocAllocator instance

Definition at line 1251 of file query.hpp.

◆ BasicQuery() [2/5]

template<typename WorldT, typename Allocator, QueryArg... Args>
helios::ecs::BasicQuery< WorldT, Allocator, Args >::BasicQuery ( ComponentManagerType & components,
std::pmr::memory_resource * resource )
inline

Constructs query from a PMR memory resource.

Enabled only when allocator_type is constructible from std::pmr::memory_resource*.

Parameters
componentsComponent manager reference
resourceMemory resource used to construct allocator

Definition at line 697 of file query.hpp.

◆ BasicQuery() [3/5]

template<typename WorldT, typename Allocator, QueryArg... Args>
helios::ecs::BasicQuery< WorldT, Allocator, Args >::BasicQuery ( ComponentManagerType & ,
std::nullptr_t  )
delete

◆ BasicQuery() [4/5]

template<typename WorldT, typename Allocator, QueryArg... Args>
helios::ecs::BasicQuery< WorldT, Allocator, Args >::BasicQuery ( const BasicQuery< WorldT, Allocator, Args > & )
delete

◆ BasicQuery() [5/5]

template<typename WorldT, typename Allocator, QueryArg... Args>
helios::ecs::BasicQuery< WorldT, Allocator, Args >::BasicQuery ( BasicQuery< WorldT, Allocator, Args > && )
defaultnoexcept

◆ ~BasicQuery()

template<typename WorldT, typename Allocator, QueryArg... Args>
helios::ecs::BasicQuery< WorldT, Allocator, Args >::~BasicQuery ( )
default

Member Function Documentation

◆ All()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
bool helios::ecs::BasicQuery< WorldT, Allocator, Args >::All ( const Pred & predicate) const
inlinenodiscard

Checks if all elements match the predicate.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
True if all results match

Definition at line 1558 of file query.hpp.

◆ Any()

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
bool helios::ecs::BasicQuery< WorldT, Allocator, Args >::Any ( const Pred & predicate) const
inlinenodiscard

Checks if any element matches the predicate.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
True if at least one result matches

Definition at line 1142 of file query.hpp.

◆ begin()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::begin ( ) const
inlinenodiscard

Gets iterator to the first matching entity and components.

Returns
Iterator to the beginning of the query results

Definition at line 1669 of file query.hpp.

◆ Chain() [1/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Chain ( const BasicQuery< WorldT, Allocator, Args > & other) const & -> utils::ChainAdapter< iterator, iterator >
inlinenodiscard

Chains this query with another query of the same type.

Parameters
otherOther query to chain after this one
Returns
Lazy chain view

Definition at line 925 of file query.hpp.

◆ Chain() [2/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
template<std::ranges::input_range R>
requires utils::ChainAdapterRequirements<iterator, std::ranges::iterator_t<const R>>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Chain ( const R & range) const & -> utils::ChainAdapter< iterator, std::ranges::iterator_t< const R > >
inlinenodiscard

Chains this query with another const range.

Template Parameters
RRange type
Parameters
rangeRange to chain after this query
Returns
Lazy chain view

Definition at line 953 of file query.hpp.

◆ Chain() [3/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename OtherIter>
requires utils::ChainAdapterRequirements<iterator, OtherIter>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Chain ( OtherIter other_begin,
OtherIter other_end ) const & -> utils::ChainAdapter< iterator, OtherIter >
inlinenodiscard

Chains this query with another iterator range.

Template Parameters
OtherIterIterator type of the second range
Parameters
other_beginBegin iterator of the second range
other_endEnd iterator of the second range
Returns
Lazy chain view

Definition at line 915 of file query.hpp.

◆ Chain() [4/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
template<std::ranges::input_range R>
requires utils::ChainAdapterRequirements<iterator, std::ranges::iterator_t<R>>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Chain ( R & range) const & -> utils::ChainAdapter< iterator, std::ranges::iterator_t< R > >
inlinenodiscard

Chains this query with another range.

Template Parameters
RRange type
Parameters
rangeRange to chain after this query
Returns
Lazy chain view

Definition at line 939 of file query.hpp.

◆ Collect()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Collect ( ) const -> std::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
inlinenodiscard

Collects all results into a vector.

Returns
Vector of tuples containing components

Definition at line 1351 of file query.hpp.

◆ CollectWith() [1/3]

template<typename WorldT, typename Allocator, QueryArg... Args>
requires std::same_as< typename ResultAlloc::value_type, typename BasicQuery<WorldT, Allocator, Args...>::value_type> &&
(!std::derived_from<std::remove_pointer_t<ResultAlloc>, std::pmr::memory_resource>)
template<typename ResultAlloc>
requires std::same_as< typename ResultAlloc::value_type, typename BasicQuery<WorldT, Allocator, Args...>::value_type> &&
(!std::derived_from<std::remove_pointer_t<ResultAlloc>, std::pmr::memory_resource>)
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::CollectWith ( ResultAlloc alloc) const -> std::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type, ResultAlloc >
inlinenodiscard

Collects all results using a custom allocator.

Template Parameters
ResultAllocSTL-compatible allocator type for value_type
Parameters
allocAllocator instance
Returns
Vector of results using provided allocator

Definition at line 1369 of file query.hpp.

◆ CollectWith() [2/3]

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::CollectWith ( std::nullptr_t ) const -> std::pmr::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type >=delete
delete

◆ CollectWith() [3/3]

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::CollectWith ( std::pmr::memory_resource * resource) const -> std::pmr::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
inlinenodiscard

Collects all results using a memory resource.

Parameters
resourceMemory resource
Returns
Vector of results using provided allocator

Definition at line 1382 of file query.hpp.

◆ Count()

template<typename WorldT, typename Allocator, QueryArg... Args>
size_t helios::ecs::BasicQuery< WorldT, Allocator, Args >::Count ( ) const
inlinenodiscardnoexcept

Gets the number of matching entities.

O(A) where A is number of matching archetypes.

Returns
Total count of entities matching the query

Definition at line 1653 of file query.hpp.

◆ CountIf()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
size_t helios::ecs::BasicQuery< WorldT, Allocator, Args >::CountIf ( const Pred & predicate) const
inlinenodiscard

Counts elements matching a predicate.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
Number of matching elements

Definition at line 1578 of file query.hpp.

◆ Empty()

template<typename WorldT, typename Allocator, QueryArg... Args>
bool helios::ecs::BasicQuery< WorldT, Allocator, Args >::Empty ( ) const
inlinenodiscardnoexcept

Checks if query matches no entities.

Returns
True if no entities match

Definition at line 1647 of file query.hpp.

◆ end()

template<typename WorldT, typename Allocator, QueryArg... Args>
iterator helios::ecs::BasicQuery< WorldT, Allocator, Args >::end ( ) const
inlinenodiscard

Gets iterator past the last matching entity and components.

Returns
Iterator to the end of the query results

Definition at line 1192 of file query.hpp.

◆ Enumerate()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Enumerate ( ) const & -> utils::EnumerateAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
inlinenodiscard

Adds an index to each element.

Returns
Lazy enumerate view

Definition at line 1519 of file query.hpp.

◆ Filter()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Filter ( Pred predicate) const & -> utils::FilterAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Pred >
inlinenodiscard

Filters query results based on a predicate.

Template Parameters
PredPredicate function type (Components...) -> bool
Parameters
predicateFunction to test each result
Returns
Lazy filter view

Definition at line 1444 of file query.hpp.

◆ Find()

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Find ( const Pred & predicate) const -> std::optional< value_type >
inlinenodiscard

Finds the first element matching a predicate.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
First matching element, or std::nullopt if none found

Definition at line 1062 of file query.hpp.

◆ Fold()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::FolderFor< Func, T, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename T, typename Func>
requires utils::FolderFor< Func, T, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
T helios::ecs::BasicQuery< WorldT, Allocator, Args >::Fold ( T init,
const Func & folder ) const
inlinenodiscard

Folds query results into a single value.

Template Parameters
TAccumulator type
FuncFolder function type (T, Components...) -> T
Parameters
initInitial accumulator value
folderFunction combining accumulator with each result
Returns
Final accumulated value

Definition at line 1599 of file query.hpp.

◆ ForEach()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::ActionFor< Action, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Action>
requires utils::ActionFor< Action, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
void helios::ecs::BasicQuery< WorldT, Allocator, Args >::ForEach ( const Action & action) const
inline

Executes an action for each matching entity's components.

Template Parameters
ActionFunction type (Components...) -> void
Parameters
actionFunction to execute for each result

Definition at line 1408 of file query.hpp.

◆ ForEachWithEntity()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::ActionFor< Action, typename BasicQueryWithEntity<WorldT, Allocator, Args...>::value_type>
template<typename Action>
requires utils::ActionFor< Action, typename BasicQueryWithEntity<WorldT, Allocator, Args...>::value_type>
void helios::ecs::BasicQuery< WorldT, Allocator, Args >::ForEachWithEntity ( const Action & action) const
inline

Executes an action for each entity and its components.

Template Parameters
ActionFunction type (Entity, Components...) -> void
Parameters
actionFunction to execute for each result

Definition at line 1423 of file query.hpp.

◆ Get()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Get ( Entity entity) const -> typename BasicQuery< WorldT, Allocator, Args... >::value_type
inlinenodiscard

Gets all query components for a specific entity (ignores query filters).

Parameters
entityThe entity to get components for
Returns
Tuple of component access types for the entity

Definition at line 1264 of file query.hpp.

◆ get_allocator()

template<typename WorldT, typename Allocator, QueryArg... Args>
allocator_type helios::ecs::BasicQuery< WorldT, Allocator, Args >::get_allocator ( ) const
inlinenodiscardnoexcept

Gets the allocator used for internal storage.

Returns
Allocator instance

Definition at line 1211 of file query.hpp.

◆ GroupBy()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::TransformFor< KeyExtractor, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename KeyExtractor>
requires utils::TransformFor< KeyExtractor, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::GroupBy ( const KeyExtractor & key_extractor) const -> std::unordered_map< std::decay_t< utils::details::call_or_apply_result_t< const KeyExtractor &, typename BasicQuery< WorldT, Allocator, Args... >::value_type > >, std::vector< typename BasicQuery< WorldT, Allocator, Args... >::value_type > >
inlinenodiscard

Groups elements by a key extracted from each result.

Template Parameters
KeyExtractorKey extraction function type
Parameters
key_extractorFunction that extracts the grouping key
Returns
Map from keys to vectors of matching elements

Definition at line 1620 of file query.hpp.

◆ Inspect()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::InspectorFor< Func, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Func>
requires utils::InspectorFor< Func, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Inspect ( Func inspector) const & -> utils::InspectAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Func >
inlinenodiscard

Inspects each element without consuming it.

Template Parameters
FuncInspection function type
Parameters
inspectorFunction to call on each result
Returns
Lazy inspect view

Definition at line 1533 of file query.hpp.

◆ Into()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires std::output_iterator< OutIt, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename OutIt>
requires std::output_iterator< OutIt, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
void helios::ecs::BasicQuery< WorldT, Allocator, Args >::Into ( OutIt out) const
inline

Writes all query results into an output iterator.

Template Parameters
OutItOutput iterator type
Parameters
outOutput iterator

Definition at line 1398 of file query.hpp.

◆ Map()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::TransformFor< Func, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Func>
requires utils::TransformFor< Func, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Map ( Func transform) const & -> utils::MapAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Func >
inlinenodiscard

Transforms each element using a mapping function.

Template Parameters
FuncTransformation function type (Components...) -> U
Parameters
transformFunction to transform each result
Returns
Lazy map view

Definition at line 1458 of file query.hpp.

◆ MaxBy()

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename KeyFunc>
requires utils::TransformFor<KeyFunc, value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::MaxBy ( const KeyFunc & key_func) const -> std::optional< value_type >
inlinenodiscard

Finds the element with the maximum key value.

Template Parameters
KeyFuncKey extraction function type
Parameters
key_funcFunction to extract comparison key
Returns
Element with maximum key, or std::nullopt if empty

Definition at line 1099 of file query.hpp.

◆ MinBy()

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename KeyFunc>
requires utils::TransformFor<KeyFunc, value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::MinBy ( const KeyFunc & key_func) const -> std::optional< value_type >
inlinenodiscard

Finds the element with the minimum key value.

Template Parameters
KeyFuncKey extraction function type
Parameters
key_funcFunction to extract comparison key
Returns
Element with minimum key, or std::nullopt if empty

Definition at line 1112 of file query.hpp.

◆ None()

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
bool helios::ecs::BasicQuery< WorldT, Allocator, Args >::None ( const Pred & predicate) const
inlinenodiscard

Checks if no elements match the predicate.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
True if no results match

Definition at line 1165 of file query.hpp.

◆ operator=() [1/2]

template<typename WorldT, typename Allocator, QueryArg... Args>
BasicQuery & helios::ecs::BasicQuery< WorldT, Allocator, Args >::operator= ( BasicQuery< WorldT, Allocator, Args > && )
defaultnoexcept

◆ operator=() [2/2]

template<typename WorldT, typename Allocator, QueryArg... Args>
BasicQuery & helios::ecs::BasicQuery< WorldT, Allocator, Args >::operator= ( const BasicQuery< WorldT, Allocator, Args > & )
delete

◆ Partition()

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename Pred>
requires utils::PredicateFor<Pred, value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Partition ( const Pred & predicate) const -> std::pair< std::vector< value_type >, std::vector< value_type > >
inlinenodiscard

Partitions elements into two groups based on a predicate.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
Pair of vectors: (matching, non-matching)

Definition at line 1086 of file query.hpp.

◆ Reverse()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Reverse ( ) const & -> utils::ReverseAdapter< iterator >
inlinenodiscard

Reverses the order of iteration.

Returns
Lazy reverse view

Definition at line 963 of file query.hpp.

◆ Skip()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Skip ( size_t count) const & -> utils::SkipAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
inlinenodiscard

Skips the first N elements.

Parameters
countNumber of elements to skip
Returns
Lazy skip view

Definition at line 1480 of file query.hpp.

◆ SkipWhile()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::SkipWhile ( Pred predicate) const & -> utils::SkipWhileAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Pred >
inlinenodiscard

Skips elements while a predicate is true.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
Lazy skip-while view

Definition at line 1508 of file query.hpp.

◆ Slide()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Slide ( size_t window_size) const & -> utils::SlideAdapter< iterator >
inlinenodiscard

Creates sliding windows over query results.

Parameters
window_sizeSize of the sliding window
Returns
Lazy slide view
Warning
window_size must be greater than 0

Definition at line 973 of file query.hpp.

◆ StepBy()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::StepBy ( size_t step) const & -> utils::StepByAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
inlinenodiscard

Yields every Nth element.

Parameters
stepInterval between yielded elements (must be > 0)
Returns
Lazy step-by view

Definition at line 1544 of file query.hpp.

◆ Stride()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Stride ( size_t stride) const & -> utils::StrideAdapter< iterator >
inlinenodiscard

Takes every Nth element with stride.

Parameters
strideNumber of elements to skip between yields
Returns
Lazy stride view
Warning
stride must be greater than 0

Definition at line 984 of file query.hpp.

◆ Take()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Take ( size_t count) const & -> utils::TakeAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator >
inlinenodiscard

Takes only the first N elements.

Parameters
countMaximum number of elements to take
Returns
Lazy take view

Definition at line 1469 of file query.hpp.

◆ TakeWhile()

template<typename WorldT, typename Allocator, QueryArg... Args>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
template<typename Pred>
requires utils::PredicateFor< Pred, typename BasicQuery<WorldT, Allocator, Args...>::value_type>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::TakeWhile ( Pred predicate) const & -> utils::TakeWhileAdapter< typename BasicQuery< WorldT, Allocator, Args... >::iterator, Pred >
inlinenodiscard

Takes elements while a predicate is true.

Template Parameters
PredPredicate function type
Parameters
predicateFunction to test each result
Returns
Lazy take-while view

Definition at line 1494 of file query.hpp.

◆ TryGet()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::TryGet ( Entity entity) const -> std::optional< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
inlinenodiscard

Tries to get all query components for a specific entity (ignores query filters).

Parameters
entityThe entity to get components for
Returns
Optional tuple of component access types for the entity

Definition at line 1290 of file query.hpp.

◆ TryGetFiltered()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::TryGetFiltered ( Entity entity) const -> std::optional< typename BasicQuery< WorldT, Allocator, Args... >::value_type >
inlinenodiscard

Tries to get all query components for a specific entity while respecting query filters.

Parameters
entityThe entity to get components for
Returns
Optional tuple of component access types for the entity

Definition at line 1318 of file query.hpp.

◆ WithEntity()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::WithEntity ( ) & -> BasicQueryWithEntity< WorldT, Allocator, Args... >
inlinenodiscardnoexcept

Creates wrapper for entity-aware iteration.

Note
Only callable on lvalue queries to prevent dangling references.
Returns
BasicQueryWithEntity wrapper for this query

Definition at line 716 of file query.hpp.

◆ WithoutTypes()

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::WithoutTypes ( ) const -> std::span< const ComponentTypeIndex >
inlinenodiscardnoexcept

Gets excluded component type indices for this query.

Returns
Span of component type indices that are excluded by this query

Definition at line 1202 of file query.hpp.

◆ Zip() [1/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Zip ( const BasicQuery< WorldT, Allocator, Args > & other) const & -> utils::ZipAdapter< iterator, iterator >
inlinenodiscard

Zips this query with another query of the same type.

Parameters
otherQuery to zip with
Returns
Lazy zip view

Definition at line 1008 of file query.hpp.

◆ Zip() [2/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
template<std::ranges::input_range R>
requires utils::ZipAdapterRequirements<iterator, std::ranges::iterator_t<const R>>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Zip ( const R & range) const & -> utils::ZipAdapter< iterator, std::ranges::iterator_t< const R > >
inlinenodiscard

Zips this query with another const range.

Template Parameters
RRange type
Parameters
rangeRange to zip with
Returns
Lazy zip view

Definition at line 1035 of file query.hpp.

◆ Zip() [3/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
template<typename OtherIter>
requires utils::ZipAdapterRequirements<iterator, OtherIter>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Zip ( OtherIter other_begin,
OtherIter other_end ) const & -> utils::ZipAdapter< iterator, OtherIter >
inlinenodiscard

Zips this query with another iterator range.

Template Parameters
OtherIterIterator type to zip with
Parameters
other_beginBegin of other range
other_endEnd of other range
Returns
Lazy zip view

Definition at line 998 of file query.hpp.

◆ Zip() [4/4]

template<typename WorldT, typename Allocator, QueryArg... Args>
template<std::ranges::input_range R>
requires utils::ZipAdapterRequirements<iterator, std::ranges::iterator_t<R>>
auto helios::ecs::BasicQuery< WorldT, Allocator, Args >::Zip ( R & range) const & -> utils::ZipAdapter< iterator, std::ranges::iterator_t< R > >
inlinenodiscard

Zips this query with another range.

Template Parameters
RRange type
Parameters
rangeRange to zip with
Returns
Lazy zip view

Definition at line 1021 of file query.hpp.

◆ BasicQueryWithEntity< WorldT, Allocator, Args... >

template<typename WorldT, typename Allocator, QueryArg... Args>
friend class BasicQueryWithEntity< WorldT, Allocator, Args... >
friend

Definition at line 1245 of file query.hpp.