tess 1.0.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 >
template<typename Tag>
void fill_field (const Schema::template value_type< Tag > &value) noexcept
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_activity (ChunkKey key) const noexcept -> ChunkActivity
auto chunk_activity (ChunkCoord3 coord) const noexcept -> ChunkActivity
auto active_category_count (ChunkKey key) const noexcept -> std::uint32_t
auto dirty_mask (ChunkKey key) const noexcept -> DirtyMask
auto active_mask (ChunkKey key) const noexcept -> ActiveMask
auto dirty_bounds (ChunkKey key) const noexcept -> Box3
void mark_dirty (ChunkKey key, DirtyMask mask, Box3 bounds) noexcept
void mark_content_changed (ChunkKey key) noexcept
void mark_topology_dirty (ChunkKey key, DirtyMask mask, Box3 bounds) noexcept
void mark_topology_rebuilt (ChunkKey key) noexcept
void clear_dirty (ChunkKey key, DirtyMask mask) noexcept
auto observe_dirty (ChunkKey key, DirtyMask mask) const noexcept -> DirtyObservation
bool clear_dirty_observed (ChunkKey key, DirtyObservation observed) noexcept
void mark_active (ChunkKey key, ActiveMask mask) noexcept
void clear_active (ChunkKey key, ActiveMask mask) noexcept
void collect_dirty_chunks (DirtyMask mask, std::vector< ChunkKey > &out) const
void collect_active_chunks (ActiveMask mask, std::vector< ChunkKey > &out) const
auto dirty_chunks (DirtyMask mask) const -> std::vector< ChunkKey >
auto active_chunks (ActiveMask mask) 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 value-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 value-initializes all chunk pages and metadata.

Member Function Documentation

◆ active_chunks()

template<typename Shape, typename Schema>
auto tess::World< Shape, Schema, AlwaysResident >::active_chunks ( ActiveMask mask) 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 ( ActiveMask mask,
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 ( DirtyMask mask,
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 ( DirtyMask mask) 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.

◆ fill_field()

template<typename Shape, typename Schema>
template<typename Tag>
void tess::World< Shape, Schema, AlwaysResident >::fill_field ( const Schema::template value_type< Tag > & value)
inlinenoexcept

Assigns value to Tag on every tile.

The traversal and TileFieldValue assignment perform no allocation and cannot throw. This is a storage write only: like direct field() writes, it does not update dirty/active masks or topology/content versions.

◆ mark_content_changed()

template<typename Shape, typename Schema>
void tess::World< Shape, Schema, AlwaysResident >::mark_content_changed ( ChunkKey key)
inlinenoexcept

Advances the chunk content version without marking dirty work.

Use this after a content write that must invalidate version-keyed derived state but does not concern any dirty-mask consumer. This changes only the content version. Use mark_dirty for dirty-metadata consumers, mark_topology_dirty when topology freshness must change, and the schedule's notification protocol when an OnDirty task must run. An intervening call also makes an earlier DirtyObservation stale.

The key must be valid, matching the precondition of mark_dirty.

◆ 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: