Engine → ECS → archetype.h
archetype
| Type | Class |
| Namespace | conjure::ecs |
| Include File Path | engine/include/conjure/ecs/archetype.h |
| Source File Path | engine/src/ecs/archetype.cpp |
| API ↗ | Archives and serialisation |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | archetype(
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
| Access | Signature | Description |
|---|---|---|
| public | ~archetype(); |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mChunks | std:: | {} | |
| private | mEdges | std:: | {} | |
| private | mEntityCount | u32 | 0 | |
| private | mIndex | u32 | 0 | |
| private | mLayout | chunk_layout | {} | |
| private | mMask | component_mask | {} | |
| private | mSpareChunks | std:: | {} |
Functions
Public
chunk_column
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
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
chunk_count[[nodiscard]] u32 chunk_count() const noexcept;Chunks held, including a drained spare kept for reuse.
chunk_entities
chunk_entitiesThe entity column of one chunk (count() entries); empty for an out-of-range index.
chunk_entity_count
chunk_entity_countRows used in one chunk; 0 for an out-of-range index.
layout
layout[[nodiscard]] const chunk_layout &layout() const noexcept;The chunk layout shared by every chunk.
mask
mask[[nodiscard]] const component_mask &mask() const noexcept;The component set of this archetype.
spare_chunk_count
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
chunk_atedge
edge[[nodiscard]] archetype_edge &edge(
component_id id);find_edge
find_edge[[nodiscard]] archetype_edge *find_edge(
component_id id) noexcept;open_chunk
open_chunkThe 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
push_row[[nodiscard]] core::result<row_location> push_row(
chunk_pool &pool);push_rows
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
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.