Function component

Summary

#include <src/entt/entity/snapshot.hpp>

(1) template <typename... Component, typename Archive>
    const basic_snapshot & component(Archive &archive) const

(2) template <typename... Component, typename Archive, typename It>
    const basic_snapshot & component(Archive &archive, It first, It last) const

Function overload

Synopsis

#include <src/entt/entity/snapshot.hpp>

template <typename... Component, typename Archive>
const basic_snapshot & component(Archive &archive) const

Description

Puts aside the given components.

Each instance is serialized together with the entity to which it belongs. Entities are serialized along with their versions.

Template Parameters

Component - Types of components to serialize.

Archive - Type of output archive.

Parameters

archive - A valid reference to an output archive.

Returns
An object of this type to continue creating the snapshot.

Source

Lines 114-124 in src/entt/entity/snapshot.hpp.

template<typename... Component, typename Archive>
const basic_snapshot &component(Archive &archive) const {
    if constexpr(sizeof...(Component) == 1u) {
        const auto view = reg->template view<const Component...>();
        (component<Component>(archive, view.rbegin(), view.rend()), ...);
        return *this;
    } else {
        (component<Component>(archive), ...);
        return *this;
    }
}

Synopsis

#include <src/entt/entity/snapshot.hpp>

template <typename... Component, typename Archive, typename It>
const basic_snapshot & component(Archive &archive, It first, It last) const

Description

Puts aside the given components for the entities in a range.

Each instance is serialized together with the entity to which it belongs. Entities are serialized along with their versions.

Template Parameters

Component - Types of components to serialize.

Archive - Type of output archive.

It - Type of input iterator.

Parameters

archive - A valid reference to an output archive.

first - An iterator to the first element of the range to serialize.

last - An iterator past the last element of the range to serialize.

Returns
An object of this type to continue creating the snapshot.

Source

Lines 140-144 in src/entt/entity/snapshot.hpp.

template<typename... Component, typename Archive, typename It>
const basic_snapshot &component(Archive &archive, It first, It last) const {
    component<Component...>(archive, first, last, std::index_sequence_for<Component...>{});
    return *this;
}





Add Discussion

Log in to comment