Function scope

Summary

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

(1) template <typename Func>
    void scope(id_t parent, const Func &func) const

(2) template <typename T, typename Func>
    void scope(const Func &func) const

(3) flecs::scoped_world scope(id_t parent)

(4) template <typename T>
    flecs::scoped_world scope()

Function overload

Synopsis

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

template <typename Func>
void scope(id_t parent, const Func &func) const

Description

All entities created in function are created in scope. All operations called in function (such as lookup) are relative to scope.

Source

Lines 687-692 in include/flecs/addons/cpp/world.hpp.

template <typename Func>
void scope(id_t parent, const Func& func) const {
    ecs_entity_t prev = ecs_set_scope(m_world, parent);
    func();
    ecs_set_scope(m_world, prev);
}

Synopsis

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

template <typename T, typename Func>
void scope(const Func &func) const

Description

Same as scope(parent, func), but with T as parent.

Source

Lines 696-700 in include/flecs/addons/cpp/world.hpp.

template <typename T, typename Func>
void scope(const Func& func) const {
    flecs::id_t parent = _::cpp_type<T>::id(m_world);
    scope(parent, func);
}

Synopsis

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

flecs::scoped_world scope(id_t parent)

Description

Use provided scope for operations ran on returned world. Operations need to be ran in a single statement.

Source

Lines 170-172 in include/flecs/addons/cpp/impl/world.hpp. Line 705 in include/flecs/addons/cpp/world.hpp.

inline flecs::scoped_world world::scope(id_t parent) {
    return scoped_world(m_world, parent);
}

Synopsis

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

template <typename T>
flecs::scoped_world scope()

Description

No description yet.

Source

Lines 174-178 in include/flecs/addons/cpp/impl/world.hpp. Line 708 in include/flecs/addons/cpp/world.hpp.

template <typename T>
inline flecs::scoped_world world::scope() {
    flecs::id_t parent = _::cpp_type<T>::id(m_world);
    return scoped_world(m_world, parent);
}