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++()
80 row_iterator begin()
const {
81 return row_iterator(0);
84 row_iterator end()
const {
85 return row_iterator(
static_cast<size_t>(iter_->
count));
94 flecs::world world()
const;
96 const flecs::iter_t* c_ptr()
const {
100 size_t count()
const {
101 ecs_check(iter_->flags & EcsIterIsValid, ECS_INVALID_PARAMETER,
102 "operation invalid before calling next()");
103 return static_cast<size_t>(iter_->count);
109 return iter_->delta_time;
113 return iter_->delta_system_time;
116 flecs::type type()
const;
118 flecs::table table()
const;
120 flecs::table other_table()
const;
122 flecs::table_range range()
const;
134 template <
typename T>
136 return static_cast<T*
>(iter_->ctx);
149 template <
typename T>
152 return static_cast<T*
>(iter_->param);
188 return iter_->field_count;
195 size_t size(int8_t index)
const {
229 return iter_->term_index;
251 template <
typename T,
typename A = actual_type_t<T>,
252 typename std::enable_if<std::is_const<T>::value,
void>::type* =
nullptr>
267 template <
typename T,
typename A = actual_type_t<T>,
268 typename std::enable_if<
269 std::is_const<T>::value == false,
void>::type* =
nullptr>
283 ecs_assert(!(iter_->flags & EcsIterCppEach) ||
285 "cannot .field from .each, use .field_at(%d, row) instead", index);
286 return get_unchecked_field(index);
293 if (iter_->row_fields & (1llu << index)) {
294 return get_unchecked_field_at(index, row)[0];
296 return get_unchecked_field(index)[row];
303 template <
typename T,
typename A = actual_type_t<T>,
304 typename std::enable_if<std::is_const<T>::value,
void>::type* =
nullptr>
305 const A&
field_at(int8_t index,
size_t row)
const {
306 if (iter_->row_fields & (1llu << index)) {
307 return get_field_at<A>(index, row)[0];
309 return get_field<A>(index)[row];
316 template <
typename T,
typename A = actual_type_t<T>,
317 typename std::enable_if<
318 std::is_const<T>::value == false,
void>::type* =
nullptr>
321 ECS_ACCESS_VIOLATION, NULL);
322 if (iter_->row_fields & (1llu << index)) {
323 return get_field_at<A>(index, row)[0];
325 return get_field<A>(index)[row];
335 iter_->entities,
static_cast<size_t>(iter_->count),
false);
356 uint64_t group_id()
const {
377 if (iter_->flags & EcsIterIsValid && iter_->table) {
378 ECS_TABLE_UNLOCK(iter_->world, iter_->table);
380 bool result = iter_->next(iter_);
381 iter_->flags |= EcsIterIsValid;
382 if (result && iter_->table) {
383 ECS_TABLE_LOCK(iter_->world, iter_->table);
393 iter_->callback(iter_);
401 template <
typename Func>
402 void targets(int8_t index,
const Func& func);
414 if (iter_->flags & EcsIterIsValid && iter_->table) {
415 ECS_TABLE_UNLOCK(iter_->world, iter_->table);
422 template <
typename T,
typename A = actual_type_t<T>>
429 ECS_COLUMN_TYPE_MISMATCH, NULL);
443 count =
static_cast<size_t>(iter_->
count);
446 return flecs::field<A>(
452 template <
typename T,
typename A = actual_type_t<T>>
453 flecs::field<T> get_field_at(int8_t index, int32_t row)
const {
458 term_id == _::type<T>::id(iter_->world),
459 ECS_COLUMN_TYPE_MISMATCH, NULL);
462 return flecs::field<A>(
467 flecs::untyped_field get_unchecked_field(int8_t index)
const {
480 count =
static_cast<size_t>(iter_->count);
483 return flecs::untyped_field(
487 flecs::untyped_field get_unchecked_field_at(int8_t index,
size_t row)
const {
489 return flecs::untyped_field(
494 flecs::iter_t *iter_;
#define ecs_assert(condition, error_code,...)
Assert.
#define ecs_check(condition, error_code,...)
Check.
ecs_id_t ecs_entity_t
An entity identifier.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return field source.
bool ecs_iter_changed(ecs_iter_t *it)
Returns whether current iterator result has changed.
bool ecs_field_is_readonly(const ecs_iter_t *it, int8_t index)
Test whether the field is readonly.
void ecs_iter_fini(ecs_iter_t *it)
Cleanup iterator resources.
char * ecs_iter_str(const ecs_iter_t *it)
Convert iterator to string.
void * ecs_field_at_w_size(const ecs_iter_t *it, size_t size, int8_t index, int32_t row)
Get data for field at specified row.
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.
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 index of 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 field.
size_t ecs_field_size(const ecs_iter_t *it, int8_t index)
Return 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 field data type.
flecs::field< A > field(int8_t index) const
Get readonly access to field data.
const A & field_at(int8_t index, size_t row) const
Get reference to field at row.
bool is_self(int8_t index) const
Returns whether field is matched on self.
flecs::string str() const
Convert current iterator result to string.
int32_t field_count() const
Number of fields in iterator.
int32_t column_index(int8_t index) const
Obtain column index for field.
void * param()
Access param.
void * field_at(int8_t index, size_t row) const
Get pointer to field at row.
bool is_readonly(int8_t index) const
Returns whether field is readonly.
bool changed()
Check if the current table has changed since the last iteration.
int8_t term_index() const
Obtain term that triggered an observer.
void fini()
Free iterator resources.
bool is_set(int8_t index) const
Returns whether field is set.
A & field_at(int8_t index, size_t row) const
Get reference to field at row.
flecs::entity entity(size_t row) const
Obtain mutable handle to entity being iterated over.
void each()
Forward to each.
flecs::untyped_field field(int8_t index) const
Get unchecked access to field data.
flecs::entity get_var(int var_id) const
Get value of variable by id.
flecs::field< const flecs::entity_t > entities() const
Get readonly access to entity ids.
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 field source (0 if This).
void skip()
Skip current table.
bool next()
Progress iterator.
Type that represents a pair.
Unsafe wrapper class around a field.
flecs::entity entity(Args &&... args) const
Create an entity.
flecs::id id(E value) const
Convert enum constant to entity.