EnTT  3.6.0
Public Types | Public Member Functions | List of all members
entt::basic_snapshot_loader< Entity > Class Template Reference

Utility class to restore a snapshot as a whole. More...

#include <snapshot.hpp>

Public Types

using entity_type = Entity
 Underlying entity identifier.
 

Public Member Functions

 basic_snapshot_loader (basic_registry< entity_type > &source) noexcept
 Constructs an instance that is bound to a given registry. More...
 
 basic_snapshot_loader (basic_snapshot_loader &&)=default
 Default move constructor.
 
basic_snapshot_loaderoperator= (basic_snapshot_loader &&)=default
 Default move assignment operator. More...
 
template<typename Archive >
const basic_snapshot_loaderentities (Archive &archive) const
 Restores entities that were in use during serialization. More...
 
template<typename... Component, typename Archive >
const basic_snapshot_loadercomponent (Archive &archive) const
 Restores components and assigns them to the right entities. More...
 
const basic_snapshot_loaderorphans () const
 Destroys those entities that have no components. More...
 

Detailed Description

template<typename Entity>
class entt::basic_snapshot_loader< Entity >

Utility class to restore a snapshot as a whole.

A snapshot loader requires that the destination registry be empty and loads all the data at once while keeping intact the identifiers that the entities originally had.
An example of use is the implementation of a save/restore utility.

Template Parameters
EntityA valid entity type (see entt_traits for more details).

Definition at line 160 of file snapshot.hpp.

Constructor & Destructor Documentation

◆ basic_snapshot_loader()

template<typename Entity >
entt::basic_snapshot_loader< Entity >::basic_snapshot_loader ( basic_registry< entity_type > &  source)
inlinenoexcept

Constructs an instance that is bound to a given registry.

Parameters
sourceA valid reference to a registry.

Definition at line 197 of file snapshot.hpp.

Member Function Documentation

◆ component()

template<typename Entity >
template<typename... Component, typename Archive >
const basic_snapshot_loader& entt::basic_snapshot_loader< Entity >::component ( Archive &  archive) const
inline

Restores components and assigns them to the right entities.

The template parameter list must be exactly the same used during serialization. In the event that the entity to which the component is assigned doesn't exist yet, the loader will take care to create it with the version it originally had.

Template Parameters
ComponentTypes of components to restore.
ArchiveType of input archive.
Parameters
archiveA valid reference to an input archive.
Returns
A valid loader to continue restoring data.

Definition at line 253 of file snapshot.hpp.

◆ entities()

template<typename Entity >
template<typename Archive >
const basic_snapshot_loader& entt::basic_snapshot_loader< Entity >::entities ( Archive &  archive) const
inline

Restores entities that were in use during serialization.

This function restores the entities that were in use during serialization and gives them the versions they originally had.

Template Parameters
ArchiveType of input archive.
Parameters
archiveA valid reference to an input archive.
Returns
A valid loader to continue restoring data.

Definition at line 221 of file snapshot.hpp.

◆ operator=()

template<typename Entity >
basic_snapshot_loader& entt::basic_snapshot_loader< Entity >::operator= ( basic_snapshot_loader< Entity > &&  )
default

Default move assignment operator.

Returns
This loader.

◆ orphans()

template<typename Entity >
const basic_snapshot_loader& entt::basic_snapshot_loader< Entity >::orphans ( ) const
inline

Destroys those entities that have no components.

In case all the entities were serialized but only part of the components was saved, it could happen that some of the entities have no components once restored.
This functions helps to identify and destroy those entities.

Returns
A valid loader to continue restoring data.

Definition at line 268 of file snapshot.hpp.


The documentation for this class was generated from the following files: