20template<
typename Base>
28 this->assert_term_id();
29 m_term_id->
flags |= flecs::Self;
36 Base& up(flecs::entity_t trav = 0) {
37 this->assert_term_id();
38 m_term_id->
flags |= flecs::Up;
40 m_term_id->
trav = trav;
45 template <
typename Trav>
52 Base& cascade(flecs::entity_t trav = 0) {
53 this->assert_term_id();
54 m_term_id->
flags |= flecs::Cascade;
56 m_term_id->
trav = trav;
61 template <
typename Trav>
68 this->assert_term_id();
69 m_term_id->
flags |= flecs::Desc;
75 this->assert_term_id();
76 m_term_id->
flags |= flecs::Parent;
81 Base& trav(flecs::entity_t trav, flecs::flags32_t flags = 0) {
82 this->assert_term_id();
83 m_term_id->
trav = trav;
84 m_term_id->
flags |= flags;
89 Base&
id(flecs::entity_t
id) {
90 this->assert_term_id();
104 this->assert_term_id();
105 m_term_id->
flags = flecs::IsEntity;
111 Base& name(
const char *name) {
112 this->assert_term_id();
113 m_term_id->
flags |= flecs::IsEntity;
114 m_term_id->
name =
const_cast<char*
>(name);
119 Base& var(
const char *var_name) {
120 this->assert_term_id();
121 m_term_id->
flags |= flecs::IsVariable;
122 m_term_id->
name =
const_cast<char*
>(var_name);
127 Base& flags(flecs::flags32_t flags) {
128 this->assert_term_id();
129 m_term_id->
flags = flags;
136 virtual flecs::world_t* world_v() = 0;
139 void assert_term_id() {
140 ecs_assert(m_term_id != NULL, ECS_INVALID_PARAMETER,
141 "no active term (call .term() first)");
145 return *
static_cast<Base*
>(
this);
154template<
typename Base>
162 Base&
term(id_t
id) {
169 this->m_term_id = &m_term->
src;
178 this->m_term_id = &m_term->
first;
186 this->m_term_id = &m_term->
second;
191 Base& src(flecs::entity_t
id) {
206 Base& src(
const char *name) {
207 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
209 if (name[0] ==
'$') {
218 Base& first(flecs::entity_t
id) {
233 Base& first(
const char *name) {
234 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
236 if (name[0] ==
'$') {
245 Base& second(flecs::entity_t
id) {
260 Base& second(
const char *name) {
261 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
263 if (name[0] ==
'$') {
297 this->src().entity(0);
325 return this->
inout(flecs::In);
330 return this->
inout(flecs::Out);
335 return this->
inout(flecs::InOut);
340 return this->
inout(flecs::InOutNone);
352 return this->
oper(flecs::And);
357 return this->
oper(flecs::Or);
362 return this->
oper(flecs::Not);
367 return this->
oper(flecs::Optional);
372 return this->
oper(flecs::AndFrom);
377 return this->
oper(flecs::OrFrom);
382 return this->
oper(flecs::NotFrom);
389 "no component specified for singleton");
391 flecs::id_t sid = m_term->
id;
396 ecs_assert(sid != 0, ECS_INVALID_PARAMETER, NULL);
398 if (!ECS_IS_PAIR(sid)) {
399 m_term->
src.
id = sid;
401 m_term->
src.
id = ecs_pair_first(
world(), sid);
415 virtual flecs::world_t* world_v() = 0;
420 this->m_term_id = &m_term->
src;
422 this->m_term_id =
nullptr;
428 ecs_assert(m_term != NULL, ECS_INVALID_PARAMETER,
429 "no active term (call .term() first)");
433 return *
static_cast<Base*
>(
this);
#define ecs_assert(condition, error_code,...)
Assert.
ecs_inout_kind_t
Specify read/write access for term.
ecs_oper_kind_t
Specify operator for term.
@ EcsNot
The term must not match.
Compile time utilities for deriving query attributes from param pack.
Type that describes a single identifier in a term.
ecs_flags32_t flags
Term flags.
ecs_entity_t trav
Relationship to traverse when looking for the component.
ecs_entity_t id
Entity id.
Type that describes a term (single element in a query)
ecs_term_id_t second
Second element of pair.
ecs_id_t id
Component id to be matched by term.
ecs_term_id_t src
Source of term.
ecs_term_id_t first
Component or first element of pair.
ecs_id_t id_flags
Id flags of term id.
ecs_inout_kind_t inout
Access to contents matched by term.
ecs_oper_kind_t oper
Operator of term.
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 & write()
Short for inout_stage(flecs::Out).
Base & role(id_t role)
Set role of term.
Class that describes a term.