22 : query_(ECS_CONST_CAST(
query_t*, q)) {
32 flecs_poly_claim(query_);
41 this->query_ = obj.query_;
42 flecs_poly_claim(this->query_);
46 this->query_ = obj.query_;
47 flecs_poly_claim(this->query_);
52 this->query_ = obj.query_;
57 this->query_ = obj.query_;
74 operator bool()
const {
75 return query_ !=
nullptr;
85 "should only be called on queries associated with entities");
95 if (query_ && !query_->
entity) {
96 if (!flecs_poly_release(query_)) {
139 template <
typename Func>
140 void each_term(
const Func& func) {
141 for (
int i = 0; i < query_->
term_count; i ++) {
152 int32_t term_count() {
156 int32_t field_count() {
160 int32_t find_var(
const char *name) {
181# include "../json/query.inl"
188template<
typename ... Components>
194 using query_base::query_base;
201 query_base::operator=(obj);
208 query_base::operator=(FLECS_FWD(obj));
214 ecs_assert(query_ !=
nullptr, ECS_INVALID_PARAMETER,
215 "cannot iterate invalid query");
228template <
typename... Comps,
typename... Args>
236 desc.
entity = query_entity;
240template <
typename... Comps,
typename... Args>
249template<
typename Func,
typename ... Args>
252template<
typename Func,
typename E,
typename ... Args>
257 f.each(FLECS_MOV(func));
262template<
typename Func,
typename ... Args>
265template<
typename Func,
typename ... Args>
270 f.each(FLECS_MOV(func));
275template<
typename Func,
typename T =
int>
278template <
typename Func>
285template <
typename Func>
294template <
typename Func>
299template <
typename T,
typename Func>
304 _::each_delegate<Func, T>(func).invoke(&it);
308template <
typename Func>
309inline void world::each(flecs::id_t each_id, Func&& func)
const {
313 _::each_delegate<Func>(func).invoke(&it);
#define ecs_assert(condition, error_code,...)
Assert.
flecs::query_builder< Comps... > query_builder(Args &&... args) const
Create a query builder.
void each(Func &&func) const
Iterate over all entities with components in argument list of function.
flecs::query< Comps... > query(Args &&... args) const
Create a query.
bool ecs_each_next(ecs_iter_t *it)
Progress an iterator created with ecs_each_id().
ecs_iter_t ecs_each_id(const ecs_world_t *world, ecs_id_t id)
Iterate all entities with specified (component id).
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
bool ecs_query_next(ecs_iter_t *it)
Progress query iterator.
const ecs_query_group_info_t * ecs_query_get_group_info(const ecs_query_t *query, uint64_t group_id)
Get information about query group.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find variable index.
void ecs_query_fini(ecs_query_t *query)
Delete a query.
char * ecs_query_plan(const ecs_query_t *query)
Convert query to a string.
ecs_iter_t ecs_query_iter(const ecs_world_t *world, const ecs_query_t *query)
Create a query iterator.
char * ecs_query_str(const ecs_query_t *query)
Convert query to string expression.
ecs_query_t * ecs_query_init(ecs_world_t *world, const ecs_query_desc_t *desc)
Create a query.
bool ecs_query_changed(ecs_query_t *query)
Returns whether the query data changed since the last iteration.
Component for storing a poly object.
ecs_poly_t * poly
Pointer to poly object.
Used with ecs_query_init().
ecs_term_t terms[32]
Query terms.
ecs_entity_t entity
Entity associated with query (optional)
Type that contains information about a query group.
void * ctx
Group context, returned by on_group_create.
Queries are lists of constraints (terms) that match entities.
ecs_term_t terms[32]
Query terms.
ecs_world_t * world
World or stage query was created with.
ecs_entity_t entity
Entity associated with query (optional)
int8_t term_count
Number of query terms.
int8_t field_count
Number of fields returned by query.
ecs_id_t id
Component id to be matched by term.
bool changed() const
Returns whether the query data changed since the last iteration.
void * group_ctx(uint64_t group_id) const
Get context for group.
flecs::string plan() const
Returns a string representing the query plan.
const flecs::query_group_info_t * group_info(uint64_t group_id) const
Get info for group.
void destruct()
Free persistent query.
Class that describes a term.