Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::iterable< Components > Struct Template Referenceabstract

Base class for iterable query objects. More...

#include <iterable.hpp>

Public Member Functions

template<typename Func >
void each (Func &&func) const
 Each iterator.
 
template<typename Func >
void run (Func &&func) const
 Run the iterator.
 
template<typename Func >
flecs::entity find (Func &&func) const
 Find the first entity matching a condition.
 
iter_iterable< Components... > iter (flecs::world_t *world=nullptr) const
 Create an iterator.
 
iter_iterable< Components... > iter (flecs::iter &iter) const
 Create an iterator.
 
iter_iterable< Components... > iter (flecs::entity e) const
 Create an iterator.
 
page_iterable< Components... > page (int32_t offset, int32_t limit)
 Page iterator.
 
worker_iterable< Components... > worker (int32_t index, int32_t count)
 Worker iterator.
 
int32_t count () const
 Return the number of entities matched by the iterable.
 
bool is_true () const
 Return whether the iterable has any matches.
 
flecs::entity first () const
 Return the first entity matched by the iterable.
 
iter_iterable< Components... > set_var (int var_id, flecs::entity_t value) const
 Set query variable by ID.
 
iter_iterable< Components... > set_var (const char *name, flecs::entity_t value) const
 Set query variable by name to an entity value.
 
iter_iterable< Components... > set_var (const char *name, flecs::table_t *value) const
 Set query variable by name to a table value.
 
iter_iterable< Components... > set_var (const char *name, ecs_table_range_t value) const
 Set query variable by name to a table range (C type).
 
iter_iterable< Components... > set_var (const char *name, flecs::table_range value) const
 Set query variable by name to a table range.
 
iter_iterable< Components... > set_group (uint64_t group_id) const
 Limit results to tables with the specified group ID (grouped queries only).
 
template<typename Group >
iter_iterable< Components... > set_group () const
 Limit results to tables with the specified group type (grouped queries only).
 
virtual ~iterable ()
 Virtual destructor.
 

Protected Member Functions

virtual ecs_iter_t get_iter (flecs::world_t *stage) const =0
 
virtual ecs_iter_next_action_t next_action () const =0
 

Protected Attributes

friend iter_iterable< Components... >
 
friend page_iterable< Components... >
 
friend worker_iterable< Components... >
 

Detailed Description

template<typename ... Components>
struct flecs::iterable< Components >

Base class for iterable query objects.

Definition at line 22 of file iterable.hpp.

Constructor & Destructor Documentation

◆ ~iterable()

template<typename ... Components>
virtual flecs::iterable< Components >::~iterable ( )
inlinevirtual

Virtual destructor.

Definition at line 164 of file iterable.hpp.

Member Function Documentation

◆ count()

template<typename ... Components>
int32_t flecs::iterable< Components >::count ( ) const
inline

Return the number of entities matched by the iterable.

Definition at line 113 of file iterable.hpp.

◆ each()

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::each ( Func && func) const
inline

Each iterator.

The "each" iterator accepts a function that is invoked for each matching entity. The following function signatures are valid:

  • func(flecs::entity e, Components& ...)
  • func(flecs::iter& it, size_t index, Components& ...)
  • func(Components& ...)
Parameters
funcThe callback function.

Definition at line 34 of file iterable.hpp.

◆ find()

template<typename ... Components>
template<typename Func >
flecs::entity flecs::iterable< Components >::find ( Func && func) const
inline

Find the first entity matching a condition.

Return the first entity for which the provided function returns true.

Parameters
funcThe predicate function.
Returns
The first matching entity, or an empty entity if none found.

Definition at line 62 of file iterable.hpp.

◆ first()

template<typename ... Components>
flecs::entity flecs::iterable< Components >::first ( ) const
inline

Return the first entity matched by the iterable.

Definition at line 123 of file iterable.hpp.

◆ is_true()

template<typename ... Components>
bool flecs::iterable< Components >::is_true ( ) const
inline

Return whether the iterable has any matches.

Definition at line 118 of file iterable.hpp.

◆ iter() [1/3]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::iter ( flecs::entity e) const

Create an iterator.

Create an iterator object that can be modified before iterating.

Definition at line 306 of file iterable.hpp.

◆ iter() [2/3]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::iter ( flecs::iter & iter) const

Create an iterator.

Create an iterator object that can be modified before iterating.

Definition at line 300 of file iterable.hpp.

◆ iter() [3/3]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::iter ( flecs::world_t * world = nullptr) const

Create an iterator.

Create an iterator object that can be modified before iterating.

Definition at line 294 of file iterable.hpp.

◆ page()

template<typename ... Components>
page_iterable< Components... > flecs::iterable< Components >::page ( int32_t offset,
int32_t limit )

Page iterator.

Create an iterator that limits the returned entities with offset/limit.

Parameters
offsetHow many entities to skip.
limitThe maximum number of entities to return.
Returns
Iterable that can be iterated with each/iter.

Definition at line 339 of file iterable.hpp.

◆ run()

template<typename ... Components>
template<typename Func >
void flecs::iterable< Components >::run ( Func && func) const
inline

Run the iterator.

The "run" callback accepts a function that is invoked once for a query with a valid iterator. The following signature is valid:

  • func(flecs::iter&)
Parameters
funcThe callback function.

Definition at line 50 of file iterable.hpp.

◆ set_group() [1/2]

template<typename ... Components>
template<typename Group >
iter_iterable< Components... > flecs::iterable< Components >::set_group ( ) const
inline

Limit results to tables with the specified group type (grouped queries only).

Definition at line 159 of file iterable.hpp.

◆ set_group() [2/2]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::set_group ( uint64_t group_id) const
inline

Limit results to tables with the specified group ID (grouped queries only).

Definition at line 153 of file iterable.hpp.

◆ set_var() [1/5]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::set_var ( const char * name,
ecs_table_range_t value ) const
inline

Set query variable by name to a table range (C type).

Definition at line 143 of file iterable.hpp.

◆ set_var() [2/5]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::set_var ( const char * name,
flecs::entity_t value ) const
inline

Set query variable by name to an entity value.

Definition at line 133 of file iterable.hpp.

◆ set_var() [3/5]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::set_var ( const char * name,
flecs::table_range value ) const
inline

Set query variable by name to a table range.

Definition at line 148 of file iterable.hpp.

◆ set_var() [4/5]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::set_var ( const char * name,
flecs::table_t * value ) const
inline

Set query variable by name to a table value.

Definition at line 138 of file iterable.hpp.

◆ set_var() [5/5]

template<typename ... Components>
iter_iterable< Components... > flecs::iterable< Components >::set_var ( int var_id,
flecs::entity_t value ) const
inline

Set query variable by ID.

Definition at line 128 of file iterable.hpp.

◆ worker()

template<typename ... Components>
worker_iterable< Components... > flecs::iterable< Components >::worker ( int32_t index,
int32_t count )

Worker iterator.

Create an iterator that divides the number of matched entities across a number of resources.

Parameters
indexThe index of the current resource.
countThe total number of resources to divide entities between.
Returns
Iterable that can be iterated with each/iter.

Definition at line 373 of file iterable.hpp.

Member Data Documentation

◆ iter_iterable< Components... >

template<typename ... Components>
friend flecs::iterable< Components >::iter_iterable< Components... >
protected

Definition at line 166 of file iterable.hpp.

◆ page_iterable< Components... >

template<typename ... Components>
friend flecs::iterable< Components >::page_iterable< Components... >
protected

Definition at line 167 of file iterable.hpp.

◆ worker_iterable< Components... >

template<typename ... Components>
friend flecs::iterable< Components >::worker_iterable< Components... >
protected

Definition at line 168 of file iterable.hpp.


The documentation for this struct was generated from the following file: