Struct observer

Synopsis

#include <include/flecs/addons/cpp/mixins/observer/impl.hpp>

struct observer final : entity

Description

No description yet.

Inheritance

Ancestors: entity

Methods

observer overload
ctx overload
entity overloadCreate entity.
entity overloadWrap an existing entity id.
entity overloadCreate a named entity
entity overloadConversion from flecs::entity_t to flecs::entity.

Source

Lines 8-38 in include/flecs/addons/cpp/mixins/observer/impl.hpp.

struct observer final : entity
{
    using entity::entity;

    explicit observer() : entity() { }

    observer(flecs::world_t *world, ecs_observer_desc_t *desc, bool instanced) 
    {
        if (!desc->filter.instanced) {
            desc->filter.instanced = instanced;
        }

        m_world = world;
        m_id = ecs_observer_init(world, desc);

        if (desc->filter.terms_buffer) {
            ecs_os_free(desc->filter.terms_buffer);
        }
    }

    void ctx(void *ctx) {
        ecs_observer_desc_t desc = {};
        desc.entity = m_id;
        desc.ctx = ctx;
        ecs_observer_init(m_world, &desc);
    }

    void* ctx() const {
        return ecs_get_observer_ctx(m_world, m_id);
    }
};