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

Base class for queries. More...

#include <impl.hpp>

Inheritance diagram for flecs::query_base:
[legend]

Public Member Functions

 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.
 

Protected Attributes

query_tquery_ = nullptr
 

Detailed Description

Base class for queries.

Definition at line 17 of file impl.hpp.

Constructor & Destructor Documentation

◆ query_base() [1/6]

flecs::query_base::query_base ( )
inline

Default constructor.

Definition at line 19 of file impl.hpp.

◆ query_base() [2/6]

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() [3/6]

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]

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.

◆ query_base() [5/6]

flecs::query_base::query_base ( const query_base & obj)
inline

Copy constructor.

Definition at line 49 of file impl.hpp.

◆ query_base() [6/6]

flecs::query_base::query_base ( query_base && obj)
inlinenoexcept

Move constructor.

Definition at line 69 of file impl.hpp.

◆ ~query_base()

flecs::query_base::~query_base ( )
inline

Destructor.

Only frees the query if it is not associated with an entity.

Definition at line 114 of file impl.hpp.

Member Function Documentation

◆ c_ptr()

const flecs::query_t * flecs::query_base::c_ptr ( ) const
inline

Get a pointer to the underlying C query.

Definition at line 87 of file impl.hpp.

◆ changed()

bool flecs::query_base::changed ( ) const
inline

Return whether the query data changed since the last iteration.

This operation must be invoked before obtaining the iterator, as this will reset the changed state. The operation will return true after:

  • new entities have been matched with
  • matched entities were deleted
  • matched components were changed
Returns
true if entities changed, otherwise false.

Definition at line 132 of file impl.hpp.

◆ destruct()

void flecs::query_base::destruct ( )
inline

Free a persistent query.

A persistent query is a query that is associated with an entity, such as system queries and named queries. Persistent queries must be deleted with destruct(), or will be deleted automatically at world cleanup.

Definition at line 106 of file impl.hpp.

◆ each_term()

template<typename Func >
void flecs::query_base::each_term ( const Func & func)
inline

Iterate each term in the query, invoking a callback for each.

Definition at line 161 of file impl.hpp.

◆ entity()

flecs::entity flecs::query_base::entity ( ) const
inline

Get the entity associated with the query.

Definition at line 82 of file impl.hpp.

◆ field_count()

int32_t flecs::query_base::field_count ( ) const
inline

Get the number of fields in the query.

Definition at line 180 of file impl.hpp.

◆ find_var()

int32_t flecs::query_base::find_var ( const char * name) const
inline

Find a variable by name.

Definition at line 185 of file impl.hpp.

◆ group_ctx()

void * flecs::query_base::group_ctx ( uint64_t group_id) const
inline

Get context for a group.

Parameters
group_idThe group ID for which to retrieve the context.
Returns
The group context.

Definition at line 150 of file impl.hpp.

◆ group_info()

const flecs::query_group_info_t * flecs::query_base::group_info ( uint64_t group_id) const
inline

Get info for a group.

Parameters
group_idThe group ID for which to retrieve the info.
Returns
The group info.

Definition at line 141 of file impl.hpp.

◆ operator bool()

flecs::query_base::operator bool ( ) const
inline

Check if the query is valid.

Definition at line 97 of file impl.hpp.

◆ operator const flecs::query_t *()

flecs::query_base::operator const flecs::query_t * ( ) const
inline

Convert to a const query pointer.

Definition at line 92 of file impl.hpp.

◆ operator=() [1/2]

query_base & flecs::query_base::operator= ( const query_base & obj)
inline

Copy assignment operator.

Definition at line 58 of file impl.hpp.

◆ operator=() [2/2]

query_base & flecs::query_base::operator= ( query_base && obj)
inlinenoexcept

Move assignment operator.

Definition at line 75 of file impl.hpp.

◆ plan()

flecs::string flecs::query_base::plan ( ) const
inline

Return a string representing the query plan.

This can be used to analyze the behavior and performance of the query.

See also
ecs_query_plan()

Definition at line 199 of file impl.hpp.

◆ str()

flecs::string flecs::query_base::str ( ) const
inline

Convert the query to a string expression.

Definition at line 190 of file impl.hpp.

◆ term()

flecs::term flecs::query_base::term ( int32_t index) const
inline

Get term at the specified index.

Definition at line 170 of file impl.hpp.

◆ term_count()

int32_t flecs::query_base::term_count ( ) const
inline

Get the number of terms in the query.

Definition at line 175 of file impl.hpp.

Member Data Documentation

◆ query_

query_t* flecs::query_base::query_ = nullptr
protected

Definition at line 212 of file impl.hpp.


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