OpenLexocad  27.1
entt::basic_continuous_loader< Entity > Class Template Reference

Utility class for continuous loading. More...

#include <entt.hpp>

Public Types

using entity_type = Entity
 Underlying entity identifier. More...
 

Public Member Functions

 basic_continuous_loader (basic_registry< entity_type > &source) ENTT_NOEXCEPT
 Constructs a loader that is bound to a given registry. More...
 
 basic_continuous_loader (basic_continuous_loader &&)=default
 Default move constructor. More...
 
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 Archive >
basic_continuous_loaderdestroyed (Archive &archive)
 Restores entities that were destroyed 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 has (entity_type entt) const ENTT_NOEXCEPT
 Tests if a loader knows about a given entity. More...
 
entity_type map (entity_type entt) const ENTT_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 accomodate 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).

Member Typedef Documentation

◆ entity_type

template<typename Entity >
using entt::basic_continuous_loader< Entity >::entity_type = Entity

Underlying entity identifier.

Constructor & Destructor Documentation

◆ basic_continuous_loader() [1/2]

template<typename Entity >
entt::basic_continuous_loader< Entity >::basic_continuous_loader ( basic_registry< entity_type > &  source)
inline

Constructs a loader that is bound to a given registry.

Parameters
sourceA valid reference to a registry.

◆ basic_continuous_loader() [2/2]

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

Default move constructor.

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.

◆ destroyed()

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

Restores entities that were destroyed during serialization.

This function restores the entities that were destroyed 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.

◆ 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.

◆ has()

template<typename Entity >
bool entt::basic_continuous_loader< Entity >::has ( entity_type  entt) const
inline

Tests if a loader knows about a given entity.

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

◆ map()

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

Returns the identifier to which an entity refers.

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

◆ 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.

◆ 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.

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