29 : query_(ECS_CONST_CAST(
query_t*, q)) {
40 flecs_poly_claim(query_);
50 this->query_ = obj.query_;
53 flecs_poly_claim(this->query_);
60 this->query_ = obj.query_;
63 flecs_poly_claim(this->query_);
70 this->query_ = obj.query_;
76 this->query_ = obj.query_;
97 operator bool()
const {
98 return query_ !=
nullptr;
108 "should only be called on queries associated with entities");
115 if (query_ && !query_->
entity) {
116 if (!flecs_poly_release(query_)) {
170 template <
typename Func>
172 for (
int i = 0; i < query_->
term_count; i ++) {
218 ecs_table_range_t r = {
261template<
typename ... Components>
299 "cannot iterate invalid query");
312template <
typename... Comps,
typename... Args>
320 desc.
entity = query_entity;
324template <
typename... Comps,
typename... Args>
333template<
typename Func,
typename ... Args>
336template<
typename Func,
typename E>
342 for (int32_t i = 0; i < entities.
alive_count; i ++) {
348template<
typename Func,
typename E,
typename ... Args>
353 f.each(FLECS_MOV(func));
358template<
typename Func,
typename ... Args>
361template<
typename Func,
typename ... Args>
366 f.each(FLECS_MOV(func));
371template<
typename Func,
typename T =
int>
374template <
typename Func>
381template <
typename Func>
390template <
typename Func>
395template <
typename T,
typename Func>
400 _::each_delegate<Func, T>(func).invoke(&it);
404template <
typename Func>
409 _::each_delegate<Func>(func).invoke(&it);
typename first_arg< Func >::type first_arg_t
Convenience alias for the first argument type of a callable.
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_INVALID_OPERATION
Invalid operation error code.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
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 the argument list of the function.
flecs::query< Comps... > query(Args &&... args) const
Create a query.
ecs_entity_t entity_t
Entity type.
ecs_world_t world_t
World type.
ecs_iter_t ecs_each_id(const ecs_world_t *world, ecs_id_t component)
Iterate all entities with a specified (component ID).
bool ecs_each_next(ecs_iter_t *it)
Progress an iterator created with ecs_each_id().
#define ecs_get_pair(world, subject, First, second)
Get the first element of a pair.
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
void ecs_iter_fini(ecs_iter_t *it)
Clean up iterator resources.
bool ecs_query_has_table(const ecs_query_t *query, ecs_table_t *table, ecs_iter_t *it)
Match a table with a query.
bool ecs_query_next(ecs_iter_t *it)
Progress a 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 a query group.
bool ecs_query_has_range(const ecs_query_t *query, ecs_table_range_t *range, ecs_iter_t *it)
Match a range with a query.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find a variable index.
void ecs_query_fini(ecs_query_t *query)
Delete a query.
bool ecs_query_has(const ecs_query_t *query, ecs_entity_t entity, ecs_iter_t *it)
Match an entity with a query.
char * ecs_query_plan(const ecs_query_t *query)
Convert a 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 a query to a 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)
Return whether the query data changed since the last iteration.
const ecs_map_t * ecs_query_get_groups(const ecs_query_t *query)
Return the map with query groups.
const ecs_query_t * ecs_query_get_cache_query(const ecs_query_t *query)
Get the query used to populate the cache.
ecs_entities_t ecs_get_entities(const ecs_world_t *world)
Return entity identifiers in the world.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get the world from a poly.
Component for storing a poly object.
ecs_poly_t * poly
Pointer to poly object.
Type returned by ecs_get_entities().
int32_t alive_count
Number of alive entity IDs.
const ecs_entity_t * ids
Array with all entity IDs in the world.
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_world_t * world
World or stage the query was created with.
ecs_entity_t entity
Entity associated with query (optional).
ecs_term_t * terms
Query terms.
int8_t term_count
Number of query terms.
int8_t field_count
Number of fields returned by the query.
ecs_id_t id
Component ID to be matched by term.
Base class for iterable query objects.
const flecs::query_t * c_ptr() const
Get a pointer to the underlying C query.
bool changed() const
Return whether the query data changed since the last iteration.
query_base & operator=(const query_base &obj)
Copy assignment operator.
flecs::entity entity() const
Get the entity associated with the query.
void each_term(const Func &func)
Iterate each term in the query, invoking a callback for each.
query_base(query_base &&obj) noexcept
Move constructor.
query_base()
Default constructor.
flecs::map< uint64_t, void * > groups() const
Iterate the active groups of a grouped query.
void * group_ctx(uint64_t group_id) const
Get context for a group.
query_base(const query_t *q)
Construct from a const query pointer.
flecs::string plan() const
Return a string representing the query plan.
flecs::term term(int32_t index) const
Get term at the specified index.
query_base(query_t *q)
Construct from a mutable query pointer.
query_base(world_t *world, const ecs_query_desc_t *desc)
Construct from a world and a query descriptor.
query_base & operator=(query_base &&obj) noexcept
Move assignment operator.
query_base(const query_base &obj)
Copy constructor.
int32_t term_count() const
Get the number of terms in the query.
const flecs::query_group_info_t * group_info(uint64_t group_id) const
Get info for a group.
flecs::string str() const
Convert the query to a string expression.
void destruct()
Free a persistent query.
int32_t find_var(const char *name) const
Find a variable by name.
int32_t field_count() const
Get the number of fields in the query.
query_base()
Default constructor.
query()
Default constructor.
query(const query &obj)
Copy constructor.
flecs::query cache_query() const
Get the cache query, if any.
query & operator=(query &&obj) noexcept
Move assignment operator.
query & operator=(const query &obj)
Copy assignment operator.
query(query &&obj) noexcept
Move constructor.
int32_t count() const
Get the number of entities in the range.
int32_t offset() const
Get the offset of the range.
table_t * get_table() const
Get the table.
Class that describes a term.
void reset()
Reset the term to its default state.
world_t * world_
Pointer to the underlying C world.
enable_if_t< false==V, int > if_not_t
Convenience enable_if alias for negated conditions.
enable_if_t< V, int > if_t
Convenience enable_if alias using int as default type.