32 explicit range_iterator(T value)
35 bool operator!=(range_iterator
const& other)
const
37 return value_ != other.value_;
40 T
const& operator*()
const
45 range_iterator& operator++()
82 return row_iterator(0);
86 row_iterator
end()
const {
87 return row_iterator(
static_cast<size_t>(iter_->count));
113 "operation invalid before calling next()");
114 return static_cast<size_t>(iter_->count);
124 return iter_->delta_time;
132 return iter_->delta_system_time;
160 template <
typename T>
162 return static_cast<T*
>(iter_->ctx);
175 template <
typename T>
178 return static_cast<T*
>(iter_->param);
220 return iter_->field_count;
228 size_t size(int8_t index)
const {
268 return iter_->term_index;
292 template <
typename T,
typename A = actual_type_t<T>, if_t<is_const_v<T>> = 0>
307 template <
typename T,
typename A = actual_type_t<T>, if_not_t<is_const_v<T>> = 0>
321 ecs_assert(!(iter_->flags & EcsIterCppEach) ||
323 "cannot .field from .each, use .field_at(%d, row) instead", index);
324 return get_unchecked_field(index);
335 if (iter_->row_fields & (1llu << index)) {
336 return get_unchecked_field_at(index, row)[0];
338 return get_unchecked_field(index)[row];
350 template <
typename T,
typename A = actual_type_t<T>, if_t< is_const_v<T> > = 0>
351 const A&
field_at(int8_t index,
size_t row)
const {
352 if (iter_->row_fields & (1llu << index)) {
353 return get_field_at<A>(index, row)[0];
355 return get_field<A>(index)[row];
367 template <
typename T,
typename A = actual_type_t<T>, if_not_t< is_const_v<T> > = 0>
371 if (iter_->row_fields & (1llu << index)) {
372 return get_field_at<A>(index, row)[0];
374 return get_field<A>(index)[row];
384 iter_->entities,
static_cast<size_t>(iter_->count),
false);
440 if (iter_->flags & EcsIterIsValid && iter_->table) {
441 ECS_TABLE_UNLOCK(iter_->world, iter_->table);
443 bool result = iter_->next(iter_);
444 iter_->flags |= EcsIterIsValid;
445 if (result && iter_->table) {
446 ECS_TABLE_LOCK(iter_->world, iter_->table);
456 iter_->callback(iter_);
464 template <
typename Func>
465 void targets(int8_t index,
const Func& func);
477 if (iter_->flags & EcsIterIsValid && iter_->table) {
478 ECS_TABLE_UNLOCK(iter_->world, iter_->table);
485 template <
typename T,
typename A = actual_type_t<T>>
509 return flecs::field<A>(
515 template <
typename T,
typename A = actual_type_t<T>>
516 flecs::field<T> get_field_at(int8_t index, int32_t row)
const {
521 term_id == _::type<T>::id(iter_->world),
525 return flecs::field<A>(
530 flecs::untyped_field get_unchecked_field(int8_t index)
const {
543 count =
static_cast<size_t>(iter_->count);
546 return flecs::untyped_field(
550 flecs::untyped_field get_unchecked_field_at(int8_t index,
size_t row)
const {
552 return flecs::untyped_field(
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_ACCESS_VIOLATION
Access violation error code.
#define ECS_INVALID_OPERATION
Invalid operation error code.
#define ECS_COLUMN_TYPE_MISMATCH
Column type mismatch error code.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
#define ecs_check(condition, error_code,...)
Check.
ecs_id_t ecs_entity_t
An entity identifier.
ecs_iter_t iter_t
Iterator type.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return the field source.
bool ecs_iter_changed(ecs_iter_t *it)
Return whether the current iterator result has changed.
bool ecs_field_is_readonly(const ecs_iter_t *it, int8_t index)
Test whether the field is read-only.
void ecs_iter_fini(ecs_iter_t *it)
Clean up iterator resources.
char * ecs_iter_str(const ecs_iter_t *it)
Convert an iterator to a string.
void * ecs_field_at_w_size(const ecs_iter_t *it, size_t size, int8_t index, int32_t row)
Get data for a field at a specified row.
ecs_id_t ecs_field_id(const ecs_iter_t *it, int8_t index)
Return the ID matched for a field.
bool ecs_field_is_set(const ecs_iter_t *it, int8_t index)
Test whether a field is set.
bool ecs_field_is_self(const ecs_iter_t *it, int8_t index)
Test whether the field is matched on self.
int32_t ecs_field_column(const ecs_iter_t *it, int8_t index)
Return the index of a matched table column.
uint64_t ecs_iter_get_group(const ecs_iter_t *it)
Return the group ID for the currently iterated result.
void * ecs_field_w_size(const ecs_iter_t *it, size_t size, int8_t index)
Get data for a field.
size_t ecs_field_size(const ecs_iter_t *it, int8_t index)
Return the field type size.
#define ecs_ftime_t
Customizable precision for scalar time values.
void ecs_iter_skip(ecs_iter_t *it)
Skip a table while iterating.
ecs_world_t * world
The world.
int32_t count
Number of entities to iterate.
Iterate over an integer range (used to iterate over entity range).
Wrapper class around a field.
Class that wraps around a flecs::id_t.
size_t size(int8_t index) const
Size of the field data type.
flecs::field< A > field(int8_t index) const
Get read-only access to field data.
flecs::entity event() const
Get the event entity associated with the iterator.
const A & field_at(int8_t index, size_t row) const
Get const reference to field at row.
flecs::table table() const
Get the table for the current iterator result.
bool is_self(int8_t index) const
Return whether the field is matched on self.
flecs::string str() const
Convert current iterator result to string.
flecs::type type() const
Get the type of the iterated table.
int32_t field_count() const
Number of fields in the iterator.
ecs_ftime_t delta_system_time() const
Get the time elapsed since the last system invocation.
int32_t column_index(int8_t index) const
Obtain the column index for the field.
void * param()
Access param.
row_iterator begin() const
Get an iterator to the beginning of the entity range.
row_iterator end() const
Get an iterator to the end of the entity range.
void * field_at(int8_t index, size_t row) const
Get pointer to field at row.
ecs_ftime_t delta_time() const
Get the time elapsed since the last frame.
bool is_readonly(int8_t index) const
Return whether the field is readonly.
flecs::table other_table() const
Get the other table for the current iterator result.
const flecs::iter_t * c_ptr() const
Get a pointer to the underlying C iterator object.
bool changed()
Check if the current table has changed since the last iteration.
int8_t term_index() const
Obtain the term that triggered an observer.
void fini()
Free iterator resources.
bool is_set(int8_t index) const
Return whether the field is set.
A & field_at(int8_t index, size_t row) const
Get mutable reference to field at row.
flecs::entity entity(size_t row) const
Obtain a mutable handle to the entity being iterated over.
void each()
Forward to each().
flecs::untyped_field field(int8_t index) const
Get unchecked access to field data.
flecs::id event_id() const
Get the event ID associated with the iterator.
flecs::entity get_var(int var_id) const
Get value of variable by ID.
size_t count() const
Get the number of entities to iterate over.
flecs::field< const flecs::entity_t > entities() const
Get read-only access to entity IDs.
uint64_t group_id() const
Return the group ID for the current table (grouped queries only).
iter(ecs_iter_t *it)
Construct iterator from C iterator object.
flecs::table_range range() const
Get the table range for the current iterator result.
void targets(int8_t index, const Func &func)
Iterate targets for pair field.
flecs::entity src(int8_t index) const
Obtain the field source (0 if This).
void skip()
Skip current table.
bool next()
Progress iterator.
flecs::world world() const
Get the world associated with the iterator.
flecs::entity system() const
Get the system entity associated with the iterator.
Type that represents a pair.
Unsafe wrapper class around a field.