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

Utility class for continuous loading. More...

#include <snapshot.hpp>

Public Types

using entity_type = Entity
 Underlying entity identifier.
 

Public Member Functions

 basic_continuous_loader (basic_registry< entity_type > &source) noexcept
 Constructs an instance that is bound to a given registry. More...
 
 basic_continuous_loader (basic_continuous_loader &&)=default
 Default move constructor.
 
basic_continuous_loaderoperator= (basic_continuous_loader &&)=default
 Default move assignment operator. More...
 
template<typename Archive >
basic_continuous_loaderentities (Archive &archive)
 Restores entities that were in use during serialization. More...
 
template<typename... Component, typename Archive , typename... Type, typename... Member>
basic_continuous_loadercomponent (Archive &archive, Member Type::*... member)
 Restores components and assigns them to the right entities. More...
 
basic_continuous_loadershrink ()
 Helps to purge entities that no longer have a conterpart. More...
 
basic_continuous_loaderorphans ()
 Destroys those entities that have no components. More...
 
bool contains (entity_type entt) const noexcept
 Tests if a loader knows about a given entity. More...
 
entity_type map (entity_type entt) const noexcept
 Returns the identifier to which an entity refers. More...
 

Detailed Description

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

Utility class for continuous loading.

A continuous loader is designed to load data from a source registry to a (possibly) non-empty destination. The loader can accommodate in a registry more than one snapshot in a sort of continuous loading that updates the destination one step at a time.
Identifiers that entities originally had are not transferred to the target. Instead, the loader maps remote identifiers to local ones while restoring a snapshot.
An example of use is the implementation of a client-server applications with the requirement of transferring somehow parts of the representation side to side.

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

Definition at line 298 of file snapshot.hpp.

Constructor & Destructor Documentation

◆ basic_continuous_loader()

template<typename Entity >
entt::basic_continuous_loader< Entity >::basic_continuous_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 415 of file snapshot.hpp.

Member Function Documentation

◆ component()

template<typename Entity >
template<typename... Component, typename Archive , typename... Type, typename... Member>
basic_continuous_loader& entt::basic_continuous_loader< Entity >::component ( Archive &  archive,
Member Type::*...  member 
)
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 a local counterpart for it.
Members can be either data members of type entity_type or containers of entities. In both cases, the loader will visit them and update the entities by replacing each one with its local counterpart.

Template Parameters
ComponentType of component to restore.
ArchiveType of input archive.
TypeTypes of components to update with local counterparts.
MemberTypes of members to update with their local counterparts.
Parameters
archiveA valid reference to an input archive.
memberMembers to update with their local counterparts.
Returns
A non-const reference to this loader.

Definition at line 478 of file snapshot.hpp.

◆ contains()

template<typename Entity >
bool entt::basic_continuous_loader< Entity >::contains ( entity_type  entt) const
inlinenoexcept

Tests if a loader knows about a given entity.

Parameters
enttAn entity identifier.
Returns
True if entity is managed by the loader, false otherwise.

Definition at line 537 of file snapshot.hpp.

◆ entities()

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

Restores entities that were in use during serialization.

This function restores the entities that were in use during serialization and creates local counterparts for them if required.

Template Parameters
ArchiveType of input archive.
Parameters
archiveA valid reference to an input archive.
Returns
A non-const reference to this loader.

Definition at line 436 of file snapshot.hpp.

◆ map()

template<typename Entity >
entity_type entt::basic_continuous_loader< Entity >::map ( entity_type  entt) const
inlinenoexcept

Returns the identifier to which an entity refers.

Parameters
enttAn entity identifier.
Returns
The local identifier if any, the null entity otherwise.

Definition at line 546 of file snapshot.hpp.

◆ operator=()

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

Default move assignment operator.

Returns
This loader.

◆ orphans()

template<typename Entity >
basic_continuous_loader& entt::basic_continuous_loader< Entity >::orphans ( )
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 non-const reference to this loader.

Definition at line 524 of file snapshot.hpp.

◆ shrink()

template<typename Entity >
basic_continuous_loader& entt::basic_continuous_loader< Entity >::shrink ( )
inline

Helps to purge entities that no longer have a conterpart.

Users should invoke this member function after restoring each snapshot, unless they know exactly what they are doing.

Returns
A non-const reference to this loader.

Definition at line 492 of file snapshot.hpp.


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