Skip to content

Engine → ECS → chunk_view.h

chunk_view

Syntax

class CONJURE_API chunk_view

Constructors

AccessSignatureDescription
publicchunk_view() noexcept = default;An invalid view: count() is 0 and every accessor returns empty.
publicchunk_view( archetype &owner, chunk &target, u32 chunkIndex, const component_registry &registry, u64 stampVersion, const system_context *context) noexcept;A view of one chunk. Built by queries and the world; context is the running system when the view was created through one (Debug access validation).
publicchunk_view( const chunk_view &) noexcept = default;

Destructors

AccessSignatureDescription
public~chunk_view() = default;

Variables

AccessNameTypeDefaultDescription
privatemArchetypearchetype *nullptr
privatemChunkchunk *nullptr
privatemChunkIndexu320
privatemContext[[maybe_unused]] const system_context *nullptr
privatemRegistryconst component_registry *nullptr
privatemStampVersionu640

Functions

Public

chunk_index

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

Index of this chunk in its archetype.

column_data

[[nodiscard]] void *column_data(
    component_id id,
    bool forWrite) noexcept;

Start of a component column, or nullptr for a tag or an absent component. forWrite stamps the column and, inside a system, checks the declared writes.

[[nodiscard]] const void *column_data(
    component_id id) const noexcept;

Read-only start of a component column, or nullptr. Never stamps.

column_stride

[[nodiscard]] u32 column_stride(
    component_id id) const noexcept;

Bytes between two rows of a column (the component size); 0 when absent.

column_version

[[nodiscard]] u64 column_version(
    component_id id) const noexcept;

Version last stamped on a column; 0 when absent.

count

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

Rows in the chunk.

entities

[[nodiscard]] std::span<const entity> entities() const noexcept;

The entity of every row.

get

template <typename ComponentType> requires (!std::is_empty_v<std::remove_cv_t<ComponentType>>) [[nodiscard]] std::span<ComponentType> get() noexcept;

The column of a required component: a non-const T stamps the column version once, a const T never does. A component the archetype lacks asserts and yields an empty span; use has() or get_optional() for optional components. A tag has no column and does not compile; test it with has().

get_optional

template <typename ComponentType> requires (!std::is_empty_v<std::remove_cv_t<ComponentType>>) [[nodiscard]] std::span<ComponentType> get_optional() noexcept;

Like get(), but an absent component yields an empty span without asserting. A tag does not compile here either.

has

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

True when the archetype holds id (tags included).

is_valid

[[nodiscard]] bool is_valid() const noexcept;

False for a default-constructed view.

owner

[[nodiscard]] const archetype *owner() const noexcept;

The archetype this chunk belongs to (nullptr for an invalid view).

stamp_version

[[nodiscard]] u64 stamp_version() const noexcept;

The version non-const access stamps.

Operator Overloads

Public

operator=

chunk_view &operator=(
    const chunk_view &) noexcept = default;