Flecs v3.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::iter Struct Reference

Class for iterating over query results. More...

#include <iter.hpp>

Public Member Functions

 iter (ecs_iter_t *it)
 Construct iterator from C iterator object. More...
 
row_iterator begin () const
 
row_iterator end () const
 
flecs::entity system () const
 
flecs::entity event () const
 
flecs::id event_id () const
 
flecs::world world () const
 
const flecs::iter_t * c_ptr () const
 
size_t count () const
 
ecs_ftime_t delta_time () const
 
ecs_ftime_t delta_system_time () const
 
flecs::type type () const
 
flecs::table table () const
 
flecs::table_range range () const
 
bool has_module () const
 Is current type a module or does it contain module contents? More...
 
void * ctx ()
 Access ctx. More...
 
template<typename T >
T * ctx ()
 Access ctx. More...
 
void * param ()
 Access param. More...
 
template<typename T >
T * param ()
 Access param. More...
 
flecs::entity entity (size_t row) const
 Obtain mutable handle to entity being iterated over. More...
 
bool is_self (int32_t index) const
 Returns whether field is matched on self. More...
 
bool is_set (int32_t index) const
 Returns whether field is set. More...
 
bool is_readonly (int32_t index) const
 Returns whether field is readonly. More...
 
int32_t field_count () const
 Number of fields in iteator. More...
 
size_t size (int32_t index) const
 Size of field data type. More...
 
flecs::entity src (int32_t index) const
 Obtain field source (0 if This). More...
 
flecs::entity id (int32_t index) const
 Obtain id matched for field. More...
 
flecs::id pair (int32_t index) const
 Obtain pair id matched for field. More...
 
flecs::string str () const
 Convert current iterator result to string. More...
 
template<typename T , typename A = actual_type_t<T>, typename std::enable_if< std::is_const< T >::value, void >::type * = nullptr>
flecs::column< A > field (int32_t index) const
 Get readonly access to field data. More...
 
template<typename T , typename A = actual_type_t<T>, typename std::enable_if< std::is_const< T >::value==false, void >::type * = nullptr>
flecs::column< A > field (int32_t index) const
 Get read/write access to field data. More...
 
flecs::untyped_column field (int32_t index) const
 Get unchecked access to field data. More...
 
int32_t table_count () const
 Obtain the total number of tables the iterator will iterate over. More...
 
bool changed ()
 Check if the current table has changed since the last iteration. More...
 
void skip ()
 Skip current table. More...
 
uint64_t group_id () const
 
flecs::entity get_var (int var_id) const
 Get value of variable by id. More...
 
flecs::entity get_var (const char *name) const
 Get value of variable by name. More...
 
flecs::string to_json (flecs::iter_to_json_desc_t *desc=nullptr)
 Serialize iterator result to JSON. More...
 
iter_iterable< Components... > & set_var (int var_id, flecs::entity_t value)
 

Detailed Description

Class for iterating over query results.

Definition at line 169 of file iter.hpp.

Constructor & Destructor Documentation

◆ iter()

flecs::iter::iter ( ecs_iter_t *  it)
inline

Construct iterator from C iterator object.

This operation is typically not invoked directly by the user.

Parameters
itPointer to C iterator.

Definition at line 179 of file iter.hpp.

Member Function Documentation

◆ begin()

row_iterator flecs::iter::begin ( ) const
inline

Definition at line 184 of file iter.hpp.

◆ c_ptr()

const flecs::iter_t * flecs::iter::c_ptr ( ) const
inline

Definition at line 200 of file iter.hpp.

◆ changed()

bool flecs::iter::changed ( )
inline

Check if the current table has changed since the last iteration.

Can only be used when iterating queries and/or systems.

Definition at line 376 of file iter.hpp.

◆ count()

size_t flecs::iter::count ( ) const
inline

Definition at line 204 of file iter.hpp.

◆ ctx() [1/2]

void * flecs::iter::ctx ( )
inline

Access ctx.

ctx contains the context pointer assigned to a system.

Definition at line 230 of file iter.hpp.

◆ ctx() [2/2]

template<typename T >
T * flecs::iter::ctx ( )
inline

Access ctx.

ctx contains the context pointer assigned to a system.

Definition at line 238 of file iter.hpp.

◆ delta_system_time()

ecs_ftime_t flecs::iter::delta_system_time ( ) const
inline

Definition at line 212 of file iter.hpp.

◆ delta_time()

ecs_ftime_t flecs::iter::delta_time ( ) const
inline

Definition at line 208 of file iter.hpp.

◆ end()

row_iterator flecs::iter::end ( ) const
inline

Definition at line 188 of file iter.hpp.

◆ entity()

flecs::entity flecs::iter::entity ( size_t  row) const
inline

Obtain mutable handle to entity being iterated over.

Parameters
rowRow being iterated over.

Definition at line 27 of file iter.hpp.

◆ event()

flecs::entity flecs::iter::event ( ) const
inline

Definition at line 15 of file iter.hpp.

◆ event_id()

flecs::id flecs::iter::event_id ( ) const
inline

Definition at line 19 of file iter.hpp.

◆ field() [1/3]

template<typename T , typename A = actual_type_t<T>, typename std::enable_if< std::is_const< T >::value, void >::type * = nullptr>
flecs::column< A > flecs::iter::field ( int32_t  index) const
inline

Get readonly access to field data.

If the specified field index does not match with the provided type, the function will assert.

Template Parameters
TType of the field.
Parameters
indexThe field index.
Returns
The field data.

Definition at line 338 of file iter.hpp.

◆ field() [2/3]

template<typename T , typename A = actual_type_t<T>, typename std::enable_if< std::is_const< T >::value==false, void >::type * = nullptr>
flecs::column< A > flecs::iter::field ( int32_t  index) const
inline

Get read/write access to field data.

If the matched id for the specified field does not match with the provided type or if the field is readonly, the function will assert.

Template Parameters
TType of the field.
Parameters
indexThe field index.
Returns
The field data.

Definition at line 353 of file iter.hpp.

◆ field() [3/3]

flecs::untyped_column flecs::iter::field ( int32_t  index) const
inline

Get unchecked access to field data.

Unchecked access is required when a system does not know the type of a field at compile time.

Parameters
indexThe field index.

Definition at line 365 of file iter.hpp.

◆ field_count()

int32_t flecs::iter::field_count ( ) const
inline

Number of fields in iteator.

Definition at line 290 of file iter.hpp.

◆ get_var() [1/2]

flecs::entity flecs::iter::get_var ( const char *  name) const
inline

Get value of variable by name.

Get value of a query variable for current result.

Definition at line 77 of file iter.hpp.

◆ get_var() [2/2]

flecs::entity flecs::iter::get_var ( int  var_id) const
inline

Get value of variable by id.

Get value of a query variable for current result.

Definition at line 68 of file iter.hpp.

◆ group_id()

uint64_t flecs::iter::group_id ( ) const
inline

Definition at line 392 of file iter.hpp.

◆ has_module()

bool flecs::iter::has_module ( ) const
inline

Is current type a module or does it contain module contents?

Definition at line 223 of file iter.hpp.

◆ id()

flecs::entity flecs::iter::id ( int32_t  index) const
inline

Obtain id matched for field.

Parameters
indexThe field index.

Definition at line 42 of file iter.hpp.

◆ is_readonly()

bool flecs::iter::is_readonly ( int32_t  index) const
inline

Returns whether field is readonly.

Parameters
indexThe field index.

Definition at line 284 of file iter.hpp.

◆ is_self()

bool flecs::iter::is_self ( int32_t  index) const
inline

Returns whether field is matched on self.

Parameters
indexThe field index.

Definition at line 268 of file iter.hpp.

◆ is_set()

bool flecs::iter::is_set ( int32_t  index) const
inline

Returns whether field is set.

Parameters
indexThe field index.

Definition at line 276 of file iter.hpp.

◆ pair()

flecs::id flecs::iter::pair ( int32_t  index) const
inline

Obtain pair id matched for field.

This operation will fail if the id is not a pair.

Parameters
indexThe field index.

Definition at line 46 of file iter.hpp.

◆ param() [1/2]

void * flecs::iter::param ( )
inline

Access param.

param contains the pointer passed to the param argument of system::run

Definition at line 245 of file iter.hpp.

◆ param() [2/2]

template<typename T >
T * flecs::iter::param ( )
inline

Access param.

param contains the pointer passed to the param argument of system::run

Definition at line 253 of file iter.hpp.

◆ range()

flecs::table_range flecs::iter::range ( ) const
inline

Definition at line 62 of file iter.hpp.

◆ size()

size_t flecs::iter::size ( int32_t  index) const
inline

Size of field data type.

Parameters
indexThe field id.

Definition at line 298 of file iter.hpp.

◆ skip()

void flecs::iter::skip ( )
inline

Skip current table.

This indicates to the query that the data in the current table is not modified. By default, iterating a table with a query will mark the iterated components as dirty if they are annotated with InOut or Out.

When this operation is invoked, the components of the current table will not be marked dirty.

Definition at line 387 of file iter.hpp.

◆ src()

flecs::entity flecs::iter::src ( int32_t  index) const
inline

Obtain field source (0 if This).

Parameters
indexThe field index.

Definition at line 38 of file iter.hpp.

◆ str()

flecs::string flecs::iter::str ( ) const
inline

Convert current iterator result to string.

Definition at line 323 of file iter.hpp.

◆ system()

flecs::entity flecs::iter::system ( ) const
inline

Definition at line 11 of file iter.hpp.

◆ table()

flecs::table flecs::iter::table ( ) const
inline

Definition at line 58 of file iter.hpp.

◆ table_count()

int32_t flecs::iter::table_count ( ) const
inline

Obtain the total number of tables the iterator will iterate over.

Definition at line 370 of file iter.hpp.

◆ type()

flecs::type flecs::iter::type ( ) const
inline

Definition at line 54 of file iter.hpp.

◆ world()

flecs::world flecs::iter::world ( ) const
inline

Definition at line 23 of file iter.hpp.


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