Function use

Summary

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

(1) template <typename T>
    flecs::entity use(const char *alias=nullptr)

(2) flecs::entity use(const char *name, const char *alias=nullptr)

(3) void use(flecs::entity entity, const char *alias=nullptr)

Function overload

Synopsis

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

template <typename T>
flecs::entity use(const char *alias=nullptr)

Description

Create alias for component.

Template Parameters

T - to create an alias for.

Parameters

alias - Alias for the component.

Returns
Entity representing the component.

Source

Lines 36-46 in include/flecs/addons/cpp/impl/world.hpp. Line 583 in include/flecs/addons/cpp/world.hpp.

template <typename T>
inline flecs::entity world::use(const char *alias) {
    entity_t e = _::cpp_type<T>::id(m_world);
    const char *name = alias;
    if (!name) {
        // If no name is defined, use the entity name without the scope
        name = ecs_get_name(m_world, e);
    }
    ecs_set_alias(m_world, e, name);
    return flecs::entity(m_world, e);
}

Synopsis

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

flecs::entity use(const char *name, const char *alias=nullptr)

Description

Create alias for entity.

Parameters

name - Name of the entity.

alias - Alias for the entity.

Source

Lines 48-54 in include/flecs/addons/cpp/impl/world.hpp. Line 590 in include/flecs/addons/cpp/world.hpp.

inline flecs::entity world::use(const char *name, const char *alias) {
    entity_t e = ecs_lookup_path_w_sep(m_world, 0, name, "::", "::", true);
    ecs_assert(e != 0, ECS_INVALID_PARAMETER, NULL);

    ecs_set_alias(m_world, e, alias);
    return flecs::entity(m_world, e);
}

Synopsis

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

void use(flecs::entity entity, const char *alias=nullptr)

Description

Create alias for entity.

Parameters

entity - Entity for which to create the alias.

alias - Alias for the entity.

Source

Lines 56-64 in include/flecs/addons/cpp/impl/world.hpp. Line 597 in include/flecs/addons/cpp/world.hpp.

inline void world::use(flecs::entity e, const char *alias) {
    entity_t eid = e.id();
    const char *name = alias;
    if (!name) {
        // If no name is defined, use the entity name without the scope
        ecs_get_name(m_world, eid);
    }
    ecs_set_alias(m_world, eid, alias);
}