Skip to content

Engine → ECS → entity_archive.h

entity_archive

Syntax

class CONJURE_API entity_archive

Constructors

AccessSignatureDescription
publicexplicit entity_archive( const component_registry &registry) noexcept;An empty archive bound to a registry.
publicentity_archive( entity_archive &&other) noexcept;

Important

Copy constructor and assignment has been deleted.

Destructors

AccessSignatureDescription
public~entity_archive();

Variables

AccessNameTypeDefaultDescription
privatemEntriesstd::vector<archive_entry>{}
privatemRegistryconst component_registry *nullptr

Functions

Public

capture

[[nodiscard]] static core::result<entity_archive> capture(
    const world &source,
    std::span<const entity> entities,
    archive_options options = {});

Copies the given entities (every non-TRANSIENT component through ops.copy) and rewrites their entity fields to local indices. ENTITY_NOT_ALIVE when an entity is dead; the world must be unlocked (STRUCTURE_LOCKED otherwise).

component_bytes

[[nodiscard]] std::span<const std::byte> component_bytes(
    u32 entryIndex,
    component_id id) const noexcept;

The component payload of one entry, or an empty span when absent (or a tag).

entity_count

[[nodiscard]] u32 entity_count() const noexcept;

Number of archived entities.

entries

[[nodiscard]] std::span<const archive_entry> entries() const noexcept;

The entries in capture order (entry 0 is the root).

push_entry

void push_entry(
    archive_entry entry);

Appends an entry whose payloads are moved in (used by read_archive_json and tests). Payload bytes must be object images owned by the caller until this call.

registry

[[nodiscard]] const component_registry &registry() const noexcept;

The registry the component ids belong to.

validate

[[nodiscard]] core::result<void> validate() const;

Checks that every component id is registered and non-tag payloads have the registered size, every mask bit has its component (and vice versa), and every archive-local entity reference points inside the archive. ARCHIVE_CORRUPT otherwise.

Private

destroy_payloads

void destroy_payloads() noexcept;

Operator Overloads

Public

operator=

entity_archive &operator=(
    entity_archive &&other) noexcept;