Function meta_reset

Summary

#include <src/entt/meta/factory.hpp>

(1) void meta_reset(const id_type id)

(2) template <typename Type>
    void meta_reset()

Function overload

Synopsis

#include <src/entt/meta/factory.hpp>

void meta_reset(const id_type id)

Description

Resets a type and all its parts.

Resets a type and all its data members, member functions and properties, as well as its constructors, destructors and conversion functions if any.
Base classes aren't reset but the link between the two types is removed.

The type is also removed from the list of searchable types.

Parameters

id - Unique identifier.

Source

Lines 555-582 in src/entt/meta/factory.hpp.

inline void meta_reset(const id_type id) ENTT_NOEXCEPT {
    auto clear_chain = [](auto **curr, auto... member) {
        for(; *curr; *curr = std::exchange((*curr)->next, nullptr)) {
            if constexpr(sizeof...(member) != 0u) {
                static_assert(sizeof...(member) == 1u, "Assert in defense of the future me");
                for(auto **it = (&((*curr)->*member), ...); *it; *it = std::exchange((*it)->next, nullptr));
            }
        }
    };

    for(auto** it = internal::meta_context::global(); *it; it = &(*it)->next) {
        if(auto *node = *it; node->id == id) {
            clear_chain(&node->prop);
            clear_chain(&node->base);
            clear_chain(&node->conv);
            clear_chain(&node->ctor, &internal::meta_ctor_node::prop);
            clear_chain(&node->data, &internal::meta_data_node::prop);
            clear_chain(&node->func, &internal::meta_func_node::prop);

            node->id = {};
            node->ctor = node->def_ctor;
            node->dtor = nullptr;
            *it = std::exchange(node->next, nullptr);

            break;
        }
    }
}

Synopsis

#include <src/entt/meta/factory.hpp>

template <typename Type>
void meta_reset()

Description

Resets a type and all its parts.

Resets all searchable types.

See
meta_reset
Template Parameters

Type - Type to reset.

See
meta_reset

Source

Lines 591-594 in src/entt/meta/factory.hpp.

template<typename Type>
void meta_reset() ENTT_NOEXCEPT {
    meta_reset(internal::meta_info<Type>::resolve()->id);
}





Add Discussion

Log in to comment