Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs::query< Components > Struct Template Reference

Typed query. More...

#include <impl.hpp>

Inheritance diagram for flecs::query< Components >:
[legend]

Public Member Functions

 query ()
 Default constructor.
 
 query (const query &obj)
 Copy constructor.
 
queryoperator= (const query &obj)
 Copy assignment operator.
 
 query (query &&obj) noexcept
 Move constructor.
 
queryoperator= (query &&obj) noexcept
 Move assignment operator.
 
flecs::query cache_query () const
 Get the cache query, if any.
 
 query_base ()
 Default constructor.
 
 query_base (query_t *q)
 Construct from a mutable query pointer.
 
 query_base (const query_t *q)
 Construct from a const query pointer.
 
 query_base (world_t *world, const ecs_query_desc_t *desc)
 Construct from a world and a query descriptor.
 
 query_base (const query_base &obj)
 Copy constructor.
 
 query_base (query_base &&obj) noexcept
 Move constructor.
 
- Public Member Functions inherited from flecs::query_base
 query_base ()
 Default constructor.
 
 query_base (query_t *q)
 Construct from a mutable query pointer.
 
 query_base (const query_t *q)
 Construct from a const query pointer.
 
 query_base (world_t *world, const ecs_query_desc_t *desc)
 Construct from a world and a query descriptor.
 
 query_base (const query_base &obj)
 Copy constructor.
 
query_baseoperator= (const query_base &obj)
 Copy assignment operator.
 
 query_base (query_base &&obj) noexcept
 Move constructor.
 
query_baseoperator= (query_base &&obj) noexcept
 Move assignment operator.
 
flecs::entity entity () const
 Get the entity associated with the query.
 
const flecs::query_tc_ptr () const
 Get a pointer to the underlying C query.
 
 operator const flecs::query_t * () const
 Convert to a const query pointer.
 
 operator bool () const
 Check if the query is valid.
 
void destruct ()
 Free a persistent query.
 
 ~query_base ()
 Destructor.
 
bool changed () const
 Return whether the query data changed since the last iteration.
 
const flecs::query_group_info_tgroup_info (uint64_t group_id) const
 Get info for a group.
 
void * group_ctx (uint64_t group_id) const
 Get context for a group.
 
template<typename Func >
void each_term (const Func &func)
 Iterate each term in the query, invoking a callback for each.
 
flecs::term term (int32_t index) const
 Get term at the specified index.
 
int32_t term_count () const
 Get the number of terms in the query.
 
int32_t field_count () const
 Get the number of fields in the query.
 
int32_t find_var (const char *name) const
 Find a variable by name.
 
flecs::string str () const
 Convert the query to a string expression.
 
flecs::string plan () const
 Return a string representing the query plan.
 
 operator query<> () const
 Convert to a typed query.
 
flecs::string to_json (flecs::iter_to_json_desc_t *desc=nullptr)
 Serialize a query to JSON.
 
- Public Member Functions inherited from flecs::iterable< Components... >
void each (Func &&func) const
 Each iterator.
 
void run (Func &&func) const
 Run the iterator.
 
flecs::entity find (Func &&func) const
 Find the first entity matching a condition.
 
iter_iterable< Components... > iter (flecs::world_t *world=nullptr) const
 Create an iterator.
 
iter_iterable< Components... > iter (flecs::iter &iter) const
 Create an iterator.
 
iter_iterable< Components... > iter (flecs::entity e) const
 Create an iterator.
 
page_iterable< Components... > page (int32_t offset, int32_t limit)
 Page iterator.
 
worker_iterable< Components... > worker (int32_t index, int32_t count)
 Worker iterator.
 
int32_t count () const
 Return the number of entities matched by the iterable.
 
bool is_true () const
 Return whether the iterable has any matches.
 
flecs::entity first () const
 Return the first entity matched by the iterable.
 
iter_iterable< Components... > set_var (int var_id, flecs::entity_t value) const
 Set query variable by ID.
 
iter_iterable< Components... > set_var (const char *name, flecs::entity_t value) const
 Set query variable by name to an entity value.
 
iter_iterable< Components... > set_var (const char *name, flecs::table_t *value) const
 Set query variable by name to a table value.
 
iter_iterable< Components... > set_var (const char *name, ecs_table_range_t value) const
 Set query variable by name to a table range (C type).
 
iter_iterable< Components... > set_var (const char *name, flecs::table_range value) const
 Set query variable by name to a table range.
 
iter_iterable< Components... > set_group (uint64_t group_id) const
 Limit results to tables with the specified group ID (grouped queries only).
 
iter_iterable< Components... > set_group () const
 Limit results to tables with the specified group type (grouped queries only).
 
virtual ~iterable ()
 Virtual destructor.
 

Additional Inherited Members

- Protected Attributes inherited from flecs::query_base
query_tquery_ = nullptr
 
- Protected Attributes inherited from flecs::iterable< Components... >
friend iter_iterable< Components... >
 
friend page_iterable< Components... >
 
friend worker_iterable< Components... >
 

Detailed Description

template<typename ... Components>
struct flecs::query< Components >

Typed query.

Definition at line 220 of file impl.hpp.

Constructor & Destructor Documentation

◆ query() [1/3]

template<typename ... Components>
flecs::query< Components >::query ( )
inline

Default constructor.

Definition at line 228 of file impl.hpp.

◆ query() [2/3]

template<typename ... Components>
flecs::query< Components >::query ( const query< Components > & obj)
inline

Copy constructor.

Definition at line 231 of file impl.hpp.

◆ query() [3/3]

template<typename ... Components>
flecs::query< Components >::query ( query< Components > && obj)
inlinenoexcept

Move constructor.

Definition at line 240 of file impl.hpp.

Member Function Documentation

◆ cache_query()

template<typename ... Components>
flecs::query flecs::query< Components >::cache_query ( ) const
inline

Get the cache query, if any.

Definition at line 249 of file impl.hpp.

◆ operator=() [1/2]

template<typename ... Components>
query & flecs::query< Components >::operator= ( const query< Components > & obj)
inline

Copy assignment operator.

Definition at line 234 of file impl.hpp.

◆ operator=() [2/2]

template<typename ... Components>
query & flecs::query< Components >::operator= ( query< Components > && obj)
inlinenoexcept

Move assignment operator.

Definition at line 243 of file impl.hpp.

◆ query_base() [1/6]

template<typename ... Components>
flecs::query_base::query_base ( )
inline

Default constructor.

Definition at line 19 of file impl.hpp.

◆ query_base() [2/6]

template<typename ... Components>
flecs::query_base::query_base ( const query_base & obj)
inline

Copy constructor.

Definition at line 49 of file impl.hpp.

◆ query_base() [3/6]

template<typename ... Components>
flecs::query_base::query_base ( const query_t * q)
inline

Construct from a const query pointer.

Definition at line 28 of file impl.hpp.

◆ query_base() [4/6]

template<typename ... Components>
flecs::query_base::query_base ( query_base && obj)
inlinenoexcept

Move constructor.

Definition at line 69 of file impl.hpp.

◆ query_base() [5/6]

template<typename ... Components>
flecs::query_base::query_base ( query_t * q)
inline

Construct from a mutable query pointer.

Definition at line 22 of file impl.hpp.

◆ query_base() [6/6]

template<typename ... Components>
flecs::query_base::query_base ( world_t * world,
const ecs_query_desc_t * desc )
inline

Construct from a world and a query descriptor.

Definition at line 34 of file impl.hpp.


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