Function do_import

Synopsis

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

template <typename T>
ecs_entity_t do_import(world &world, const char *symbol)

Description

No description yet.

Source

Lines 20-45 in include/flecs/addons/cpp/module.hpp.

template <typename T>
ecs_entity_t do_import(world& world, const char *symbol) {
    ecs_trace_1("import %s", _::name_helper<T>::name());
    ecs_log_push();

    ecs_entity_t scope = ecs_get_scope(world);
    ecs_set_scope(world, 0);

    // Initialize module component type & don't allow it to be registered as a
    // tag, as this would prevent calling emplace()
    auto m_c = component<T>(world, nullptr, false);
    ecs_add_module_tag(world, m_c);

    world.emplace<T>(world);

    ecs_set_scope(world, scope);

    // // It should now be possible to lookup the module
    ecs_entity_t m = ecs_lookup_symbol(world, symbol, true);
    ecs_assert(m != 0, ECS_MODULE_UNDEFINED, symbol);
    ecs_assert(m == m_c, ECS_INTERNAL_ERROR, NULL);

    ecs_log_pop();     

    return m;
}