EnTT
3.6.0
|
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_loader & | operator= (basic_continuous_loader &&)=default |
Default move assignment operator. More... | |
template<typename Archive > | |
basic_continuous_loader & | entities (Archive &archive) |
Restores entities that were in use during serialization. More... | |
template<typename... Component, typename Archive , typename... Type, typename... Member> | |
basic_continuous_loader & | component (Archive &archive, Member Type::*... member) |
Restores components and assigns them to the right entities. More... | |
basic_continuous_loader & | shrink () |
Helps to purge entities that no longer have a conterpart. More... | |
basic_continuous_loader & | orphans () |
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... | |
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.
Entity | A valid entity type (see entt_traits for more details). |
Definition at line 298 of file snapshot.hpp.
|
inlinenoexcept |
Constructs an instance that is bound to a given registry.
source | A valid reference to a registry. |
Definition at line 415 of file snapshot.hpp.
|
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.
Component | Type of component to restore. |
Archive | Type of input archive. |
Type | Types of components to update with local counterparts. |
Member | Types of members to update with their local counterparts. |
archive | A valid reference to an input archive. |
member | Members to update with their local counterparts. |
Definition at line 478 of file snapshot.hpp.
|
inlinenoexcept |
Tests if a loader knows about a given entity.
entt | An entity identifier. |
entity
is managed by the loader, false otherwise. Definition at line 537 of file snapshot.hpp.
|
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.
Archive | Type of input archive. |
archive | A valid reference to an input archive. |
Definition at line 436 of file snapshot.hpp.
|
inlinenoexcept |
Returns the identifier to which an entity refers.
entt | An entity identifier. |
Definition at line 546 of file snapshot.hpp.
|
default |
Default move assignment operator.
|
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.
Definition at line 524 of file snapshot.hpp.
|
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.
Definition at line 492 of file snapshot.hpp.