Function get

Summary

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

(1) template <typename T>
    const T * get() const

(2) template <typename Func, if_t< is_callable< Func >::value > = 0>
    void get(const Func &func)

Function overload

Synopsis

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

template <typename T>
const T * get() const

Description

Get singleton component.

Mentioned in

Source

Lines 96-100 in include/flecs/addons/cpp/impl/world.hpp. Line 549 in include/flecs/addons/cpp/world.hpp.

template <typename T>
const T* world::get() const {
    flecs::entity e(m_world, _::cpp_type<T>::id(m_world));
    return e.get<T>();
}

Synopsis

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

template <typename Func, if_t< is_callable< Func >::value > = 0>
void get(const Func &func)

Description

Get singleton component inside a callback.

Mentioned in

Source

Lines 125-130 in include/flecs/addons/cpp/impl/world.hpp. Line 554 in include/flecs/addons/cpp/world.hpp.

template <typename Func, if_t< is_callable<Func>::value > >
void world::get(const Func& func) {
    static_assert(arity<Func>::value == 1, "singleton component must be the only argument");
    _::entity_with_invoker<Func>::invoke_get(
        this->m_world, this->singleton<first_arg_t<Func>>(), func);
}