Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
ecs_iter_t Struct Reference

Iterator. More...

#include <flecs.h>

Public Attributes

ecs_world_tworld
 The world.
 
ecs_world_treal_world
 Actual world.
 
const ecs_entity_tentities
 Entity identifiers.
 
const ecs_size_t * sizes
 Component sizes.
 
ecs_table_ttable
 Current table.
 
ecs_table_tother_table
 Prev or next table when adding/removing.
 
ecs_id_tids
 (Component) ids
 
ecs_var_t * variables
 Values of variables (if any)
 
const ecs_table_record_t ** trs
 Info on where to find field in table.
 
ecs_entity_tsources
 Entity on which the id was matched (0 if same as entities)
 
ecs_flags64_t constrained_vars
 Bitset that marks constrained variables.
 
uint64_t group_id
 Group id for table, if group_by is used.
 
ecs_flags32_t set_fields
 Fields that are set.
 
ecs_flags32_t ref_fields
 Bitset with fields that aren't component arrays.
 
ecs_flags32_t row_fields
 Fields that must be obtained with field_at.
 
ecs_flags32_t up_fields
 Bitset with fields matched through up traversal.
 
ecs_entity_t system
 The system (if applicable)
 
ecs_entity_t event
 The event (if applicable)
 
ecs_id_t event_id
 The (component) id for the event.
 
int32_t event_cur
 Unique event id.
 
int8_t field_count
 Number of fields in iterator.
 
int8_t term_index
 Index of term that emitted an event.
 
int8_t variable_count
 Number of variables for query.
 
const ecs_query_tquery
 Query being evaluated.
 
char ** variable_names
 Names of variables (if any)
 
void * param
 Param passed to ecs_run.
 
void * ctx
 System context.
 
void * binding_ctx
 System binding context.
 
void * callback_ctx
 Callback language binding context.
 
void * run_ctx
 Run language binding context.
 
float delta_time
 Time elapsed since last frame.
 
float delta_system_time
 Time elapsed since last system invocation.
 
int32_t frame_offset
 Offset relative to start of iteration.
 
int32_t offset
 Offset relative to current table.
 
int32_t count
 Number of entities to iterate.
 
ecs_flags32_t flags
 Iterator flags.
 
ecs_entity_t interrupted_by
 When set, system execution is interrupted.
 
ecs_iter_private_t priv_
 Private data.
 
ecs_iter_next_action_t next
 Function to progress iterator.
 
ecs_iter_action_t callback
 Callback of system or observer.
 
ecs_iter_fini_action_t fini
 Function to cleanup iterator resources.
 
ecs_iter_tchain_it
 Optional, allows for creating iterator chains.
 

Detailed Description

Iterator.

Used for iterating queries. The ecs_iter_t type contains all the information that is provided by a query, and contains all the state required for the iterator code.

Functions that create iterators accept as first argument the world, and as second argument the object they iterate. For example:

ecs_iter_t ecs_query_iter(const ecs_world_t *world, const ecs_query_t *query)
Create a query iterator.
Iterator.
Definition flecs.h:1101
ecs_world_t * world
The world.
Definition flecs.h:1103

When this code is called from a system, it is important to use the world provided by its iterator object to ensure thread safety. For example:

void Collide(ecs_iter_t *it) {
ecs_iter_t qit = ecs_query_iter(it->world, Colliders);
}

An iterator contains resources that need to be released. By default this is handled by the last call to next() that returns false. When iteration is ended before iteration has completed, an application has to manually call ecs_iter_fini() to release the iterator resources:

while (ecs_query_next(&it)) {
if (cond) {
break;
}
}
void ecs_iter_fini(ecs_iter_t *it)
Cleanup iterator resources.
bool ecs_query_next(ecs_iter_t *it)
Progress query iterator.

Definition at line 1101 of file flecs.h.

Member Data Documentation

◆ binding_ctx

void* ecs_iter_t::binding_ctx

System binding context.

Definition at line 1140 of file flecs.h.

◆ callback

ecs_iter_action_t ecs_iter_t::callback

Callback of system or observer.

Definition at line 1160 of file flecs.h.

◆ callback_ctx

void* ecs_iter_t::callback_ctx

Callback language binding context.

Definition at line 1141 of file flecs.h.

◆ chain_it

ecs_iter_t* ecs_iter_t::chain_it

Optional, allows for creating iterator chains.

Definition at line 1162 of file flecs.h.

◆ constrained_vars

ecs_flags64_t ecs_iter_t::constrained_vars

Bitset that marks constrained variables.

Definition at line 1115 of file flecs.h.

◆ count

int32_t ecs_iter_t::count

Number of entities to iterate.

Definition at line 1151 of file flecs.h.

◆ ctx

void* ecs_iter_t::ctx

System context.

Definition at line 1139 of file flecs.h.

◆ delta_system_time

float ecs_iter_t::delta_system_time

Time elapsed since last system invocation.

Definition at line 1146 of file flecs.h.

◆ delta_time

float ecs_iter_t::delta_time

Time elapsed since last frame.

Definition at line 1145 of file flecs.h.

◆ entities

const ecs_entity_t* ecs_iter_t::entities

Entity identifiers.

Definition at line 1107 of file flecs.h.

◆ event

ecs_entity_t ecs_iter_t::event

The event (if applicable)

Definition at line 1124 of file flecs.h.

◆ event_cur

int32_t ecs_iter_t::event_cur

Unique event id.

Used to dedup observer calls

Definition at line 1126 of file flecs.h.

◆ event_id

ecs_id_t ecs_iter_t::event_id

The (component) id for the event.

Definition at line 1125 of file flecs.h.

◆ field_count

int8_t ecs_iter_t::field_count

Number of fields in iterator.

Definition at line 1129 of file flecs.h.

◆ fini

ecs_iter_fini_action_t ecs_iter_t::fini

Function to cleanup iterator resources.

Definition at line 1161 of file flecs.h.

◆ flags

ecs_flags32_t ecs_iter_t::flags

Iterator flags.

Definition at line 1154 of file flecs.h.

◆ frame_offset

int32_t ecs_iter_t::frame_offset

Offset relative to start of iteration.

Definition at line 1149 of file flecs.h.

◆ group_id

uint64_t ecs_iter_t::group_id

Group id for table, if group_by is used.

Definition at line 1116 of file flecs.h.

◆ ids

ecs_id_t* ecs_iter_t::ids

(Component) ids

Definition at line 1111 of file flecs.h.

◆ interrupted_by

ecs_entity_t ecs_iter_t::interrupted_by

When set, system execution is interrupted.

Definition at line 1155 of file flecs.h.

◆ next

ecs_iter_next_action_t ecs_iter_t::next

Function to progress iterator.

Definition at line 1159 of file flecs.h.

◆ offset

int32_t ecs_iter_t::offset

Offset relative to current table.

Definition at line 1150 of file flecs.h.

◆ other_table

ecs_table_t* ecs_iter_t::other_table

Prev or next table when adding/removing.

Definition at line 1110 of file flecs.h.

◆ param

void* ecs_iter_t::param

Param passed to ecs_run.

Definition at line 1138 of file flecs.h.

◆ priv_

ecs_iter_private_t ecs_iter_t::priv_

Private data.

Definition at line 1156 of file flecs.h.

◆ query

const ecs_query_t* ecs_iter_t::query

Query being evaluated.

Definition at line 1134 of file flecs.h.

◆ real_world

ecs_world_t* ecs_iter_t::real_world

Actual world.

Never points to a stage.

Definition at line 1104 of file flecs.h.

◆ ref_fields

ecs_flags32_t ecs_iter_t::ref_fields

Bitset with fields that aren't component arrays.

Definition at line 1118 of file flecs.h.

◆ row_fields

ecs_flags32_t ecs_iter_t::row_fields

Fields that must be obtained with field_at.

Definition at line 1119 of file flecs.h.

◆ run_ctx

void* ecs_iter_t::run_ctx

Run language binding context.

Definition at line 1142 of file flecs.h.

◆ set_fields

ecs_flags32_t ecs_iter_t::set_fields

Fields that are set.

Definition at line 1117 of file flecs.h.

◆ sizes

const ecs_size_t* ecs_iter_t::sizes

Component sizes.

Definition at line 1108 of file flecs.h.

◆ sources

ecs_entity_t* ecs_iter_t::sources

Entity on which the id was matched (0 if same as entities)

Definition at line 1114 of file flecs.h.

◆ system

ecs_entity_t ecs_iter_t::system

The system (if applicable)

Definition at line 1123 of file flecs.h.

◆ table

ecs_table_t* ecs_iter_t::table

Current table.

Definition at line 1109 of file flecs.h.

◆ term_index

int8_t ecs_iter_t::term_index

Index of term that emitted an event.

This field will be set to the 'index' field of an observer term.

Definition at line 1130 of file flecs.h.

◆ trs

const ecs_table_record_t** ecs_iter_t::trs

Info on where to find field in table.

Definition at line 1113 of file flecs.h.

◆ up_fields

ecs_flags32_t ecs_iter_t::up_fields

Bitset with fields matched through up traversal.

Definition at line 1120 of file flecs.h.

◆ variable_count

int8_t ecs_iter_t::variable_count

Number of variables for query.

Definition at line 1133 of file flecs.h.

◆ variable_names

char** ecs_iter_t::variable_names

Names of variables (if any)

Definition at line 1135 of file flecs.h.

◆ variables

ecs_var_t* ecs_iter_t::variables

Values of variables (if any)

Definition at line 1112 of file flecs.h.

◆ world

ecs_world_t* ecs_iter_t::world

The world.

Can point to stage when in deferred/readonly mode.

Definition at line 1103 of file flecs.h.


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