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

Owning cold model declaration; copies share one single-scene registration. Construction does not read providers or register runtime objects. Closed declarations remain closed; use a new declaration for another scene. Captured borrows retain their original lifetime obligations. Access and registration are creating-UI-thread operations. More...

#include <ui_model.hpp>

Public Types

using Row = T
 Immutable domain row, shared with the mounted model.

Public Member Functions

 Model ()=default
 Create an empty descriptor whose checked use reports INVALID_ARGUMENT.
std::expected< ManagedModel< T >, ManagedError > managed () const
 Obtain the published model without extending scene lifetime.
ModelValue< T > value (std::source_location origin=std::source_location::current()) const
 Observe this scalar value; descriptor assignment itself only copies handles.
template<class Member, class Record>
requires std::same_as<Record, T> && std::equality_comparable<T> && std::copy_constructible<T> && std::copy_constructible
<std::remove_cv_t<Member>> && (!std::is_array_v<Member>) && (!std::is_pointer_v<Member>) &&
(!portals::detail::IS_BORROWED_DERIVED_VALUE<std::remove_cv_t<Member>>) && (!std::ranges::view<std::remove_cv_t<Member>>)
ModelField< T, Member > field (Member Record::*member, std::source_location origin=std::source_location::current()) const
 Observe one owned scalar field without borrowing a snapshot or registering another source.
std::expected< void, ManagedError > insert (std::uint64_t index, const T &value) const
 Insert one value into a mounted owned sequence on its UI thread.
std::expected< void, ManagedError > update (RowId id, const T &value) const
 Replace one owned row value while preserving its model-local identity and order.
bool row (RowId id, const T &value, std::source_location origin=std::source_location::current()) const
 Replace an owned row value and collect a checked failure in the existing event diagnostics.
std::expected< void, ManagedError > erase (std::uint64_t first, std::uint64_t count=1) const
 Erase a range from a mounted owned sequence on its UI thread.
std::expected< void, ManagedError > move (std::uint64_t first, std::uint64_t count, std::uint64_t destination) const
 Move an owned range without replacing its row identities.
std::expected< void, ManagedError > clear () const
 Remove every row from a mounted owned sequence on its UI thread.

Friends

struct detail::ModelAccess
struct detail::EditAccess
struct detail::ValueModelAccess
template<class>
class ModelValue
template<class, class>
class ModelField

Detailed Description

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

Owning cold model declaration; copies share one single-scene registration. Construction does not read providers or register runtime objects. Closed declarations remain closed; use a new declaration for another scene. Captured borrows retain their original lifetime obligations. Access and registration are creating-UI-thread operations.

Template Parameters
TDomain value or collection row; scalar and owned-array paths require copyable values.

Member Function Documentation

◆ clear()

template<class T>
std::expected< void, ManagedError > portals::ui::Model< T >::clear ( ) const

Remove every row from a mounted owned sequence on its UI thread.

Returns
Success or typed capability, lifetime or allocation failure; rejection preserves the snapshot. An already empty sequence does not advance its revision.

◆ erase()

template<class T>
std::expected< void, ManagedError > portals::ui::Model< T >::erase ( std::uint64_t first,
std::uint64_t count = 1 ) const

Erase a range from a mounted owned sequence on its UI thread.

Parameters
firstRange start; the end boundary is valid for an empty range.
countErased count, defaulting to one; zero is a no-op.
Returns
Success or typed capability, lifetime, bounds or allocation failure; rejection preserves the snapshot.

◆ field()

template<class T>
requires std::same_as<Record, T> && std::equality_comparable<T> && std::copy_constructible<T> && std::copy_constructible
<std::remove_cv_t<Member>> && (!std::is_array_v<Member>) && (!std::is_pointer_v<Member>) &&
(!portals::detail::IS_BORROWED_DERIVED_VALUE<std::remove_cv_t<Member>>) && (!std::ranges::view<std::remove_cv_t<Member>>)
template<class Member, class Record>
requires std::same_as<Record, T> && std::equality_comparable<T> && std::copy_constructible<T> && std::copy_constructible
<std::remove_cv_t<Member>> && (!std::is_array_v<Member>) && (!std::is_pointer_v<Member>) &&
(!portals::detail::IS_BORROWED_DERIVED_VALUE<std::remove_cv_t<Member>>) && (!std::ranges::view<std::remove_cv_t<Member>>)
ModelField< T, Member > portals::ui::Model< T >::field ( Member Record::* member,
std::source_location origin = std::source_location::current() ) const

Observe one owned scalar field without borrowing a snapshot or registering another source.

Template Parameters
MemberCopyable owning field value; const fields expose checked reads only. Known borrowed pointers, string views, spans, reference wrappers and range views are rejected.
RecordDeclaring record type, required to match this model's value type.
Parameters
memberNon-null data-member pointer retained by value; null reports INVALID_ARGUMENT on use.
originAssignment diagnostic site retained by the returned proxy.
Returns
UI-affine field property sharing this declaration and its root revision/transaction. Cold, collection, wrong-thread and closed failures follow value().

◆ insert()

template<class T>
std::expected< void, ManagedError > portals::ui::Model< T >::insert ( std::uint64_t index,
const T & value ) const

Insert one value into a mounted owned sequence on its UI thread.

Parameters
indexInsertion ordinal, including the end boundary.
valueValue copied under the existing mutation admission boundary.
Returns
Success with a fresh SDK identity, or typed capability, lifetime, capacity or allocation failure. Existing identities survive; failure preserves the installed snapshot.

◆ managed()

template<class T>
std::expected< ManagedModel< T >, ManagedError > portals::ui::Model< T >::managed ( ) const
inline

Obtain the published model without extending scene lifetime.

Returns
Weak runtime handle, CLOSED before publication/after close, or a typed handle/thread failure.

◆ move()

template<class T>
std::expected< void, ManagedError > portals::ui::Model< T >::move ( std::uint64_t first,
std::uint64_t count,
std::uint64_t destination ) const

Move an owned range without replacing its row identities.

Parameters
firstMoved range start.
countMoved row count; zero is a no-op.
destinationInsertion index after removing the range.
Returns
Success or typed capability, lifetime, bounds or allocation failure; rejection preserves the snapshot.

◆ row()

template<class T>
bool portals::ui::Model< T >::row ( RowId id,
const T & value,
std::source_location origin = std::source_location::current() ) const

Replace an owned row value and collect a checked failure in the existing event diagnostics.

Parameters
idExact model-local row key, with the same validation as update().
valueReplacement copied under update() admission.
originCaller location retained by collected diagnostics.
Returns
True on acceptance or equality no-op; false after reporting the update() failure.

◆ update()

template<class T>
std::expected< void, ManagedError > portals::ui::Model< T >::update ( RowId id,
const T & value ) const

Replace one owned row value while preserving its model-local identity and order.

Parameters
idExact live key from this model; missing or stale generations report INVALID_ARGUMENT.
valueCopy-constructible replacement, copied before publication; no assignment is required.
Returns
Success or typed capability, lifetime, reentry, key, revision or allocation failure. Equality-comparable values that compare equal are a no-op; other values publish a revision. Precommit failure preserves the snapshot. Later delivery errors do not roll back an accepted update.

◆ value()

template<class T>
requires std::equality_comparable<T>
ModelValue< T > portals::ui::Model< T >::value ( std::source_location origin = std::source_location::current()) const

Observe this scalar value; descriptor assignment itself only copies handles.

Parameters
originAssignment diagnostic site retained by the returned proxy.
Returns
UI-affine smart property with checked reads/writes and collected assignment. Collection declarations report INVALID_ARGUMENT; cold or closed values report CLOSED.

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