5#include <portals/model_position_finite.hpp>
7namespace portals::detail {
10struct ModelViewCheckpoint;
11struct PreparedModelViewChange;
12struct ModelRestoreChannels;
14struct ManagedNavigationRecord {
15 ManagedState<NavigationPosition> current;
16 ManagedState<NavigationSelection> selection;
17 ManagedState<NavigationPosition> reading;
18 ManagedScene *owner{};
19 std::weak_ptr<const void> lifetime;
20 std::weak_ptr<ManagedModelSource> model;
22 ModelResource resource;
24 NavigationOptions options;
25 std::optional<ModelBookmark> bookmark;
26 std::optional<ModelBookmark> readingBookmark;
27 PositionChangeMap changes;
28 std::optional<PositionRequest> request;
29 std::stop_source cancellation{std::nostopstate};
30 std::uint64_t sequence{};
31 std::uint64_t operation{};
32 std::uint64_t frameRevision{};
37 std::unique_ptr<std::vector<std::weak_ptr<EditNavigationParticipant>>> editors;
38 std::expected<void, TreeError> beforeEditTransition(
const NavigationPosition *next =
nullptr,
39 const std::shared_ptr<ManagedModelSource> &source = {});
41 std::function<std::expected<ModelBookmark, TreeError>(
const std::shared_ptr<ManagedNavigationRecord> &, RowId)>;
42 using Synchronize = std::function<std::expected<void, TreeError>(
const std::shared_ptr<ManagedNavigationRecord> &)>;
43 std::shared_ptr<Capture> capture;
44 std::shared_ptr<Synchronize> synchronize;
45 std::shared_ptr<ModelViewHistory> history;
48 std::shared_ptr<Property<NavigationPosition>> currentOwner;
49 std::shared_ptr<Property<NavigationSelection>> selectionOwner;
50 std::shared_ptr<Property<NavigationPosition>> readingOwner;
51 Property<NavigationPosition>::PreparedChange current;
52 Property<NavigationSelection>::PreparedChange selection;
53 Property<NavigationPosition>::PreparedChange reading;
56 std::expected<Publication, TreeError>
57 preparePublication(NavigationPosition nextCurrent, NavigationSelection nextSelection, NavigationPosition nextReading);
58 std::expected<void, TreeError> validatePublication(
const Publication &publication)
const;
59 std::expected<void, TreeError> invalidatePublication(
const Publication &publication)
const;
60 static void installPublication(
const Publication &publication)
noexcept;
61 static std::optional<SchedulerError> publishPublication(
const Publication &publication);
63 std::expected<void, TreeError> setPosition(std::optional<ModelBookmark> value, PositionResolution resolution,
64 bool readingAnchor =
false);
65 void cancel() noexcept;
66 void close() noexcept;
69struct ManagedNavigationBinding {
71 std::weak_ptr<ManagedNavigationRecord> context;
72 NavigationBindingOptions options;
73 using Stage = std::function<std::expected<std::unique_ptr<PreparedModelViewChange>, ManagedError>(
74 const std::shared_ptr<ManagedModelSource> &, ModelRebindOptions,
const std::shared_ptr<ModelViewHistory> &,
75 const ModelViewCheckpoint *,
const void *)>;
77 std::function<void(
const ModelViewCheckpoint *,
const ModelRestoreChannels *)> installed;
78 std::function<std::expected<void, TreeError>()> before;
79 std::function<std::expected<void, TreeError>()> after;
82struct LogCheckpointEntry {
85 SourceCredit metadataCredit;
86 ModelResource resource;
87 std::weak_ptr<const void> lifetime;
88 LogReadingCheckpoint value;
89 std::unique_ptr<LogCheckpointEntry> next;
92struct LogCheckpointChange {
93 SourceCredit metadataCredit;
94 std::unique_ptr<LogCheckpointEntry> added;
95 LogCheckpointEntry *existing{};
96 ModelResource resource;
97 std::weak_ptr<const void> lifetime;
98 LogReadingCheckpoint value;
99 bool replaceMetadata{};
102struct LogNavigationSession {
104 std::shared_ptr<SourceBudget> budget;
105 std::weak_ptr<const void> lifetime;
106 std::weak_ptr<const void> binding;
108 LogCheckpointOptions options;
109 LogRestoreStatus status;
110 std::unique_ptr<LogCheckpointEntry> entries;
115 LogCheckpointEntry *find(ModelResource resource)
const noexcept;
116 void prune() noexcept;
117 void reset(ModelResource resource) noexcept;
118 void close() noexcept;
119 std::expected<LogCheckpointChange, SourceError>
120 stage(ModelResource resource, std::weak_ptr<const
void> resourceLifetime, LogReadingCheckpoint value);
121 void commit(LogCheckpointChange change) noexcept;
124struct ManagedNavigationRegistry {
125 std::vector<std::shared_ptr<ManagedNavigationRecord>> contexts =
126 std::vector<std::shared_ptr<ManagedNavigationRecord>>(0);
127 std::vector<std::shared_ptr<ManagedNavigationBinding>> bindings =
128 std::vector<std::shared_ptr<ManagedNavigationBinding>>(0);
129 std::vector<std::shared_ptr<LogNavigationSession>> logSessions =
130 std::vector<std::shared_ptr<LogNavigationSession>>(0);
131 bool refreshAfterLayout{};
134TreeError navigationTreeError(SourceError error)
noexcept;
TreeError
Checked tree failures; rejected operations never start the requested callback.
Definition widget_types.hpp:26