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

UI-owned source connecting immutable providers and scoped ranges to a real WidgetTree. The tree must outlive the source; use a long-lived context when views are disposable. Publisher and request tokens may outlive source/tree/scheduler. Read one pin per model per frame. Scheduler dispatch and source mutation belong between frames. More...

#include <model.hpp>

Public Member Functions

 ~Model ()
 Close publication delivery on UI, without waiting for worker ownership.
 Model (const Model &)=delete
Model & operator= (const Model &)=delete
Publisher< ModelSnapshot< T > > publisher () const
 Copy worker-safe full snapshot endpoint on UI.
std::expected< ModelFrame< T >, TreeError > pin () const
 Capture one immutable frame owner on UI; never reads provider ranges or copies rows.
std::expected< ModelConsumer< T >, TreeError > openRange ()
 Register one independent consumer; NODE_LIMIT reports its finite capacity.
std::expected< std::optional< TreeError >, TreeError > lastError () const
 Last UI application failure; queue acceptance alone is not proof of application.

Static Public Member Functions

static std::expected< std::unique_ptr< Model >, TreeError > create (WidgetTree &tree, Node< Widget > context, std::shared_ptr< const ModelSnapshot< T > > initial, ModelOptions options={})
 Create two bounded Scheduler endpoints in the context's scope; initial snapshot is required.

Friends

class ManagedScene
struct ui::detail::EditAccess

Detailed Description

template<class T>
class portals::Model< T >

UI-owned source connecting immutable providers and scoped ranges to a real WidgetTree. The tree must outlive the source; use a long-lived context when views are disposable. Publisher and request tokens may outlive source/tree/scheduler. Read one pin per model per frame. Scheduler dispatch and source mutation belong between frames.

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.

Member Function Documentation

◆ create()

template<class T>
std::expected< std::unique_ptr< Model >, TreeError > portals::Model< T >::create ( WidgetTree & tree,
Node< Widget > context,
std::shared_ptr< const ModelSnapshot< T > > initial,
ModelOptions options = {} )
inlinestatic

Create two bounded Scheduler endpoints in the context's scope; initial snapshot is required.

Parameters
treeBorrowed UI-owned tree and scheduler that must outlive the source.
contextLive node whose scope owns the endpoints and whose layout is invalidated on publication.
initialNon-null immutable provider snapshot retained as the initial base revision.
optionsPositive independent row, consumer and in-flight-work limits.
Returns
New source; INVALID_ARGUMENT for null/invalid limits, tree/scheduler errors, IDENTITY_EXHAUSTED, or NO_MEMORY on failure without a source.

◆ lastError()

template<class T>
std::expected< std::optional< TreeError >, TreeError > portals::Model< T >::lastError ( ) const
inline

Last UI application failure; queue acceptance alone is not proof of application.

Returns
Sticky UI application error, an empty optional before any such failure, or WRONG_THREAD.

◆ openRange()

template<class T>
std::expected< ModelConsumer< T >, TreeError > portals::Model< T >::openRange ( )
inline

Register one independent consumer; NODE_LIMIT reports its finite capacity.

Returns
Independent UI-owned consumer; tree/frame errors, closed, NODE_LIMIT, IDENTITY_EXHAUSTED, or NO_MEMORY.

◆ pin()

template<class T>
std::expected< ModelFrame< T >, TreeError > portals::Model< T >::pin ( ) const
inline

Capture one immutable frame owner on UI; never reads provider ranges or copies rows.

Returns
Immutable base snapshot/consumer table owner, or WRONG_THREAD. Existing pins survive later publications.

◆ publisher()

template<class T>
Publisher< ModelSnapshot< T > > portals::Model< T >::publisher ( ) const
inline

Copy worker-safe full snapshot endpoint on UI.

Returns
Copied endpoint for strictly newer immutable provider snapshots; acceptance does not imply application.

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