21template<
typename Base>
29 this->assert_term_ref();
30 term_ref_->
id |= flecs::Self;
35 Base&
id(flecs::entity_t
id) {
36 this->assert_term_ref();
50 this->assert_term_ref();
51 term_ref_->
id =
entity | flecs::IsEntity;
56 Base& name(
const char *name) {
57 this->assert_term_ref();
58 term_ref_->
id |= flecs::IsEntity;
59 term_ref_->
name =
const_cast<char*
>(name);
64 Base& var(
const char *var_name) {
65 this->assert_term_ref();
66 term_ref_->
id |= flecs::IsVariable;
67 term_ref_->
name =
const_cast<char*
>(var_name);
72 Base& flags(flecs::flags64_t flags) {
73 this->assert_term_ref();
74 term_ref_->
id = flags;
81 virtual flecs::world_t* world_v() = 0;
83 void assert_term_ref() {
84 ecs_assert(term_ref_ != NULL, ECS_INVALID_PARAMETER,
85 "no active term (call .with() first)");
90 return *
static_cast<Base*
>(
this);
99template<
typename Base>
107 Base&
term(id_t
id) {
114 this->term_ref_ = &term_->
src;
123 this->term_ref_ = &term_->
first;
131 this->term_ref_ = &term_->
second;
136 Base& src(flecs::entity_t
id) {
151 Base& src(
const char *name) {
152 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
154 if (name[0] ==
'$') {
163 Base& first(flecs::entity_t
id) {
178 Base& first(
const char *name) {
179 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
181 if (name[0] ==
'$') {
190 Base& second(flecs::entity_t
id) {
205 Base& second(
const char *name) {
206 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
208 if (name[0] ==
'$') {
219 Base& up(flecs::entity_t trav = 0) {
220 this->assert_term_ref();
221 ecs_check(this->term_ref_ != &term_->
first, ECS_INVALID_PARAMETER,
222 "up traversal can only be applied to term source");
224 "up traversal can only be applied to term source");
225 this->term_ref_->
id |= flecs::Up;
233 template <
typename Trav>
240 Base& cascade(flecs::entity_t trav = 0) {
241 this->assert_term_ref();
243 this->term_ref_->
id |= flecs::Cascade;
250 template <
typename Trav>
257 this->assert_term_ref();
258 this->term_ref_->
id |= flecs::Desc;
268 Base& trav(flecs::entity_t trav, flecs::flags32_t flags = 0) {
269 this->assert_term_ref();
271 this->term_ref_->
id |= flags;
301 this->src().entity(0);
329 return this->
inout(flecs::In);
334 return this->
inout(flecs::Out);
339 return this->
inout(flecs::InOut);
344 return this->
inout(flecs::InOutNone);
350 term_->
oper =
static_cast<int16_t
>(
oper);
356 return this->
oper(flecs::And);
361 return this->
oper(flecs::Or);
366 return this->
oper(flecs::Not);
371 return this->
oper(flecs::Optional);
376 return this->
oper(flecs::AndFrom);
381 return this->
oper(flecs::OrFrom);
386 return this->
oper(flecs::NotFrom);
398 virtual flecs::world_t* world_v()
override = 0;
403 this->term_ref_ = &term_->
src;
405 this->term_ref_ =
nullptr;
411 ecs_assert(term_ != NULL, ECS_INVALID_PARAMETER,
412 "no active term (call .with() first)");
416 return *
static_cast<Base*
>(
this);
#define ecs_assert(condition, error_code,...)
Assert.
#define ecs_check(condition, error_code,...)
Check.
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
@ EcsNot
The term must not match.
Compile time utilities for deriving query attributes from param 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.
Class that wraps around a flecs::id_t.
Base & inout(flecs::inout_kind_t inout)
Set read/write access of term.
Base & oper(flecs::oper_kind_t oper)
Set operator of term.
Base & read_write()
Short for inout_stage(flecs::InOut).
Base & inout()
Short for inout(flecs::InOut)
Base & in()
Short for inout(flecs::In)
Base & inout_stage(flecs::inout_kind_t inout)
Set read/write access for stage.
Base & out()
Short for inout(flecs::Out)
Base & read()
Short for inout_stage(flecs::In).
Base & inout_none()
Short for inout(flecs::In)
Base & id_flags(id_t flags)
Set id flags for term.
Base & write()
Short for inout_stage(flecs::Out).
Class that describes a term.