5#include <portals/row_id.hpp>
6#include <portals/widget.hpp>
66 std::span<const ModelRow<T>>
rows;
149 const std::uint64_t revision_;
150 const std::uint64_t rows_;
194 std::swap(owner_, other.owner_);
195 std::swap(range_, other.range_);
196 std::swap(data_, other.data_);
211 std::span<const ModelRow<T>>
rows() const noexcept {
218 std::string_view
error() const noexcept {
233 return owner_ ? owner_->revision() : 0;
245 std::size_t max_rows) {
246 if (!owner ||
range.count > max_rows ||
range.first > owner->rowCount() ||
247 range.count > owner->rowCount() -
range.first) {
262 }
catch (
const std::bad_alloc &) {
271 template <
class>
friend class Model;
275 : owner_(std::move(owner)), range_(
range), data_(data) {
278 std::shared_ptr<const ModelSnapshot<T>> owner_;
285std::expected<std::uint64_t, TreeError> modelSession();
287struct ModelLifetime {
288 std::atomic<bool> alive{
true};
289 std::atomic<std::size_t> outstanding{};
293 ModelLease(std::shared_ptr<ModelLifetime> life, std::shared_ptr<const void> storage)
294 : lifetime(std::move(life)), storage(std::move(storage)) {
295 lifetime->outstanding.fetch_add(1);
301 lifetime->outstanding.fetch_sub(1);
304 std::shared_ptr<ModelLifetime> lifetime;
305 std::shared_ptr<const void> storage;
306 std::atomic<bool> cancelled{};
307 std::atomic<bool> submitted{};
310template <
class T>
struct ModelEntry {
312 std::uint64_t generation{};
313 ModelRange<T> result;
314 std::weak_ptr<ModelLease> work;
317template <
class T>
struct ModelFrameData {
318 explicit ModelFrameData(std::shared_ptr<
const ModelSnapshot<T>> initial) : snapshot(std::move(initial)) {
321 std::shared_ptr<const ModelSnapshot<T>> snapshot;
322 std::vector<ModelEntry<T>> entries = std::vector<ModelEntry<T>>(0);
323 std::uint64_t revision{};
326template <
class T>
struct ModelCompletion {
328 std::uint64_t generation{};
329 std::shared_ptr<ModelLease> lease;
330 ModelRange<T> result;
333template <
class T>
struct ModelState {
334 ModelState(WidgetTree &value, Node<Widget> node) : tree(value), target(node) {
337 std::expected<void, TreeError> allowed()
const {
338 if (owner != std::this_thread::get_id()) {
339 return std::unexpected(TreeError::WRONG_THREAD);
342 if (!lifetime->alive.load()) {
343 return std::unexpected(TreeError::CLOSED);
346 return tree.withScope(target, [](
const UiScope &) {
350 std::expected<std::shared_ptr<ModelFrameData<T>>,
TreeError> next()
const {
351 if (current->revision == std::numeric_limits<std::uint64_t>::max()) {
352 return std::unexpected(TreeError::IDENTITY_EXHAUSTED);
356 auto result = std::make_shared<ModelFrameData<T>>(*current);
361 }
catch (
const std::bad_alloc &) {
362 return std::unexpected(TreeError::NO_MEMORY);
366 std::expected<void, TreeError> commit(std::shared_ptr<ModelFrameData<T>> next) {
367 auto invalidated = tree.invalidate(target, Invalidation::LAYOUT);
370 return std::unexpected(invalidated.error());
374 auto previous = std::exchange(current, std::move(next));
381 const std::thread::id owner{std::this_thread::get_id()};
382 ModelOptions options;
383 std::uint64_t session{};
384 std::uint64_t identity{};
385 std::vector<ModelRangeId> retired = std::vector<ModelRangeId>(0);
386 std::shared_ptr<ModelLifetime> lifetime = std::make_shared<ModelLifetime>();
387 std::shared_ptr<const ModelFrameData<T>> current;
388 Publisher<ModelCompletion<T>> publisher;
389 std::optional<TreeError> application_error;
416 std::swap(data_, other.data_);
417 std::swap(max_rows_, other.max_rows_);
426 return data_->revision;
433 return data_->snapshot->revision();
441 std::shared_ptr<const ModelSnapshot<T>>
snapshot() const noexcept {
442 return data_->snapshot;
449 return data_->snapshot->rowCount();
457 auto entry = std::ranges::find_if(data_->entries, [
id](
const auto &value) {
458 return value.id == id;
461 if (entry == data_->entries.end()) {
465 return entry->result;
483 if (
id.value == 0 ||
id.generation == 0) {
488 const auto result = data_->snapshot->locateRow(
id);
490 switch (result.state) {
503 }
catch (
const std::bad_alloc &) {
511 template <
class>
friend class Model;
514 template <
class>
friend class Chart;
521 if (!cached.owner_ || cached.owner_ == data_->snapshot || cached.dataRevision() !=
dataRevision() ||
522 cached.owner_->rowCount() !=
rowCount()) {
529 auto cached = readOwner(completed);
535 auto previous = readOwner(*retained);
538 return std::unexpected(previous.error());
550 ModelFrame(std::shared_ptr<
const detail::ModelFrameData<T>> data, std::size_t max_rows)
551 : data_(std::move(data)), max_rows_(max_rows) {
554 std::shared_ptr<const detail::ModelFrameData<T>> data_;
555 std::size_t max_rows_;
583 std::swap(id_, other.id_);
584 std::swap(generation_, other.generation_);
585 std::swap(revision_, other.revision_);
586 std::swap(row_count_, other.row_count_);
587 std::swap(range_, other.range_);
588 std::swap(lease_, other.lease_);
589 std::swap(publisher_, other.publisher_);
613 return !lease_ || lease_->cancelled.load() || !lease_->lifetime->alive.load();
619 lease_->cancelled.store(
true);
632 auto request = *
this;
634 if (request.stopRequested()) {
638 if (!snapshot || snapshot->revision() != request.revision_ || snapshot->rowCount() != request.row_count_) {
642 auto result =
ModelRange<T>::read(std::move(snapshot), request.range_, request.range_.count);
658 bool expected =
false;
660 if (!request.lease_->submitted.compare_exchange_strong(expected,
true)) {
665 auto event = std::make_shared<const detail::ModelCompletion<T>>(request.id_, request.generation_, request.lease_,
667 auto published = request.publisher_.publish(std::move(event));
670 request.lease_->submitted.store(
false);
674 }
catch (
const std::bad_alloc &) {
675 request.lease_->submitted.store(
false);
684 std::uint64_t generation_{};
685 std::uint64_t revision_{};
686 std::uint64_t row_count_{};
688 std::shared_ptr<detail::ModelLease> lease_;
689 Publisher<detail::ModelCompletion<T>> publisher_;
712 if (state_ && state_->owner != std::this_thread::get_id()) {
722 if (state_ && state_->owner != std::this_thread::get_id()) {
726 std::swap(state_, other.state_);
727 std::swap(id_, other.id_);
753 if (!state || id_.
value == 0) {
757 auto allowed = state->allowed();
760 return std::unexpected(allowed.error());
763 auto current = state->current;
764 auto entry = find(*current);
766 if (entry == current->entries.end()) {
770 if (range.count > state->options.max_range_rows || range.first > current->snapshot->rowCount() ||
771 range.count > current->snapshot->rowCount() - range.first) {
775 if (state->lifetime->outstanding.load() >= state->options.max_in_flight) {
779 if (entry->generation == std::numeric_limits<std::uint64_t>::max()) {
784 auto next = state->next();
787 return std::unexpected(next.error());
792 std::make_shared<detail::ModelLease>(state->lifetime, work_owner ? std::move(work_owner) : current->snapshot);
793 auto &updated = *std::ranges::find_if((*next)->entries, [
this](
auto &value) {
794 return value.id == id_;
797 ++updated.generation;
798 updated.work = lease;
799 updated.result =
ModelRange<T>(current->snapshot, range, {});
801 ModelRequest<T> result;
804 result.generation_ = updated.generation;
805 result.revision_ = current->snapshot->revision();
806 result.row_count_ = current->snapshot->rowCount();
807 result.range_ = range;
808 result.lease_ = std::move(lease);
809 result.publisher_ = state->publisher;
811 auto committed = state->commit(std::move(*next));
814 return std::unexpected(committed.error());
817 if (
auto old = entry->work.lock()) {
818 old->cancelled.store(
true);
822 }
catch (
const std::bad_alloc &) {
831 std::expected<void, TreeError>
close() {
832 if (state_ && state_->owner != std::this_thread::get_id()) {
842 template <
class>
friend class Model;
847 auto find(
const detail::ModelFrameData<T> &data)
const {
848 return std::ranges::find_if(data.entries, [
this](
const auto &value) {
849 return value.id == id_;
853 void retire() noexcept {
854 auto state = std::move(state_);
855 auto id = std::exchange(id_, {});
861 if (state->owner != std::this_thread::get_id()) {
866 state->retired.push_back(
id);
868 auto entry = std::ranges::find_if(state->current->entries, [
id](
const auto &value) {
869 return value.id == id;
872 if (entry != state->current->entries.end()) {
873 if (
auto work = entry->work.lock()) {
874 work->cancelled.store(
true);
879 std::shared_ptr<detail::ModelState<T>> state_;
890template <
class T>
class Model {
903 if (!initial || options.max_range_rows == 0 || options.max_consumers == 0 || options.max_in_flight == 0) {
907 auto allowed = tree.
withScope(context, [](
const UiScope &) {
911 return std::unexpected(allowed.error());
914 auto session = detail::modelSession();
917 return std::unexpected(session.error());
921 auto state = std::make_shared<detail::ModelState<T>>(tree, context);
923 state->session = *session;
924 state->options = options;
925 state->retired.reserve(options.max_consumers);
926 state->current = std::make_shared<const detail::ModelFrameData<T>>(std::move(initial));
928 auto completed = tree.template connect<detail::ModelCompletion<T>>(
929 context, [weak = std::weak_ptr(state)](Widget &, std::shared_ptr<const detail::ModelCompletion<T>> value) {
930 auto state = weak.lock();
932 if (!state || !state->lifetime->alive.load() || value->lease->cancelled.load()) {
936 auto previous = state->current;
937 auto entry = std::ranges::find_if(previous->entries, [&](
const auto &item) {
938 return item.id == value->id;
943 if (entry == previous->entries.end() || entry->generation != value->generation ||
944 value->result.dataRevision() != previous->snapshot->revision() || retired(*state, value->id)) {
948 auto next = state->next();
951 state->application_error = next.error();
956 (*next)->entries[
static_cast<std::size_t
>(entry - previous->entries.begin())].result = value->result;
958 auto result = state->commit(std::move(*next));
961 state->application_error = result.error();
966 return std::unexpected(completed.error());
969 state->publisher = completed->publisher;
971 auto snapshots = tree.template connect<ModelSnapshot<T>>(
972 context, [weak = std::weak_ptr(state)](Widget &, std::shared_ptr<const ModelSnapshot<T>> value) {
973 auto state = weak.lock();
975 if (!state || !state->lifetime->alive.load() || value->revision() <= state->current->snapshot->revision()) {
979 auto applied = applySnapshot(*state, std::move(value));
981 state->application_error = applied.error();
986 return std::unexpected(snapshots.error());
989 return std::unique_ptr<Model>(
new Model(std::move(state), std::move(*completed), std::move(*snapshots)));
990 }
catch (
const std::length_error &) {
992 }
catch (
const std::bad_alloc &) {
999 if (state_->owner != std::this_thread::get_id()) {
1003 state_->lifetime->alive.store(
false);
1013 return snapshots_.publisher;
1020 if (state_->owner != std::this_thread::get_id()) {
1024 return ModelFrame<T>(state_->current, state_->options.max_range_rows);
1031 auto state = state_;
1032 auto allowed = state->allowed();
1035 return std::unexpected(allowed.error());
1038 if (state->current->entries.size() - state->retired.size() >= state->options.max_consumers) {
1042 if (state->identity == std::numeric_limits<std::uint64_t>::max()) {
1046 auto previous = state->current;
1047 auto next = state->next();
1050 return std::unexpected(next.error());
1054 std::erase_if((*next)->entries, [&](
const auto &entry) {
1055 return retired(*state, entry.id);
1060 (*next)->entries.push_back({id, 0,
ModelRange<T>((*next)->snapshot, {}, {}), {}});
1062 auto committed = state->commit(std::move(*next));
1065 return std::unexpected(committed.error());
1068 state->identity =
id.
value;
1069 state->retired.clear();
1072 }
catch (
const std::bad_alloc &) {
1081 if (state_->owner != std::this_thread::get_id()) {
1085 return state_->application_error;
1090 friend struct ui::detail::EditAccess;
1093 static std::expected<void, TreeError> applySnapshot(detail::ModelState<T> &state,
1095 auto allowed = state.allowed();
1099 if (!value || value->revision() <= state.current->snapshot->revision()) {
1102 auto previous = state.current;
1103 auto next = state.next();
1106 return std::unexpected(next.error());
1109 (*next)->snapshot = std::move(value);
1113 for (
auto &entry : (*next)->entries) {
1118 auto result = state.commit(std::move(*next));
1124 for (
const auto &entry : previous->entries) {
1125 if (
auto work = entry.work.lock()) {
1126 work->cancelled.store(
true);
1132 static bool retired(
const detail::ModelState<T> &state, ModelRangeId
id) {
1133 return std::ranges::contains(state.retired,
id);
1136 Model(std::shared_ptr<detail::ModelState<T>> state, SchedulerConnection<detail::ModelCompletion<T>> completion,
1137 SchedulerConnection<ModelSnapshot<T>> snapshots)
1138 : state_(std::move(state)), completion_(std::move(completion)), snapshots_(std::move(snapshots)) {
1141 std::shared_ptr<detail::ModelState<T>> state_;
1142 SchedulerConnection<detail::ModelCompletion<T>> completion_;
1143 SchedulerConnection<ModelSnapshot<T>> snapshots_;
UI-owned retained plot of a bounded immutable model range. Accessors run only in prepareChart,...
Definition chart.hpp:117
Additive lifecycle owner over one existing Application subtree. UI affine and nonmovable....
Definition managed.hpp:530
Move-only UI-owned range slot. Equal/overlapping consumers are independent. Close/destruction retires...
Definition model.hpp:698
ModelConsumer(ModelConsumer &&other) noexcept
Transfer on UI.
Definition model.hpp:711
std::expected< ModelRequest< T >, TreeError > request(RowRange range, std::shared_ptr< const void > work_owner={})
UI-only request or replace this slot's work; never starts a worker or reads provider data....
Definition model.hpp:750
~ModelConsumer()
Logically retire without waiting for workers.
Definition model.hpp:704
ModelRangeId id() const noexcept
Stable handle for ModelFrame::range.
Definition model.hpp:737
std::expected< void, TreeError > close()
Retire this consumer on UI. Idempotent; no allocation, cancellation never joins. Retained tables keep...
Definition model.hpp:831
ModelConsumer & operator=(ModelConsumer other) noexcept
Transfer on UI; retire old ownership only after the full replacement is complete.
Definition model.hpp:721
ModelConsumer()=default
Empty consumer.
One immutable model revision retained by the frame owner for all its views. Obtain once before Widget...
Definition model.hpp:400
std::expected< ModelRange< T >, TreeError > read(RowRange range) const
Direct bounded read from the base snapshot, without asynchronous requests or overlays.
Definition model.hpp:472
std::uint64_t rowCount() const noexcept
Logical rows.
Definition model.hpp:448
std::shared_ptr< const ModelSnapshot< T > > snapshot() const noexcept
Retain the immutable base source without reading rows or transferring this UI frame.
Definition model.hpp:441
std::uint64_t dataRevision() const noexcept
Provider data revision.
Definition model.hpp:432
ModelFrame(const ModelFrame &other)=default
Retain the same immutable ownership.
ModelFrame & operator=(ModelFrame other) noexcept
Replace all fields before releasing old storage, whose destructor may reenter.
Definition model.hpp:415
std::expected< ModelRange< T >, TreeError > range(ModelRangeId id) const
Read a consumer's exact result; stale/foreign consumer returns STALE_NODE. No spatial merge.
Definition model.hpp:456
std::uint64_t revision() const noexcept
UI publication revision, including range readiness.
Definition model.hpp:425
std::expected< RowLookup, TreeError > locateRow(RowId id) const
Resolve identity against the same retained snapshot as this frame's base rows.
Definition model.hpp:482
ModelFrame(ModelFrame &&other) noexcept=default
Transfer ownership without releasing old storage.
Independent owner for borrowed rows and provider error text.
Definition model.hpp:175
ModelRange & operator=(ModelRange other) noexcept
Replace all fields before releasing old storage, whose destructor may reenter.
Definition model.hpp:193
std::span< const ModelRow< T > > rows() const noexcept
Borrow until this owner is released.
Definition model.hpp:211
static std::expected< ModelRange, TreeError > read(std::shared_ptr< const ModelSnapshot< T > > owner, RowRange range, std::size_t max_rows)
Read only memory and retain its snapshot. Bounds/provider contract failures are explicit....
Definition model.hpp:244
ModelRange(const ModelRange &other)=default
Retain the same immutable ownership.
RowRange range() const noexcept
Logical interval of this result.
Definition model.hpp:225
std::string_view error() const noexcept
Borrow error text for this owner's lifetime.
Definition model.hpp:218
ModelRange(ModelRange &&other) noexcept=default
Transfer ownership without releasing old storage.
RangeState state() const noexcept
Read readiness without loading.
Definition model.hpp:204
ModelRange()=default
Empty pending result.
std::uint64_t dataRevision() const noexcept
Provider revision.
Definition model.hpp:232
ModelRequest()=default
Empty cancelled token.
RowRange range() const noexcept
Requested rows.
Definition model.hpp:597
ModelRequest & operator=(ModelRequest other) noexcept
Replace all fields before releasing old storage, whose destructor may reenter.
Definition model.hpp:582
ModelRequest(ModelRequest &&other) noexcept=default
Transfer ownership without releasing old storage.
bool stopRequested() const noexcept
Worker-safe cooperative stop query.
Definition model.hpp:612
void cancel() const noexcept
Cancel only this generation; does not release its work budget.
Definition model.hpp:617
std::uint64_t dataRevision() const noexcept
Required provider revision.
Definition model.hpp:604
std::expected< PublishResult, SchedulerError > complete(std::shared_ptr< const ModelSnapshot< T > > snapshot) const
Queue ready/error storage from the requested data revision; pending is invalid. Exactly one successfu...
Definition model.hpp:631
ModelRequest(const ModelRequest &other)=default
Retain the same immutable ownership.
Immutable list/table provider storage, independent of view/source lifetime. Implement read as bounded...
Definition model.hpp:94
virtual ~ModelSnapshot()=default
Reclaim storage after all ranges, frames and workers release it.
virtual std::shared_ptr< const PositionChangeHistory > positionHistory() const
Optional immutable ordering proof owner; default sources add no storage.
Definition model.hpp:144
std::uint64_t rowCount() const noexcept
Logical count, without materializing rows.
Definition model.hpp:116
ModelSnapshot(std::uint64_t revision, std::uint64_t rows)
Define immutable metadata.
Definition model.hpp:100
virtual ModelRows< T > read(RowRange range) const =0
Borrow a checked interval; may return pending/error.
std::uint64_t revision() const noexcept
Provider data revision; strictly increasing on replacement.
Definition model.hpp:109
virtual RowLookup locateRow(RowId id) const
Resolve stable identity without materializing rows or blocking the UI.
Definition model.hpp:134
UI-owned source connecting immutable providers and scoped ranges to a real WidgetTree....
Definition model.hpp:890
Publisher< ModelSnapshot< T > > publisher() const
Copy worker-safe full snapshot endpoint on UI.
Definition model.hpp:1012
std::expected< std::optional< TreeError >, TreeError > lastError() const
Last UI application failure; queue acceptance alone is not proof of application.
Definition model.hpp:1080
~Model()
Close publication delivery on UI, without waiting for worker ownership.
Definition model.hpp:998
std::expected< ModelConsumer< T >, TreeError > openRange()
Register one independent consumer; NODE_LIMIT reports its finite capacity.
Definition model.hpp:1030
std::expected< ModelFrame< T >, TreeError > pin() const
Capture one immutable frame owner on UI; never reads provider ranges or copies rows.
Definition model.hpp:1019
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.
Definition model.hpp:900
Copyable typed observer; never owns or exposes an unchecked widget pointer.
Definition widget.hpp:92
Optional immutable bounded ordering history owned only by supporting providers. No rows,...
Definition model_position.hpp:267
Copyable, worker-safe endpoint. It owns the closed channel state, never UI captures....
Definition scheduler.hpp:189
One UI-owned view with bounded owning row text and one independent model consumer....
Definition virtual_list.hpp:133
One UI-owned table with bounded owning cell text and one independent model consumer....
Definition virtual_table.hpp:154
consteval auto id(StyleState state=StyleState::ANY, bool readOnly=false)
Definition style_static.hpp:865
Public Portals API.
Definition action.hpp:8
@ PENDING
Complete or abandon the owning session before submitting another frame.
Definition diff.hpp:108
@ CLOSED
Scheduler, scope, registration or endpoint is closed.
Definition scheduler.hpp:24
@ CALLBACK_FAILED
A user callback threw; dispatch disconnects its registration.
Definition scheduler.hpp:29
@ INVALID_ARGUMENT
Invalid option, null snapshot or unsupported lane/overflow combination.
Definition scheduler.hpp:21
@ NO_MEMORY
Allocation failed inside the operation boundary.
Definition scheduler.hpp:26
@ READY
Successful nonempty content; the reserved status strip is blank.
Definition data_presentation.hpp:12
@ FAILED
The coroutine returned an error or threw.
Definition async.hpp:46
RangeState
Observable asynchronous range readiness.
Definition model.hpp:45
@ READY
Exactly the requested immutable rows are available.
Definition model.hpp:47
@ FAILED
Provider failure is represented by snapshot-owned text and no rows.
Definition model.hpp:48
@ PENDING
Data is not ready; reading must not block or start work.
Definition model.hpp:46
@ FOUND
A selected owning match is available.
Definition document_search.hpp:18
@ UNSUPPORTED
The application explicitly excludes this annotated phase.
Definition key_binding.hpp:44
RowLookupState
Identity lookup capability and outcome for a pinned provider snapshot.
Definition model.hpp:71
@ FOUND
The index identifies this RowId in the same snapshot.
Definition model.hpp:74
@ UNSUPPORTED
Provider does not implement an identity index; ordinal scrolling remains available.
Definition model.hpp:72
@ NOT_FOUND
Provider supports lookup, but this full RowId is absent.
Definition model.hpp:73
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26
@ CLOSED
The owning tree or source is closed.
Definition widget_types.hpp:31
@ CALLBACK_FAILED
A user extension or callback threw.
Definition widget_types.hpp:37
@ NODE_LIMIT
The configured live node, observer or consumer limit was reached.
Definition widget_types.hpp:35
@ WRONG_THREAD
Operation requires the tree's UI thread.
Definition widget_types.hpp:28
@ STALE_NODE
The observed node or model consumer is absent or retired.
Definition widget_types.hpp:30
@ WOULD_BLOCK
The current frame/reentry boundary or finite queue/work budget rejects this operation.
Definition widget_types.hpp:32
@ IDENTITY_EXHAUSTED
A session, generation or revision cannot advance without reuse.
Definition widget_types.hpp:34
@ INVALID_ARGUMENT
An option, enum value or operation argument is invalid.
Definition widget_types.hpp:27
@ NO_MEMORY
Allocation failed inside the operation boundary.
Definition widget_types.hpp:33
Provider-assigned column identity; typed row accessors define column values.
Definition model.hpp:24
std::uint64_t generation
Nonzero generation, independent of visual order.
Definition model.hpp:26
std::uint64_t value
Nonzero identity within one model.
Definition model.hpp:25
bool operator==(const ColumnId &other) const noexcept=default
Compare identity.
Finite per-model storage and work budgets; all fields must be positive.
Definition model.hpp:165
std::size_t max_in_flight
Request owners, including cancelled and queued work not yet released.
Definition model.hpp:168
std::size_t max_range_rows
Largest single read/request.
Definition model.hpp:166
std::size_t max_consumers
Live scoped range slots, regardless of readiness.
Definition model.hpp:167
Stable identity of a scoped range consumer, distinct even for equal row intervals.
Definition model.hpp:154
std::uint64_t value
Never-reused consumer identity.
Definition model.hpp:156
std::uint64_t session
Process-unique model session.
Definition model.hpp:155
bool operator==(const ModelRangeId &other) const noexcept=default
Compare source and consumer.
A typed domain row and its stable identity; a table uses a typed record as T.
Definition model.hpp:55
T value
Typed value; all reachable data must be immutable while published.
Definition model.hpp:57
RowId id
Stable provider identity, never the row index.
Definition model.hpp:56
Provider result borrowing from its immutable snapshot.
Definition model.hpp:64
RangeState state
Pending never blocks or initiates I/O.
Definition model.hpp:65
std::string_view error
Snapshot-owned description when error; otherwise empty.
Definition model.hpp:67
std::span< const ModelRow< T > > rows
Exactly the requested count when ready; otherwise empty.
Definition model.hpp:66
Provider-assigned row identity, independent of position; increment generation on reuse.
Definition row_id.hpp:9
Owning lookup result; no row storage is borrowed.
Definition model.hpp:78
RowLookupState state
Explicit capability/result, never inferred from an index.
Definition model.hpp:79
std::uint64_t index
Logical index, meaningful only for FOUND.
Definition model.hpp:80
Half-open logical row interval; arithmetic is checked before provider access.
Definition model.hpp:35
std::uint64_t first
First logical row.
Definition model.hpp:36
bool operator==(const RowRange &other) const noexcept=default
Compare interval.
std::size_t count
Number of rows, bounded independently of logical model size.
Definition model.hpp:37