Function init

Synopsis

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

static void init(world_t *world, entity_t entity, bool allow_tag=true)

Description

No description yet.

Source

Lines 113-148 in include/flecs/addons/cpp/component.hpp.

static void init(
    world_t* world, 
    entity_t entity, 
    bool allow_tag = true) 
{
    if (s_reset_count != ecs_cpp_reset_count_get()) {
        reset();
    }
    // If an identifier was already set, check for consistency
    if (s_id) {
        ecs_assert(s_name.c_str() != nullptr, ECS_INTERNAL_ERROR, NULL);
        ecs_assert(s_id == entity, ECS_INCONSISTENT_COMPONENT_ID, 
            type_name<T>());
        ecs_assert(allow_tag == s_allow_tag, ECS_INVALID_PARAMETER, NULL);
        // Component was already registered and data is consistent with new
        // identifier, so nothing else to be done.
        return;
    }
    // Component wasn't registered yet, set the values. Register component
    // name as the fully qualified flecs path.
    char *path = ecs_get_fullpath(world, entity);
    s_id = entity;
    s_name = flecs::string(path);
    s_allow_tag = allow_tag;
    s_size = sizeof(T);
    s_alignment = alignof(T);
    if (is_empty<T>::value && allow_tag) {
        s_size = 0;
        s_alignment = 0;
    }
    s_reset_count = ecs_cpp_reset_count_get();
}