Flecs v4.0
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::query_builder_i< Base, Components > Struct Template Referenceabstract

Query builder interface. More...

#include <builder_i.hpp>

Inheritance diagram for flecs::query_builder_i< Base, Components >:
[legend]

Public Member Functions

 query_builder_i (ecs_query_desc_t *desc, int32_t term_index=0)
 
Base & instanced ()
 
Base & query_flags (ecs_flags32_t flags)
 
Base & cache_kind (query_cache_kind_t kind)
 
Base & cached ()
 
Base & expr (const char *expr)
 
template<typename T >
Base & with ()
 
Base & with (id_t id)
 
Base & with (const char *name)
 
Base & with (const char *first, const char *second)
 
Base & with (entity_t r, entity_t o)
 
Base & with (entity_t r, const char *o)
 
template<typename First >
Base & with (id_t o)
 
template<typename First >
Base & with (const char *second)
 
template<typename First , typename Second >
Base & with ()
 
template<typename E , if_t< is_enum< E >::value > = 0>
Base & with (E value)
 
Base & with (flecs::term &term)
 
Base & with (flecs::term &&term)
 
template<typename ... Args>
Base & without (Args &&... args)
 
template<typename T , typename ... Args>
Base & without (Args &&... args)
 
template<typename First , typename Second >
Base & without ()
 
Base & write ()
 
template<typename ... Args>
Base & write (Args &&... args)
 
template<typename T , typename ... Args>
Base & write (Args &&... args)
 
template<typename First , typename Second >
Base & write ()
 
Base & read ()
 
template<typename ... Args>
Base & read (Args &&... args)
 
template<typename T , typename ... Args>
Base & read (Args &&... args)
 
template<typename First , typename Second >
Base & read ()
 
Base & scope_open ()
 
Base & scope_close ()
 
Base & term ()
 
Base & term_at (int32_t term_index)
 
template<typename T >
Base & order_by (int(*compare)(flecs::entity_t, const T *, flecs::entity_t, const T *))
 Sort the output of a query.
 
Base & order_by (flecs::entity_t component, int(*compare)(flecs::entity_t, const void *, flecs::entity_t, const void *))
 Sort the output of a query.
 
template<typename T >
Base & group_by (uint64_t(*group_by_action)(flecs::world_t *, flecs::table_t *table, flecs::id_t id, void *ctx))
 Group and sort matched tables.
 
Base & group_by (flecs::entity_t component, uint64_t(*group_by_action)(flecs::world_t *, flecs::table_t *table, flecs::id_t id, void *ctx))
 Group and sort matched tables.
 
template<typename T >
Base & group_by ()
 Group and sort matched tables.
 
Base & group_by (flecs::entity_t component)
 Group and sort matched tables.
 
Base & group_by_ctx (void *ctx, ecs_ctx_free_t ctx_free=nullptr)
 Specify context to be passed to group_by function.
 
Base & on_group_create (ecs_group_create_action_t action)
 Specify on_group_create action.
 
Base & on_group_delete (ecs_group_delete_action_t action)
 Specify on_group_delete action.
 
- Public Member Functions inherited from flecs::term_builder_i< Base >
 term_builder_i (ecs_term_t *term_ptr)
 
Base & term (id_t id)
 
Base & src ()
 
Base & first ()
 
Base & second ()
 
Base & src (flecs::entity_t id)
 
template<typename T >
Base & src ()
 
Base & src (const char *name)
 
Base & first (flecs::entity_t id)
 
template<typename T >
Base & first ()
 
Base & first (const char *name)
 
Base & second (flecs::entity_t id)
 
template<typename T >
Base & second ()
 
Base & second (const char *name)
 
Base & up (flecs::entity_t trav=0)
 
template<typename Trav >
Base & up ()
 
Base & cascade (flecs::entity_t trav=0)
 
template<typename Trav >
Base & cascade ()
 
Base & desc ()
 
Base & parent ()
 
Base & trav (flecs::entity_t trav, flecs::flags32_t flags=0)
 
Base & id_flags (id_t flags)
 Set id flags for term.
 
Base & inout (flecs::inout_kind_t inout)
 Set read/write access of term.
 
Base & inout_stage (flecs::inout_kind_t inout)
 Set read/write access for stage.
 
Base & write ()
 Short for inout_stage(flecs::Out).
 
Base & read ()
 Short for inout_stage(flecs::In).
 
Base & read_write ()
 Short for inout_stage(flecs::InOut).
 
Base & in ()
 Short for inout(flecs::In)
 
Base & out ()
 Short for inout(flecs::Out)
 
Base & inout ()
 Short for inout(flecs::InOut)
 
Base & inout_none ()
 Short for inout(flecs::In)
 
Base & oper (flecs::oper_kind_t oper)
 Set operator of term.
 
Base & and_ ()
 
Base & or_ ()
 
Base & not_ ()
 
Base & optional ()
 
Base & and_from ()
 
Base & or_from ()
 
Base & not_from ()
 
Base & singleton ()
 Match singleton.
 
Base & filter ()
 
- Public Member Functions inherited from flecs::term_ref_builder_i< Base >
Base & self ()
 
Base & id (flecs::entity_t id)
 
Base & entity (flecs::entity_t entity)
 
Base & name (const char *name)
 
Base & var (const char *var_name)
 
Base & flags (flecs::flags32_t flags)
 

Protected Member Functions

virtual flecs::world_t * world_v () override=0
 
- Protected Member Functions inherited from flecs::term_builder_i< Base >
void set_term (ecs_term_t *term)
 
- Protected Member Functions inherited from flecs::term_ref_builder_i< Base >
void assert_term_ref ()
 

Protected Attributes

int32_t term_index_
 
int32_t expr_count_
 

Additional Inherited Members

- Public Attributes inherited from flecs::term_builder_i< Base >
ecs_term_tterm_
 
- Public Attributes inherited from flecs::term_ref_builder_i< Base >
ecs_term_ref_tterm_ref_
 

Detailed Description

template<typename Base, typename ... Components>
struct flecs::query_builder_i< Base, Components >

Query builder interface.

Definition at line 18 of file builder_i.hpp.

Constructor & Destructor Documentation

◆ query_builder_i()

template<typename Base , typename ... Components>
flecs::query_builder_i< Base, Components >::query_builder_i ( ecs_query_desc_t * desc,
int32_t term_index = 0 )
inline

Definition at line 19 of file builder_i.hpp.

Member Function Documentation

◆ cache_kind()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::cache_kind ( query_cache_kind_t kind)
inline

Definition at line 34 of file builder_i.hpp.

◆ cached()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::cached ( )
inline

Definition at line 39 of file builder_i.hpp.

◆ expr()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::expr ( const char * expr)
inline

Definition at line 43 of file builder_i.hpp.

◆ group_by() [1/4]

template<typename Base , typename ... Components>
template<typename T >
Base & flecs::query_builder_i< Base, Components >::group_by ( )
inline

Group and sort matched tables.

Same as group_by<T>, but with default group_by action.

Template Parameters
TThe component used to determine the group rank.

Definition at line 322 of file builder_i.hpp.

◆ group_by() [2/4]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::group_by ( flecs::entity_t component)
inline

Group and sort matched tables.

Same as group_by, but with default group_by action.

Parameters
componentThe component used to determine the group rank.

Definition at line 331 of file builder_i.hpp.

◆ group_by() [3/4]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::group_by ( flecs::entity_t component,
uint64_t(*)(flecs::world_t *, flecs::table_t *table, flecs::id_t id, void *ctx) group_by_action )
inline

Group and sort matched tables.

Same as group_by<T>, but with component identifier.

Parameters
componentThe component used to determine the group rank.
group_by_actionCallback that determines group id for table.

Definition at line 310 of file builder_i.hpp.

◆ group_by() [4/4]

template<typename Base , typename ... Components>
template<typename T >
Base & flecs::query_builder_i< Base, Components >::group_by ( uint64_t(*)(flecs::world_t *, flecs::table_t *table, flecs::id_t id, void *ctx) group_by_action)
inline

Group and sort matched tables.

Similar to ecs_query_order_by(), but instead of sorting individual entities, this operation only sorts matched tables. This can be useful of a query needs to enforce a certain iteration order upon the tables it is iterating, for example by giving a certain component or tag a higher priority.

The sorting function assigns a "rank" to each type, which is then used to sort the tables. Tables with higher ranks will appear later in the iteration.

Resorting happens when a query iterator is obtained, and only if the set of matched tables for a query has changed. If table sorting is enabled together with entity sorting, table sorting takes precedence, and entities will be sorted within each set of tables that are assigned the same rank.

Template Parameters
TThe component used to determine the group rank.
Parameters
group_by_actionCallback that determines group id for table.

Definition at line 299 of file builder_i.hpp.

◆ group_by_ctx()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::group_by_ctx ( void * ctx,
ecs_ctx_free_t ctx_free = nullptr )
inline

Specify context to be passed to group_by function.

Parameters
ctxContext to pass to group_by function.
ctx_freeFunction to cleanup context (called when query is deleted).

Definition at line 340 of file builder_i.hpp.

◆ instanced()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::instanced ( )
inline

Definition at line 24 of file builder_i.hpp.

◆ on_group_create()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::on_group_create ( ecs_group_create_action_t action)
inline

Specify on_group_create action.

Definition at line 348 of file builder_i.hpp.

◆ on_group_delete()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::on_group_delete ( ecs_group_delete_action_t action)
inline

Specify on_group_delete action.

Definition at line 355 of file builder_i.hpp.

◆ order_by() [1/2]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::order_by ( flecs::entity_t component,
int(*)(flecs::entity_t, const void *, flecs::entity_t, const void *) compare )
inline

Sort the output of a query.

Same as order_by<T>, but with component identifier.

Parameters
componentThe component used to sort.
compareThe compare function used to sort the components.

Definition at line 275 of file builder_i.hpp.

◆ order_by() [2/2]

template<typename Base , typename ... Components>
template<typename T >
Base & flecs::query_builder_i< Base, Components >::order_by ( int(*)(flecs::entity_t, const T *, flecs::entity_t, const T *) compare)
inline

Sort the output of a query.

This enables sorting of entities across matched tables. As a result of this operation, the order of entities in the matched tables may be changed. Resorting happens when a query iterator is obtained, and only if the table data has changed.

If multiple queries that match the same (down)set of tables specify different sorting functions, resorting is likely to happen every time an iterator is obtained, which can significantly slow down iterations.

The sorting function will be applied to the specified component. Resorting only happens if that component has changed, or when the entity order in the table has changed. If no component is provided, resorting only happens when the entity order changes.

Template Parameters
TThe component used to sort.
Parameters
compareThe compare function used to sort the components.

Definition at line 264 of file builder_i.hpp.

◆ query_flags()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::query_flags ( ecs_flags32_t flags)
inline

Definition at line 29 of file builder_i.hpp.

◆ read() [1/4]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::read ( )
inline

Definition at line 185 of file builder_i.hpp.

◆ read() [2/4]

template<typename Base , typename ... Components>
template<typename First , typename Second >
Base & flecs::query_builder_i< Base, Components >::read ( )
inline

Definition at line 201 of file builder_i.hpp.

◆ read() [3/4]

template<typename Base , typename ... Components>
template<typename ... Args>
Base & flecs::query_builder_i< Base, Components >::read ( Args &&... args)
inline

Definition at line 191 of file builder_i.hpp.

◆ read() [4/4]

template<typename Base , typename ... Components>
template<typename T , typename ... Args>
Base & flecs::query_builder_i< Base, Components >::read ( Args &&... args)
inline

Definition at line 196 of file builder_i.hpp.

◆ scope_close()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::scope_close ( )
inline

Definition at line 210 of file builder_i.hpp.

◆ scope_open()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::scope_open ( )
inline

Definition at line 206 of file builder_i.hpp.

◆ term()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::term ( )
inline

Definition at line 216 of file builder_i.hpp.

◆ term_at()

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::term_at ( int32_t term_index)
inline

Definition at line 234 of file builder_i.hpp.

◆ with() [1/12]

template<typename Base , typename ... Components>
template<typename T >
Base & flecs::query_builder_i< Base, Components >::with ( )
inline

Definition at line 56 of file builder_i.hpp.

◆ with() [2/12]

template<typename Base , typename ... Components>
template<typename First , typename Second >
Base & flecs::query_builder_i< Base, Components >::with ( )
inline

Definition at line 123 of file builder_i.hpp.

◆ with() [3/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( const char * first,
const char * second )
inline

Definition at line 85 of file builder_i.hpp.

◆ with() [4/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( const char * name)
inline

Definition at line 76 of file builder_i.hpp.

◆ with() [5/12]

template<typename Base , typename ... Components>
template<typename First >
Base & flecs::query_builder_i< Base, Components >::with ( const char * second)
inline

Definition at line 118 of file builder_i.hpp.

◆ with() [6/12]

template<typename Base , typename ... Components>
template<typename E , if_t< is_enum< E >::value > = 0>
Base & flecs::query_builder_i< Base, Components >::with ( E value)
inline

Definition at line 128 of file builder_i.hpp.

◆ with() [7/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( entity_t r,
const char * o )
inline

Definition at line 103 of file builder_i.hpp.

◆ with() [8/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( entity_t r,
entity_t o )
inline

Definition at line 94 of file builder_i.hpp.

◆ with() [9/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( flecs::term && term)
inline

Definition at line 140 of file builder_i.hpp.

◆ with() [10/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( flecs::term & term)
inline

Definition at line 134 of file builder_i.hpp.

◆ with() [11/12]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::with ( id_t id)
inline

Definition at line 67 of file builder_i.hpp.

◆ with() [12/12]

template<typename Base , typename ... Components>
template<typename First >
Base & flecs::query_builder_i< Base, Components >::with ( id_t o)
inline

Definition at line 113 of file builder_i.hpp.

◆ without() [1/3]

template<typename Base , typename ... Components>
template<typename First , typename Second >
Base & flecs::query_builder_i< Base, Components >::without ( )
inline

Definition at line 159 of file builder_i.hpp.

◆ without() [2/3]

template<typename Base , typename ... Components>
template<typename ... Args>
Base & flecs::query_builder_i< Base, Components >::without ( Args &&... args)
inline

Definition at line 149 of file builder_i.hpp.

◆ without() [3/3]

template<typename Base , typename ... Components>
template<typename T , typename ... Args>
Base & flecs::query_builder_i< Base, Components >::without ( Args &&... args)
inline

Definition at line 154 of file builder_i.hpp.

◆ world_v()

template<typename Base , typename ... Components>
virtual flecs::world_t * flecs::query_builder_i< Base, Components >::world_v ( )
overrideprotectedpure virtual

◆ write() [1/4]

template<typename Base , typename ... Components>
Base & flecs::query_builder_i< Base, Components >::write ( )
inline

Definition at line 165 of file builder_i.hpp.

◆ write() [2/4]

template<typename Base , typename ... Components>
template<typename First , typename Second >
Base & flecs::query_builder_i< Base, Components >::write ( )
inline

Definition at line 181 of file builder_i.hpp.

◆ write() [3/4]

template<typename Base , typename ... Components>
template<typename ... Args>
Base & flecs::query_builder_i< Base, Components >::write ( Args &&... args)
inline

Definition at line 171 of file builder_i.hpp.

◆ write() [4/4]

template<typename Base , typename ... Components>
template<typename T , typename ... Args>
Base & flecs::query_builder_i< Base, Components >::write ( Args &&... args)
inline

Definition at line 176 of file builder_i.hpp.

Member Data Documentation

◆ expr_count_

template<typename Base , typename ... Components>
int32_t flecs::query_builder_i< Base, Components >::expr_count_
protected

Definition at line 363 of file builder_i.hpp.

◆ term_index_

template<typename Base , typename ... Components>
int32_t flecs::query_builder_i< Base, Components >::term_index_
protected

Definition at line 362 of file builder_i.hpp.


The documentation for this struct was generated from the following file: