9template <
typename ... Components>
13template <
typename ... Components>
17template <
typename ... Components>
18struct worker_iterable;
21template <
typename ... Components>
33 template <
typename Func>
34 void each(Func&& func)
const {
49 template <
typename Func>
50 void run(Func&& func)
const {
61 template <
typename Func>
67 while (!result && next(&it)) {
114 return this->
iter().count();
119 return this->
iter().is_true();
129 return this->
iter().set_var(var_id, value);
134 return this->
iter().set_var(name, value);
139 return this->
iter().set_var(name, value);
144 return this->
iter().set_var(name, value);
149 return this->
iter().set_var(name, value);
154 return this->
iter().set_group(group_id);
158 template <
typename Group>
160 return this->
iter().template set_group<Group>();
175template <
typename ... Components>
178 template <
typename Iterable>
181 it_ = it->get_iter(
world);
182 next_ = it->next_action();
183 next_each_ = it->next_action();
221 ecs_table_range_t range;
223 range.offset = value.
offset();
224 range.count = value.
count();
235 while (next_each_(&it_)) {
243 bool result = next_each_(&it_);
253 if (next_each_(&it_) && it_.
count) {
267 template <
typename Group>
293template <
typename ... Components>
299template <
typename ... Components>
305template <
typename ... Components>
312template <
typename ... Components>
315 template <
typename Iterable>
320 chain_it_ = it->get_iter(
nullptr);
338template <
typename ... Components>
347template <
typename ... Components>
354 chain_it_ = it->get_iter(
nullptr);
372template <
typename ... Components>
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
#define ECS_INTERNAL_ERROR
Internal error code.
ecs_table_t table_t
Table type.
ecs_entity_t entity_t
Entity type.
ecs_world_t world_t
World type.
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
ecs_iter_t ecs_worker_iter(const ecs_iter_t *it, int32_t index, int32_t count)
Create a worker iterator.
void ecs_iter_fini(ecs_iter_t *it)
Clean up iterator resources.
ecs_iter_t ecs_page_iter(const ecs_iter_t *it, int32_t offset, int32_t limit)
Create a paged iterator.
void ecs_iter_set_var(ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
Set the value for an iterator variable.
bool ecs_worker_next(ecs_iter_t *it)
Progress a worker iterator.
void ecs_iter_set_var_as_table(ecs_iter_t *it, int32_t var_id, const ecs_table_t *table)
Same as ecs_iter_set_var(), but for a table.
bool ecs_page_next(ecs_iter_t *it)
Progress a paged iterator.
void ecs_iter_set_var_as_range(ecs_iter_t *it, int32_t var_id, const ecs_table_range_t *range)
Same as ecs_iter_set_var(), but for a range of entities.
void ecs_iter_set_group(ecs_iter_t *it, uint64_t group_id)
Set the group to iterate for a query iterator.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find a variable index.
ecs_world_t * real_world
Actual world.
ecs_world_t * world
The world.
const ecs_query_t * query
Query being evaluated.
int32_t count
Number of entities to iterate.
const ecs_entity_t * entities
Entity identifiers.
flecs::world world() const
Get the world.
flecs::entity first() const
Get first element from a pair.
Forward declaration of iter_iterable.
iter_iterable< Components... > & set_var(const char *name, ecs_table_range_t value)
Set query variable by name to a table range (C type).
iter_iterable< Components... > & set_group()
Limit results to tables with the specified group type (grouped queries only).
iter_iterable< Components... > & set_var(const char *name, flecs::table_range value)
Set query variable by name to a table range.
iter_iterable< Components... > & set_group(uint64_t group_id)
Limit results to tables with the specified group ID (grouped queries only).
flecs::entity first()
Return the first matching entity.
iter_iterable< Components... > & set_var(const char *name, flecs::table_t *value)
Set query variable by name to a table value.
iter_iterable(Iterable *it, flecs::world_t *world)
Construct iter_iterable from an iterable and a world.
iter_iterable< Components... > & set_var(int var_id, flecs::entity_t value)
Set query variable by ID.
bool is_true()
Return whether the iterator yields at least one result.
iter_iterable< Components... > & set_var(const char *name, flecs::entity_t value)
Set query variable by name to an entity value.
int32_t count()
Return the total number of entities in the result.
Class for iterating over query results.
flecs::world world() const
Get the world associated with the iterator.
Base class for iterable query objects.
bool is_true() const
Return whether the iterable has any matches.
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_group() const
Limit results to tables with the specified group type (grouped queries only).
iter_iterable< Components... > set_var(int var_id, flecs::entity_t value) const
Set query variable by ID.
void run(Func &&func) const
Run the iterator.
flecs::entity first() const
Return the first entity matched by the iterable.
void each(Func &&func) const
Each iterator.
virtual ~iterable()
Virtual destructor.
int32_t count() const
Return the number of entities matched by the iterable.
iter_iterable< Components... > iter(flecs::entity e) const
Create an iterator.
page_iterable< Components... > page(int32_t offset, int32_t limit)
Page iterator.
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, flecs::table_range value) const
Set query variable by name to a table range.
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).
flecs::entity find(Func &&func) const
Find the first entity matching a condition.
iter_iterable< Components... > iter(flecs::iter &iter) const
Create an iterator.
worker_iterable< Components... > worker(int32_t index, int32_t count)
Worker iterator.
iter_iterable< Components... > iter(flecs::world_t *world=nullptr) const
Create an iterator.
iter_iterable< Components... > set_group(uint64_t group_id) const
Limit results to tables with the specified group ID (grouped queries only).
Forward declaration of page_iterable.
page_iterable(int32_t offset, int32_t limit, Iterable *it)
Construct a page_iterable from an offset, limit, and source iterable.
int32_t count() const
Get the number of entities in the range.
int32_t offset() const
Get the offset of the range.
table_t * get_table() const
Get the table.
Forward declaration of worker_iterable.
worker_iterable(int32_t index, int32_t count, iterable< Components... > *it)
Construct a worker_iterable from an index, count, and source iterable.