22 : query_(ECS_CONST_CAST(
query_t*, q)) {
32 flecs_poly_claim(query_);
41 this->query_ = obj.query_;
44 flecs_poly_claim(this->query_);
50 this->query_ = obj.query_;
53 flecs_poly_claim(this->query_);
59 this->query_ = obj.query_;
64 this->query_ = obj.query_;
81 operator bool()
const {
82 return query_ !=
nullptr;
92 "should only be called on queries associated with entities");
102 if (query_ && !query_->
entity) {
103 if (!flecs_poly_release(query_)) {
146 template <
typename Func>
147 void each_term(
const Func& func) {
148 for (
int i = 0; i < query_->
term_count; i ++) {
159 int32_t term_count() {
163 int32_t field_count() {
167 int32_t find_var(
const char *name) {
188# include "../json/query.inl"
195template<
typename ... Components>
201 using query_base::query_base;
208 query_base::operator=(obj);
215 query_base::operator=(FLECS_FWD(obj));
221 ecs_assert(query_ !=
nullptr, ECS_INVALID_PARAMETER,
222 "cannot iterate invalid query");
235template <
typename... Comps,
typename... Args>
243 desc.
entity = query_entity;
247template <
typename... Comps,
typename... Args>
256template<
typename Func,
typename ... Args>
259template<
typename Func,
typename E,
typename ... Args>
264 f.each(FLECS_MOV(func));
269template<
typename Func,
typename ... Args>
272template<
typename Func,
typename ... Args>
277 f.each(FLECS_MOV(func));
282template<
typename Func,
typename T =
int>
285template <
typename Func>
292template <
typename Func>
301template <
typename Func>
306template <
typename T,
typename Func>
311 _::each_delegate<Func, T>(func).invoke(&it);
315template <
typename Func>
316inline void world::each(flecs::id_t each_id, Func&& func)
const {
320 _::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.