20 return flecs::id(iter_->world, iter_->event_id);
23inline flecs::world iter::world()
const {
24 return flecs::world(iter_->world);
28 ecs_assert(row <
static_cast<size_t>(iter_->count),
29 ECS_COLUMN_INDEX_OUT_OF_RANGE, NULL);
43 ecs_check(ECS_HAS_ID_FLAG(
id, PAIR), ECS_INVALID_PARAMETER, NULL);
57inline flecs::table iter::other_table()
const {
58 return flecs::table(iter_->real_world, iter_->other_table);
61inline flecs::table_range iter::range()
const {
62 return flecs::table_range(iter_->real_world, iter_->table,
63 iter_->offset, iter_->count);
66template <
typename T,
typename A,
67 typename std::enable_if<std::is_const<T>::value,
void>::type*>
71 "cannot .field from .each, use .field_at<%s>(%d, row) instead",
72 _::type_name<T>(), index);
73 return get_field<A>(index);
76template <
typename T,
typename A,
77 typename std::enable_if<
78 std::is_const<T>::value ==
false,
void>
::type*>
82 "cannot .field from .each, use .field_at<%s>(%d, row) instead",
83 _::type_name<T>(), index);
85 ECS_ACCESS_VIOLATION, NULL);
86 return get_field<A>(index);
90 ecs_assert(var_id != -1, ECS_INVALID_PARAMETER, 0);
98 const flecs::query_t *q = iter_->query;
101 ecs_assert(var_id != -1, ECS_INVALID_PARAMETER, name);
105template <
typename Func>
107 ecs_assert(iter_->table !=
nullptr, ECS_INVALID_OPERATION, NULL);
111 const ecs_table_record_t *tr = iter_->trs[index];
112 int32_t i = tr->index, end = i + tr->count;
113 for (; i < end; i ++) {
115 ecs_assert(ECS_IS_PAIR(
id), ECS_INVALID_PARAMETER,
116 "field does not match a pair");
118 ecs_pair_second(iter_->real_world,
id));
#define ecs_assert(condition, error_code,...)
Assert.
#define ecs_check(condition, error_code,...)
Check.
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return field source.
bool ecs_field_is_readonly(const ecs_iter_t *it, int8_t index)
Test whether the field is readonly.
ecs_id_t ecs_field_id(const ecs_iter_t *it, int8_t index)
Return id matched for field.
bool ecs_field_is_set(const ecs_iter_t *it, int8_t index)
Test whether field is set.
ecs_entity_t ecs_iter_get_var(ecs_iter_t *it, int32_t var_id)
Get value of iterator variable as entity.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find variable index.
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get type for table.
ecs_world_t * real_world
Actual world.
ecs_flags32_t flags
Iterator flags.
ecs_table_t * table
Current table.
ecs_world_t * world
The world.
A type is a list of (component) ids.
ecs_id_t * array
Array with ids.
Wrapper class around a field.
Class that wraps around a flecs::id_t.
flecs::id id(int8_t index) const
Obtain id matched for field.
flecs::field< A > field(int8_t index) const
Get readonly access to field data.
int32_t field_count() const
Number of fields in iterator.
flecs::entity entity(size_t row) const
Obtain mutable handle to entity being iterated over.
flecs::id pair(int8_t index) const
Obtain pair id matched for field.
flecs::entity get_var(int var_id) const
Get value of variable by id.
void targets(int8_t index, const Func &func)
Iterate targets for pair field.
flecs::entity src(int8_t index) const
Obtain field source (0 if This).
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::id id(E value) const
Convert enum constant to entity.