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));
114 "operation invalid before calling next()");
115 return static_cast<size_t>(iter_->count);
120 size_t frame_offset()
const {
122 "operation invalid before calling next()");
133 return iter_->delta_time;
141 return iter_->delta_system_time;
169 template <
typename T>
171 return static_cast<T*
>(iter_->ctx);
184 template <
typename T>
187 return static_cast<T*
>(iter_->param);
229 return iter_->field_count;
237 size_t size(int8_t index)
const {
277 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>
320 template <
typename T,
typename A = actual_type_t<T>, if_t<is_const_v<T>> = 0>
329 template <
typename T,
typename A = actual_type_t<T>, if_not_t<is_const_v<T>> = 0>
343 ecs_assert(!(iter_->flags & EcsIterCppEach) ||
345 "cannot .field from .each, use .field_at(%d, row) instead", index);
346 return get_unchecked_field(index);
357 if (iter_->row_fields & (1llu << index)) {
358 return get_unchecked_field_at(index, row)[0];
360 return get_unchecked_field(index)[row];
372 template <
typename T,
typename A = actual_type_t<T>, if_t< is_const_v<T> > = 0>
373 const A&
field_at(int8_t index,
size_t row)
const {
374 if (iter_->row_fields & (1llu << index)) {
375 return get_field_at<A>(index, row)[0];
377 return get_field<A>(index)[row];
389 template <
typename T,
typename A = actual_type_t<T>, if_not_t< is_const_v<T> > = 0>
393 if (iter_->row_fields & (1llu << index)) {
394 return get_field_at<A>(index, row)[0];
396 return get_field<A>(index)[row];
406 iter_->entities,
static_cast<size_t>(iter_->count),
false);
409#ifdef FLECS_CACHED_QUERIES
439#ifdef FLECS_QUERY_PLANS
466 if (iter_->flags & EcsIterIsValid && iter_->table) {
467 ECS_TABLE_UNLOCK(iter_->stage, iter_->table);
469 bool result = iter_->next(iter_);
470 iter_->flags |= EcsIterIsValid;
471 if (result && iter_->table) {
472 ECS_TABLE_LOCK(iter_->stage, iter_->table);
482 iter_->callback(iter_);
490 template <
typename Func>
491 void targets(int8_t index,
const Func& func);
503 if (iter_->flags & EcsIterIsValid && iter_->table) {
504 ECS_TABLE_UNLOCK(iter_->stage, iter_->table);
511 template <
typename T,
typename A = actual_type_t<T>>
535 return flecs::field<A>(
543 template <
typename T,
typename A = actual_type_t<T>>
544 flecs::base_field<T> get_base_field(int8_t index)
const {
557 count =
static_cast<size_t>(iter_->count);
560 return flecs::base_field<A>(
566 template <
typename T,
typename A = actual_type_t<T>>
567 flecs::field<T> get_field_at(int8_t index, int32_t row)
const {
572 term_id == _::type<T>::id(iter_->stage),
576 return flecs::field<A>(
581 flecs::untyped_field get_unchecked_field(int8_t index)
const {
594 count =
static_cast<size_t>(iter_->count);
597 return flecs::untyped_field(
601 flecs::untyped_field get_unchecked_field_at(int8_t index,
size_t row)
const {
603 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.
size_t ecs_field_stride(const ecs_iter_t *it, int8_t index)
Return the field storage stride.
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.
void * ecs_base_field_w_size(const ecs_iter_t *it, size_t size, int8_t index)
Get data for a field matched through component inheritance.
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.
int32_t frame_offset
Offset relative to the start of iteration.
ecs_flags32_t flags
Iterator flags.
int32_t count
Number of entities to iterate.
Iterate over an integer range (used to iterate over entity range).
Wrapper class around a field matched through component inheritance.
entity()
Default constructor.
Wrapper class around a field.
field(T *array, size_t count, bool is_shared=false)
Create a field from a component array.
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/write access to field data.
const A & field_at(int8_t index, size_t row) const
Get const reference to field at row.
bool is_self(int8_t index) const
Return whether the field is matched on self.
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.
flecs::base_field< A > base_field(int8_t index) const
Get access to a field matched through component inheritance.
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.
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.
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.
pair(type &v)
Construct pair from a mutable reference to the storage type.
system()
Default constructor.
table()
Default constructor.
type()
Default constructor.
Unsafe wrapper class around a field.
flecs::event_builder event(flecs::entity_t evt) const
Create a new event.