Function add

Summary

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

(1) template <typename T>
    Self & add()

(2) Self & add(id_t component)

(3) Self & add(entity_t first, entity_t second)

(4) template <typename First, typename Second>
    Self & add()

(5) template <typename First, typename Second, if_not_t< is_enum< Second >::value > = 0>
    Self & add(Second second)

(6) template <typename First, typename Second, if_t< is_enum< Second >::value > = 0>
    Self & add(Second constant)

(7) template <typename E, if_t< is_enum< E >::value > = 0>
    Self & add(E value)

Function overload

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename T>
Self & add()

Description

Add a component to an entity. To ensure the component is initialized, it should have a constructor.

Template Parameters

T - the component type to add.

Source

Lines 16-22 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template <typename T>
Self& add() {
    flecs_static_assert(is_flecs_constructible<T>::value,
        "cannot default construct type: add T::T() or use emplace<T>()");
    ecs_add_id(this->m_world, this->m_id, _::cpp_type<T>::id(this->m_world));
    return to_base();
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

Self & add(id_t component)

Description

Add an entity to an entity. Add an entity to the entity. This is typically used for tagging.

Parameters

component - The component to add.

Source

Lines 29-32 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

Self& add(id_t component) {
    ecs_add_id(this->m_world, this->m_id, component);
    return to_base();
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

Self & add(entity_t first, entity_t second)

Description

Add a pair. This operation adds a pair to the entity.

Parameters

first - The first element of the pair.

second - The second element of the pair.

Source

Lines 40-43 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

Self& add(entity_t first, entity_t second) {
    ecs_add_pair(this->m_world, this->m_id, first, second);
    return to_base();
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename First, typename Second>
Self & add()

Description

Add a pair. This operation adds a pair to the entity.

Template Parameters

First - The first element of the pair

Second - The second element of the pair

Source

Lines 51-54 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template<typename First, typename Second>
Self& add() {
    return this->add<First>(_::cpp_type<Second>::id(this->m_world));
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename First, typename Second, if_not_t< is_enum< Second >::value > = 0>
Self & add(Second second)

Description

Add a pair. This operation adds a pair to the entity.

Template Parameters

First - The first element of the pair

Parameters

second - The second element of the pair.

Source

Lines 62-67 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template<typename First, typename Second, if_not_t< is_enum<Second>::value > = 0>
Self& add(Second second) {
    flecs_static_assert(is_flecs_constructible<First>::value,
        "cannot default construct type: add T::T() or use emplace<T>()");
    return this->add(_::cpp_type<First>::id(this->m_world), second);
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename First, typename Second, if_t< is_enum< Second >::value > = 0>
Self & add(Second constant)

Description

Add a pair. This operation adds a pair to the entity that consists out of a tag combined with an enum constant.

Template Parameters

First - The first element of the pair

Parameters

constant - the enum constant.

Source

Lines 76-82 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template<typename First, typename Second, if_t< is_enum<Second>::value > = 0>
Self& add(Second constant) {
    flecs_static_assert(is_flecs_constructible<First>::value,
        "cannot default construct type: add T::T() or use emplace<T>()");
    const auto& et = enum_type<Second>(this->m_world);
    return this->add<First>(et.entity(constant));
}

Synopsis

#include <include/flecs/addons/cpp/mixins/entity/builder.hpp>

template <typename E, if_t< is_enum< E >::value > = 0>
Self & add(E value)

Description

Add pair for enum constant. This operation will add a pair to the entity where the first element is the enumeration type, and the second element the enumeration constant.

The operation may be used with regular (C style) enumerations as well as enum classes.

Parameters

value - The enumeration value.

Source

Lines 449-455 in include/flecs/addons/cpp/mixins/entity/builder.hpp.

template <typename E, if_t< is_enum<E>::value > = 0>
Self& add(E value) {
    flecs::entity_t first = _::cpp_type<E>::id(this->m_world);
    const auto& et = enum_type<E>(this->m_world);
    flecs::entity_t second = et.entity(value);
    return this->add(first, second);
}