tess 0.4.0
Performance-first tile and path simulation substrate
Loading...
Searching...
No Matches
tess::World< Shape, Schema, AlwaysResident > Class Template Reference

#include <tess/storage/world.h>

Public Types

using shape_type = Shape
using schema_type = Schema
using residency_type = AlwaysResident
using page_type = ChunkPage<Shape, Schema>

Public Member Functions

 World ()
auto chunks () noexcept -> std::span< page_type >
auto chunks () const noexcept -> std::span< const page_type >
auto chunk (ChunkKey key) noexcept -> page_type &
auto chunk (ChunkKey key) const noexcept -> const page_type &
auto chunk (ChunkCoord3 coord) noexcept -> page_type &
auto chunk (ChunkCoord3 coord) const noexcept -> const page_type &
auto try_chunk (ChunkKey key) noexcept -> page_type *
auto try_chunk (ChunkKey key) const noexcept -> const page_type *
auto try_chunk (ChunkCoord3 coord) noexcept -> page_type *
auto try_chunk (ChunkCoord3 coord) const noexcept -> const page_type *
auto meta (ChunkKey key) noexcept -> ChunkMeta &
auto meta (ChunkKey key) const noexcept -> const ChunkMeta &
auto meta (ChunkCoord3 coord) noexcept -> ChunkMeta &
auto meta (ChunkCoord3 coord) const noexcept -> const ChunkMeta &
auto try_meta (ChunkKey key) noexcept -> ChunkMeta *
auto try_meta (ChunkKey key) const noexcept -> const ChunkMeta *
auto try_meta (ChunkCoord3 coord) noexcept -> ChunkMeta *
auto try_meta (ChunkCoord3 coord) const noexcept -> const ChunkMeta *
auto chunk_state (ChunkKey key) const noexcept -> ChunkState
auto chunk_state (ChunkCoord3 coord) const noexcept -> ChunkState
void set_chunk_state (ChunkKey key, ChunkState state) noexcept
auto dirty_flags (ChunkKey key) const noexcept -> std::uint32_t
auto active_flags (ChunkKey key) const noexcept -> std::uint32_t
auto dirty_bounds (ChunkKey key) const noexcept -> Box3
void mark_dirty (ChunkKey key, std::uint32_t flags, Box3 bounds) noexcept
void mark_topology_dirty (ChunkKey key, std::uint32_t flags, Box3 bounds) noexcept
void mark_topology_rebuilt (ChunkKey key) noexcept
void clear_dirty (ChunkKey key, std::uint32_t flags) noexcept
auto observe_dirty (ChunkKey key, std::uint32_t flags) const noexcept -> DirtyObservation
bool clear_dirty_observed (ChunkKey key, DirtyObservation observed) noexcept
void mark_active (ChunkKey key, std::uint32_t flags) noexcept
void clear_active (ChunkKey key, std::uint32_t flags) noexcept
void collect_dirty_chunks (std::uint32_t flags, std::vector< ChunkKey > &out) const
void collect_active_chunks (std::uint32_t flags, std::vector< ChunkKey > &out) const
auto dirty_chunks (std::uint32_t flags) const -> std::vector< ChunkKey >
auto active_chunks (std::uint32_t flags) const -> std::vector< ChunkKey >
auto resolve (Coord3 coord) const noexcept -> ResolvedTile< Shape >
auto try_resolve (Coord3 coord) const noexcept -> std::optional< ResolvedTile< Shape > >
template<typename Tag>
auto field (Coord3 coord) noexcept -> Schema::template value_type< Tag > &
template<typename Tag>
auto field (Coord3 coord) const noexcept -> const Schema::template value_type< Tag > &
template<typename Tag>
auto try_field (Coord3 coord) noexcept -> Schema::template value_type< Tag > *
template<typename Tag>
auto try_field (Coord3 coord) const noexcept -> const Schema::template value_type< Tag > *
template<typename Tag>
auto field_span (ChunkKey key) noexcept
template<typename Tag>
auto field_span (ChunkKey key) const noexcept

Static Public Attributes

static constexpr std::uint64_t chunk_count = ShapeTraits<Shape>::chunk_count
static constexpr std::uint64_t local_tile_count
static constexpr std::size_t field_count = Schema::field_count
static constexpr std::size_t page_byte_size = page_type::byte_size
static constexpr std::size_t storage_byte_size

Detailed Description

template<typename Shape, typename Schema>
class tess::World< Shape, Schema, AlwaysResident >

Dense owner of every chunk page and its metadata.

Construction allocates and zero-initializes storage for the complete bounded shape. No operation changes the number of pages afterward, so page pointers, references, and spans remain valid until the world is moved from or destroyed. Query and mutation hot paths do not allocate; methods returning a std::vector may. Instances are not internally synchronized: concurrent reads are safe, while mutation requires external synchronization with all accesses to the affected world.

Constructor & Destructor Documentation

◆ World()

template<typename Shape, typename Schema>
tess::World< Shape, Schema, AlwaysResident >::World ( )
inline

Allocates and zero-initializes all chunk pages and metadata.

Member Function Documentation

◆ active_chunks()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::active_chunks ( std::uint32_t flags) const -> std::vector< ChunkKey >
inlinenodiscard

Returns matching active keys in a newly allocated vector.

◆ chunk() [1/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::chunk ( ChunkCoord3 coord) const -> const page_type &
inlinenodiscardnoexcept

Const overload of chunk(ChunkCoord3) with the same precondition.

◆ chunk() [2/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::chunk ( ChunkCoord3 coord) -> page_type &
inlinenodiscardnoexcept

Returns a page by coordinate without runtime error recovery.

Precondition
coord is inside the world.

◆ chunk() [3/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::chunk ( ChunkKey key) const -> const page_type &
inlinenodiscardnoexcept

Const overload of chunk(ChunkKey) with the same precondition.

◆ chunk() [4/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::chunk ( ChunkKey key) -> page_type &
inlinenodiscardnoexcept

Returns a page by key without runtime error recovery.

Precondition
key is inside the world; debug builds assert this precondition.

◆ chunks() [1/2]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::chunks ( ) const -> std::span< const page_type >
inlinenodiscardnoexcept

Const overload of chunks() with the same lifetime contract.

◆ chunks() [2/2]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::chunks ( ) -> std::span< page_type >
inlinenodiscardnoexcept

Returns all pages in chunk-key order without allocating.

◆ collect_active_chunks()

template<typename Shape, typename Schema>
void tess::World< Shape, Schema, AlwaysResident >::collect_active_chunks ( std::uint32_t flags,
std::vector< ChunkKey > & out ) const
inline

Appends matching active chunk keys to caller-owned storage.

The scan and allocation contract matches collect_dirty_chunks().

◆ collect_dirty_chunks()

template<typename Shape, typename Schema>
void tess::World< Shape, Schema, AlwaysResident >::collect_dirty_chunks ( std::uint32_t flags,
std::vector< ChunkKey > & out ) const
inline

Appends matching dirty chunk keys to caller-owned storage.

The scan is O(chunk_count). It allocates only if out grows; reserve enough capacity when allocation-free collection is required.

◆ dirty_chunks()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::dirty_chunks ( std::uint32_t flags) const -> std::vector< ChunkKey >
inlinenodiscard

Returns matching dirty keys in a newly allocated vector.

◆ field() [1/2]

template<typename Shape, typename Schema>
template<typename Tag>
auto tess::World< Shape, Schema, AlwaysResident >::field ( Coord3 coord) const -> const Schema::template value_type< Tag > &
inlinenodiscardnoexcept

Const overload of field() with the same preconditions.

◆ field() [2/2]

template<typename Shape, typename Schema>
template<typename Tag>
auto tess::World< Shape, Schema, AlwaysResident >::field ( Coord3 coord) -> Schema::template value_type< Tag > &
inlinenodiscardnoexcept

Returns mutable field storage without runtime error recovery.

Precondition
coord is inside the world and Tag belongs to the schema.

◆ field_span() [1/2]

template<typename Shape, typename Schema>
template<typename Tag>
auto tess::World< Shape, Schema, AlwaysResident >::field_span ( ChunkKey key) const
inlinenodiscardnoexcept

Const overload of field_span() with the same lifetime contract.

◆ field_span() [2/2]

template<typename Shape, typename Schema>
template<typename Tag>
auto tess::World< Shape, Schema, AlwaysResident >::field_span ( ChunkKey key)
inlinenodiscardnoexcept

Returns the contiguous field column for a chunk without allocating.

Precondition
key is inside the world and Tag belongs to the schema.

◆ meta()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::meta ( ChunkKey key) -> ChunkMeta &
inlinenodiscardnoexcept

Returns mutable metadata by key.

Precondition
key is inside the world; debug builds assert this precondition.

◆ resolve()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::resolve ( Coord3 coord) const -> ResolvedTile< Shape >
inlinenodiscardnoexcept

Resolves a world coordinate without runtime error recovery.

Precondition
coord is inside the world; debug builds assert this precondition.

◆ try_chunk() [1/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::try_chunk ( ChunkCoord3 coord) const -> const page_type *
inlinenodiscardnoexcept

Const overload of try_chunk(ChunkCoord3).

◆ try_chunk() [2/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::try_chunk ( ChunkCoord3 coord) -> page_type *
inlinenodiscardnoexcept

Returns a page by coordinate, or null when it is out of bounds.

◆ try_chunk() [3/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::try_chunk ( ChunkKey key) const -> const page_type *
inlinenodiscardnoexcept

Const overload of try_chunk(ChunkKey).

◆ try_chunk() [4/4]

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::try_chunk ( ChunkKey key) -> page_type *
inlinenodiscardnoexcept

Returns a page by key, or null when the key is out of bounds.

◆ try_field() [1/2]

template<typename Shape, typename Schema>
template<typename Tag>
auto tess::World< Shape, Schema, AlwaysResident >::try_field ( Coord3 coord) const -> const Schema::template value_type< Tag > *
inlinenodiscardnoexcept

Const overload of try_field() with the same checked behavior.

◆ try_field() [2/2]

template<typename Shape, typename Schema>
template<typename Tag>
auto tess::World< Shape, Schema, AlwaysResident >::try_field ( Coord3 coord) -> Schema::template value_type< Tag > *
inlinenodiscardnoexcept

Returns mutable field storage, or null when coord is out of bounds. Tag must belong to the schema.

◆ try_meta()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::try_meta ( ChunkKey key) -> ChunkMeta *
inlinenodiscardnoexcept

Returns mutable metadata, or null when key is out of bounds.

◆ try_resolve()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::try_resolve ( Coord3 coord) const -> std::optional< ResolvedTile< Shape > >
inlinenodiscardnoexcept

Returns a resolved tile, or std::nullopt when out of bounds.

Member Data Documentation

◆ local_tile_count

template<typename Shape, typename Schema>
std::uint64_t tess::World< Shape, Schema, AlwaysResident >::local_tile_count
staticconstexpr
Initial value:
=
ShapeTraits<Shape>::local_tile_count

◆ storage_byte_size

template<typename Shape, typename Schema>
std::size_t tess::World< Shape, Schema, AlwaysResident >::storage_byte_size
staticconstexpr
Initial value:
=
static_cast<std::size_t>(chunk_count) * page_byte_size

The documentation for this class was generated from the following file: