20template<
typename Base>
28 this->assert_term_ref();
29 term_ref_->
id |= flecs::Self;
34 Base&
id(flecs::entity_t
id) {
35 this->assert_term_ref();
49 this->assert_term_ref();
50 term_ref_->
id =
entity | flecs::IsEntity;
55 Base& name(
const char *name) {
56 this->assert_term_ref();
57 term_ref_->
id |= flecs::IsEntity;
58 term_ref_->
name =
const_cast<char*
>(name);
63 Base& var(
const char *var_name) {
64 this->assert_term_ref();
65 term_ref_->
id |= flecs::IsVariable;
66 term_ref_->
name =
const_cast<char*
>(var_name);
71 Base& flags(flecs::flags32_t flags) {
72 this->assert_term_ref();
73 term_ref_->
id = flags;
80 virtual flecs::world_t* world_v() = 0;
82 void assert_term_ref() {
83 ecs_assert(term_ref_ != NULL, ECS_INVALID_PARAMETER,
84 "no active term (call .with() first)");
89 return *
static_cast<Base*
>(
this);
98template<
typename Base>
106 Base&
term(id_t
id) {
113 this->term_ref_ = &term_->
src;
122 this->term_ref_ = &term_->
first;
130 this->term_ref_ = &term_->
second;
135 Base& src(flecs::entity_t
id) {
150 Base& src(
const char *name) {
151 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
153 if (name[0] ==
'$') {
162 Base& first(flecs::entity_t
id) {
177 Base& first(
const char *name) {
178 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
180 if (name[0] ==
'$') {
189 Base& second(flecs::entity_t
id) {
204 Base& second(
const char *name) {
205 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
207 if (name[0] ==
'$') {
218 Base& up(flecs::entity_t trav = 0) {
219 this->assert_term_ref();
220 ecs_check(this->term_ref_ != &term_->
first, ECS_INVALID_PARAMETER,
221 "up traversal can only be applied to term source");
223 "up traversal can only be applied to term source");
224 this->term_ref_->
id |= flecs::Up;
232 template <
typename Trav>
239 Base& cascade(flecs::entity_t trav = 0) {
240 this->assert_term_ref();
242 this->term_ref_->
id |= flecs::Cascade;
249 template <
typename Trav>
256 this->assert_term_ref();
257 this->term_ref_->
id |= flecs::Desc;
267 Base& trav(flecs::entity_t trav, flecs::flags32_t flags = 0) {
268 this->assert_term_ref();
270 this->term_ref_->
id |= flags;
300 this->src().entity(0);
328 return this->
inout(flecs::In);
333 return this->
inout(flecs::Out);
338 return this->
inout(flecs::InOut);
343 return this->
inout(flecs::InOutNone);
355 return this->
oper(flecs::And);
360 return this->
oper(flecs::Or);
365 return this->
oper(flecs::Not);
370 return this->
oper(flecs::Optional);
375 return this->
oper(flecs::AndFrom);
380 return this->
oper(flecs::OrFrom);
385 return this->
oper(flecs::NotFrom);
392 "no component specified for singleton");
394 flecs::id_t sid = term_->
id;
399 ecs_assert(sid != 0, ECS_INVALID_PARAMETER, NULL);
401 if (!ECS_IS_PAIR(sid)) {
418 virtual flecs::world_t* world_v()
override = 0;
423 this->term_ref_ = &term_->
src;
425 this->term_ref_ =
nullptr;
431 ecs_assert(term_ != NULL, ECS_INVALID_PARAMETER,
432 "no active term (call .with() first)");
436 return *
static_cast<Base*
>(
this);
#define ecs_assert(condition, error_code,...)
Assert.
#define ecs_check(condition, error_code,...)
Check.
ecs_inout_kind_t
Specify read/write access for term.
ecs_oper_kind_t
Specify operator for term.
@ 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 & singleton()
Match singleton.
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.