21template<
typename Base>
31 this->assert_term_ref();
38 this->assert_term_ref();
52 this->assert_term_ref();
59 this->assert_term_ref();
66 Base&
var(
const char *var_name) {
67 this->assert_term_ref();
75 this->assert_term_ref();
86 void assert_term_ref() {
88 "no active term (call .with() first)");
93 return *
static_cast<Base*
>(
this);
102template<
typename Base>
117 template <
typename T = void,
typename... Args>
118 Base& src(Args... args) {
122 template <
typename T = void,
typename... Args>
123 Base& first(Args... args) {
127 template <
typename T = void,
typename... Args>
128 Base& second(Args... args) {
136 this->assert_term_ref();
138 "up traversal can only be applied to term source");
140 "up traversal can only be applied to term source");
150 template <
typename Trav>
158 this->assert_term_ref();
168 template <
typename Trav>
175 this->assert_term_ref();
187 this->assert_term_ref();
219 this->src().entity(0);
339 Base& set_ref(
const char *
name) {
344 template <
typename T,
typename... Args>
348 if constexpr (std::is_void_v<T>) {
349 return set_ref(args...);
351 return set_ref(_::type<T>::id(this->world_v()));
357 "no active term (call .with() first)");
361 return *
static_cast<Base*
>(
this);
#define ecs_assert(condition, error_code,...)
Assert.
#define ECS_INVALID_PARAMETER
Invalid parameter error code.
#define ecs_check(condition, error_code,...)
Check.
struct ecs_term_t ecs_term_t
A term is a single element in a query.
ecs_flags64_t flags64_t
64-bit flags type.
oper_kind_t
Operator kind.
ecs_entity_t entity_t
Entity type.
ecs_flags32_t flags32_t
32-bit flags type.
ecs_world_t world_t
World type.
@ NotFrom
NotFrom operator.
@ AndFrom
AndFrom operator.
@ Optional
Optional operator.
struct ecs_term_ref_t ecs_term_ref_t
Type that describes a reference to an entity or variable in a term.
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
@ EcsNot
The term must not match.
Compile-time utilities for deriving query attributes from a parameter pack.
Type that describes a reference to an entity or variable in a term.
ecs_entity_t id
Entity ID.
Type that describes a term (single element in a query).
ecs_term_ref_t src
Source of term.
ecs_id_t id
Component ID to be matched by term.
int16_t oper
Operator of term.
ecs_term_ref_t second
Second element of pair.
ecs_entity_t trav
Relationship to traverse when looking for the component.
int16_t inout
Access to contents matched by term.
ecs_term_ref_t first
Component or first element of pair.
Base & filter()
Mark the term as a filter.
Base & inout(flecs::inout_kind_t inout)
Set read/write access of the term.
Base & or_from()
Short for oper(flecs::OrFrom).
void set_term(ecs_term_t *term)
Set the current term pointer.
Base & cascade(flecs::entity_t trav=0)
The cascade flag is like up(), but returns results in breadth-first order.
Base & oper(flecs::oper_kind_t oper)
Set the operator of the term.
Base & read_write()
Short for inout_stage(flecs::InOut).
Base & term(id_t id)
Set the term ID.
Base & parent()
Same as up().
Base & inout()
Short for inout(flecs::InOut).
Base & desc()
Use with cascade() to iterate results in descending (bottom-to-top) order.
Base & in()
Short for inout(flecs::In).
Base & inout_stage(flecs::inout_kind_t inout)
Set read/write access for a stage.
Base & trav(flecs::entity_t trav, flecs::flags32_t flags=0)
Specify the relationship to traverse, and flags to indicate direction.
Base & or_()
Short for oper(flecs::Or).
Base & and_from()
Short for oper(flecs::AndFrom).
Base & out()
Short for inout(flecs::Out).
Base & up()
Traverse upwards using the specified relationship type.
Base & and_()
Short for oper(flecs::And).
ecs_term_t * term_
Pointer to the current term.
Base & optional()
Short for oper(flecs::Optional).
Base & cascade()
Cascade using the specified relationship type.
Base & read()
Short for inout_stage(flecs::In).
term_builder_i(ecs_term_t *term_ptr)
Construct from a term pointer.
Base & up(flecs::entity_t trav=0)
The up flag indicates that the term identifier may be substituted by traversing a relationship upward...
Base & inout_none()
Short for inout(flecs::InOutNone).
term_builder_i()
Default constructor.
Base & id_flags(id_t flags)
Set ID flags for the term.
Base & not_from()
Short for oper(flecs::NotFrom).
Base & not_()
Short for oper(flecs::Not).
Base & write()
Short for inout_stage(flecs::Out).
Base & name(const char *name)
Specify the value of the identifier by name.
Base & id(flecs::entity_t id)
Specify the value of the identifier by ID.
ecs_term_ref_t * term_ref_
Pointer to the current term reference.
virtual ~term_ref_builder_i()
Destructor.
Base & entity(flecs::entity_t entity)
Specify the value of the identifier by ID.
Base & var(const char *var_name)
Specify that the identifier is a variable (resolved at query evaluation time).
Base & self()
The self flag indicates that the term identifier itself is used.
Base & flags(flecs::flags64_t flags)
Override the term ID flags.
term_ref_builder_i()
Default constructor.