22struct term_ref_builder_i {
23 term_ref_builder_i() : term_ref_(
nullptr) { }
25 virtual ~term_ref_builder_i() { }
29 this->assert_term_ref();
30 term_ref_->id |= flecs::Self;
35 Base& id(flecs::entity_t
id) {
36 this->assert_term_ref();
49 Base& entity(flecs::entity_t entity) {
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);
100struct term_builder_i : term_ref_builder_i<Base> {
101 term_builder_i() : term_(
nullptr) { }
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");
223 ecs_check(this->term_ref_ != &term_->second, ECS_INVALID_PARAMETER,
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;
285 term_->inout =
static_cast<int16_t
>(
inout);
299 term_->inout =
static_cast<int16_t
>(
inout);
300 if (term_->oper !=
EcsNot) {
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);