Portals0.7.0 · dev (544a5c68c72e · 2026-11-28 UTC)
Loading...
Searching...
No Matches
portals::ModelSnapshot< T > Class Template Referenceabstract

Immutable list/table provider storage, independent of view/source lifetime. Implement read as bounded in-memory access, without I/O, waiting or domain mutation. Every ready range of one data revision must agree, including overlapping ranges from different snapshot objects. Shared ownership does not make mutable aliases safe. Opting this source into a background model adapter requires worker-safe read access, including concurrent reads of the same immutable storage; no UI frame or thread-affine cache may be used. Snapshots and transitively owned T values must support destruction on the last owner's thread; UI reentry from a destructor requires a still-live UI context. More...

#include <model.hpp>

Inheritance diagram for portals::ModelSnapshot< T >:
portals::ModelSnapshot< T >portals::ModelSnapshot< T > portals::QuerySnapshot< T >

Public Member Functions

 ModelSnapshot (std::uint64_t revision, std::uint64_t rows)
 Define immutable metadata.
virtual ~ModelSnapshot ()=default
 Reclaim storage after all ranges, frames and workers release it.
std::uint64_t revision () const noexcept
 Provider data revision; strictly increasing on replacement.
std::uint64_t rowCount () const noexcept
 Logical count, without materializing rows.
virtual ModelRows< T > read (RowRange range) const =0
 Borrow a checked interval; may return pending/error.
virtual RowLookup locateRow (RowId id) const
 Resolve stable identity without materializing rows or blocking the UI.
virtual std::shared_ptr< const PositionChangeHistory > positionHistory () const
 Optional immutable ordering proof owner; default sources add no storage.

Detailed Description

template<class T>
class portals::ModelSnapshot< T >

Immutable list/table provider storage, independent of view/source lifetime. Implement read as bounded in-memory access, without I/O, waiting or domain mutation. Every ready range of one data revision must agree, including overlapping ranges from different snapshot objects. Shared ownership does not make mutable aliases safe. Opting this source into a background model adapter requires worker-safe read access, including concurrent reads of the same immutable storage; no UI frame or thread-affine cache may be used. Snapshots and transitively owned T values must support destruction on the last owner's thread; UI reentry from a destructor requires a still-live UI context.

Template Parameters
TDomain row value type; snapshot-owned reachable data must remain immutable and support destruction on the final owner's thread. Library range/frame/request operations do not copy T values.

Constructor & Destructor Documentation

◆ ModelSnapshot()

template<class T>
portals::ModelSnapshot< T >::ModelSnapshot ( std::uint64_t revision,
std::uint64_t rows )
inline

Define immutable metadata.

Parameters
revisionProvider data revision; full replacements apply only when strictly newer.
rowsLogical row count, independent of how much data is materialized.

Member Function Documentation

◆ locateRow()

template<class T>
virtual RowLookup portals::ModelSnapshot< T >::locateRow ( RowId id) const
inlinevirtual

Resolve stable identity without materializing rows or blocking the UI.

Parameters
idFull nonzero row identity, including generation.
Returns
FOUND with this snapshot's index, NOT_FOUND if absent, or UNSUPPORTED by default.
Note
Override with a bounded identity index to support stable viewport anchoring and ensure-visible. Do not scan the full model, perform I/O, mutate domain data, or retain the argument. Called during preparation on UI, never paint; exceptions are translated by ModelFrame::locateRow.

Reimplemented in portals::QuerySnapshot< T >.

◆ positionHistory()

template<class T>
virtual std::shared_ptr< const PositionChangeHistory > portals::ModelSnapshot< T >::positionHistory ( ) const
inlinevirtual

Optional immutable ordering proof owner; default sources add no storage.

Returns
Provider-owned bounded scalar history, or empty when this capability is unsupported. This additive virtual capability requires matching SDK headers and library ABI.

◆ read()

template<class T>
virtual ModelRows< T > portals::ModelSnapshot< T >::read ( RowRange range) const
pure virtual

Borrow a checked interval; may return pending/error.

Parameters
rangeInterval already validated by ModelRange::read; direct callers must validate bounds.
Returns
Borrowed rows/error text owned by this snapshot: ready has exactly range.count rows and no error; pending has no rows or error; error has no rows. The provider must keep returned storage alive.

Implemented in portals::QuerySnapshot< T >.

◆ revision()

template<class T>
std::uint64_t portals::ModelSnapshot< T >::revision ( ) const
inlinenoexcept

Provider data revision; strictly increasing on replacement.

Returns
Immutable provider data revision supplied at construction.

◆ rowCount()

template<class T>
std::uint64_t portals::ModelSnapshot< T >::rowCount ( ) const
inlinenoexcept

Logical count, without materializing rows.

Returns
Logical number of rows supplied at construction; no rows are loaded.

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