Skip to content

Engine → ECS → archetype.h

archetype

Syntax

class CONJURE_API archetype

Constructors

AccessSignatureDescription
publicarchetype( const component_mask &mask, chunk_layout layout, u32 index);

Important

Copy constructor and assignment has been deleted. Move constructors have been deleted. Move assignment has been deleted.

Destructors

AccessSignatureDescription
public~archetype();

Variables

AccessNameTypeDefaultDescription
privatemChunksstd::vector<std::unique_ptr<chunk>>{}
privatemEdgesstd::vector<archetype_edge>{}
privatemEntityCountu320
privatemIndexu320
privatemLayoutchunk_layout{}
privatemMaskcomponent_mask{}
privatemSpareChunksstd::vector<std::unique_ptr<chunk>>{}

Functions

Public

chunk_column

[[nodiscard]] const void *chunk_column(
    u32 chunkIndex,
    component_id id) const noexcept;

Read-only start of a component column in one chunk; nullptr for a tag, an absent component or an out-of-range chunk.

chunk_column_version

[[nodiscard]] u64 chunk_column_version(
    u32 chunkIndex,
    component_id id) const noexcept;

World version last stamped on a column of one chunk; 0 when absent.

chunk_count

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

Chunks held, including a drained spare kept for reuse.

chunk_entities

[[nodiscard]] std::span<const entity> chunk_entities(
    u32 chunkIndex) const noexcept;

The entity column of one chunk (count() entries); empty for an out-of-range index.

chunk_entity_count

[[nodiscard]] u32 chunk_entity_count(
    u32 chunkIndex) const noexcept;

Rows used in one chunk; 0 for an out-of-range index.

entity_count

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

Entities stored here.

has

[[nodiscard]] bool has(
    component_id id) const noexcept;

True when the set contains id.

index

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

Position in world::archetypes().

layout

[[nodiscard]] const chunk_layout &layout() const noexcept;

The chunk layout shared by every chunk.

mask

[[nodiscard]] const component_mask &mask() const noexcept;

The component set of this archetype.

spare_chunk_count

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

Drained chunk objects parked without a block (their blocks are back in the pool), reused by the next growth so create/destroy churn allocates no chunk metadata.

Private

chunk_at

[[nodiscard]] chunk *chunk_at(
    u32 chunkIndex) noexcept;
[[nodiscard]] const chunk *chunk_at(
    u32 chunkIndex) const noexcept;

edge

[[nodiscard]] archetype_edge &edge(
    component_id id);

find_edge

[[nodiscard]] archetype_edge *find_edge(
    component_id id) noexcept;

open_chunk

[[nodiscard]] chunk *open_chunk(
    u32 &chunkIndex) noexcept;

The chunk the next row goes into (a partial chunk ahead of a drained spare fills before the spare so only the last used chunk is partial), or nullptr when every chunk is full.

push_row

[[nodiscard]] core::result<row_location> push_row(
    chunk_pool &pool);

push_rows

[[nodiscard]] core::result<row_span> push_rows(
    chunk_pool &pool,
    usize wanted);

Takes up to wanted (at least one) consecutive rows of the chunk the next row goes into, allocating a chunk when every chunk is full: all wanted when they fit, else the rest of that chunk. The rows count as entities at once; the caller fills or discards every one of them. Fails like reserve_row, taking nothing.

reserve_row

[[nodiscard]] core::result<void> reserve_row(
    chunk_pool &pool);

Makes sure a chunk with a free row exists, allocating one when needed, without taking the row: the part of push_row that can fail (ARCHETYPE_TOO_LARGE, OUT_OF_MEMORY), split off so the world can run observers between the check and the move.