Class term

Synopsis

#include <include/flecs/addons/cpp/builder.hpp>

class term final : public term_builder_i<term>

Description

No description yet.

Inheritance

Ancestors: term_builder_i

Methods

term overload
~term
finalize
is_set
is_trivial
move
operator= overload
reset
world

Source

Lines 314-408 in include/flecs/addons/cpp/builder.hpp.

class term final : public term_builder_i<term> {
public:
    term(flecs::world_t *world_ptr) 
        : term_builder_i<term>(&value)
        , value({})
        , m_world(world_ptr) { value.move = true; }

    term(flecs::world_t *world_ptr, id_t id) 
        : term_builder_i<term>(&value)
        , value({})
        , m_world(world_ptr) { 
            value.move = true; 
            this->id(id);
        }

    term(flecs::world_t *world_ptr, ecs_term_t t)
        : term_builder_i<term>(&value)
        , value({})
        , m_world(world_ptr) {
            value = t;
            value.move = false;
            this->set_term(&value);
        }        

    term(flecs::world_t *world_ptr, id_t r, id_t o) 
        : term_builder_i<term>(&value)
        , value({})
        , m_world(world_ptr) { 
            value.move = true; 
            this->id(r, o);
        }

    term(const term& obj) : term_builder_i<term>(&value) {
        m_world = obj.m_world;
        value = ecs_term_copy(&obj.value);
        this->set_term(&value);
    }

    term(term&& obj) : term_builder_i<term>(&value) {
        m_world = obj.m_world;
        value = ecs_term_move(&obj.value);
        obj.reset();
        this->set_term(&value);
    }

    term& operator=(const term& obj) {
        ecs_assert(m_world == obj.m_world, ECS_INVALID_PARAMETER, NULL);
        ecs_term_fini(&value);
        value = ecs_term_copy(&obj.value);
        this->set_term(&value);
        return *this;
    }

    term& operator=(term&& obj) {
        ecs_assert(m_world == obj.m_world, ECS_INVALID_PARAMETER, NULL);
        ecs_term_fini(&value);
        value = obj.value;
        this->set_term(&value);
        obj.reset();
        return *this;
    }   

    ~term() {
        ecs_term_fini(&value);
    }

    void reset() {
        value = {};
        this->set_term(nullptr);
    }

    int finalize() {
        return ecs_term_finalize(m_world, nullptr, &value);
    }

    bool is_set() {
        return ecs_term_is_initialized(&value);
    }

    bool is_trivial() {
        return ecs_term_is_trivial(&value);
    }

    ecs_term_t move() { /* explicit move to ecs_term_t */
        return ecs_term_move(&value);
    }

    ecs_term_t value;

protected:
    flecs::world_t* world() override { return m_world; }

private:
    flecs::world_t *m_world;
};