8#include "../../utils/signature.hpp"
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::Parent;
74 Base& trav(flecs::entity_t trav, flecs::flags32_t flags = 0) {
75 this->assert_term_id();
76 m_term_id->
trav = trav;
77 m_term_id->
flags |= flags;
82 Base&
id(flecs::entity_t
id) {
83 this->assert_term_id();
97 this->assert_term_id();
98 m_term_id->
flags = flecs::IsEntity;
104 Base& name(
const char *name) {
105 this->assert_term_id();
106 m_term_id->
flags |= flecs::IsEntity;
107 m_term_id->
name =
const_cast<char*
>(name);
112 Base& var(
const char *var_name) {
113 this->assert_term_id();
114 m_term_id->
flags |= flecs::IsVariable;
115 m_term_id->
name =
const_cast<char*
>(var_name);
120 Base& flags(flecs::flags32_t flags) {
121 this->assert_term_id();
122 m_term_id->
flags = flags;
129 virtual flecs::world_t* world_v() = 0;
132 void assert_term_id() {
133 ecs_assert(m_term_id != NULL, ECS_INVALID_PARAMETER,
134 "no active term (call .term() first)");
138 return *
static_cast<Base*
>(
this);
147template<
typename Base>
155 Base&
term(id_t
id) {
162 this->m_term_id = &m_term->
src;
171 this->m_term_id = &m_term->
first;
179 this->m_term_id = &m_term->
second;
184 Base& src(flecs::entity_t
id) {
199 Base& src(
const char *name) {
200 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
202 if (name[0] ==
'$') {
211 Base& first(flecs::entity_t
id) {
226 Base& first(
const char *name) {
227 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
229 if (name[0] ==
'$') {
238 Base& second(flecs::entity_t
id) {
253 Base& second(
const char *name) {
254 ecs_assert(name != NULL, ECS_INVALID_PARAMETER, NULL);
256 if (name[0] ==
'$') {
290 this->src().entity(0);
318 return this->
inout(flecs::In);
323 return this->
inout(flecs::Out);
328 return this->
inout(flecs::InOut);
333 return this->
inout(flecs::InOutNone);
345 return this->
oper(flecs::And);
350 return this->
oper(flecs::Or);
355 return this->
oper(flecs::Not);
360 return this->
oper(flecs::Optional);
365 return this->
oper(flecs::AndFrom);
370 return this->
oper(flecs::OrFrom);
375 return this->
oper(flecs::NotFrom);
382 "no component specified for singleton");
384 flecs::id_t sid = m_term->
id;
389 ecs_assert(sid != 0, ECS_INVALID_PARAMETER, NULL);
391 if (!ECS_IS_PAIR(sid)) {
392 m_term->
src.
id = sid;
394 m_term->
src.
id = ecs_pair_first(
world(), sid);
408 virtual flecs::world_t* world_v() = 0;
413 this->m_term_id = &m_term->
src;
415 this->m_term_id =
nullptr;
421 ecs_assert(m_term != NULL, ECS_INVALID_PARAMETER,
422 "no active term (call .term() first)");
426 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.
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.
flecs::term term() const
Create a term for a (component) type.