载入中...
搜索中...
未找到
EditorPropertyModel.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
8
9#include <functional>
10#include <map>
11#include <memory>
12#include <optional>
13#include <set>
14#include <string>
15#include <vector>
16
17namespace eve::editor {
18
19class IEditorTransactionBackend;
20struct EditorDryRunReport;
21
24
39public:
40 using EditSink = std::function<Result<void>(const PropertyEditIntent &)>;
41
44 PropertyModelSurface surface = PropertyModelSurface::Developer,
45 HostProfile profile = HostProfile::developer(),
46 IEditorTransactionBackend *transactionBackend = nullptr);
49
51 const property_access::PropertySchema &schema() const override { return presentationSchema_; }
53 std::optional<eve::Value> read(const std::string &path) const override;
55 [[nodiscard]] property_access::WriteResult write(const std::string &path, const eve::Value &value) override;
57 std::uint64_t revision() const override { return revision_; }
59 property_access::Subscription subscribe(ChangeCallback callback) override;
60
62 [[nodiscard]] eve::Revision targetRevision() const noexcept { return targetRevision_; }
63
68 [[nodiscard]] Result<void> bind();
69
75 [[nodiscard]] Result<void> setTransactionBackend(IEditorTransactionBackend *backend);
76
82 [[nodiscard]] Result<TransactionId> beginTransaction(std::string label = "Edit property");
84 [[nodiscard]] Result<EditorDryRunReport> previewTransaction();
86 [[nodiscard]] Result<TransactionReceipt> commitTransaction();
88 [[nodiscard]] Result<void> rollbackTransaction();
90 [[nodiscard]] Result<TransactionReceipt> retryTransaction();
92 [[nodiscard]] Result<TransactionReceipt> undo();
94 [[nodiscard]] Result<TransactionReceipt> redo();
95
97 void setEditSink(EditSink sink) { sink_ = std::move(sink); }
103 [[nodiscard]] Result<void> refresh();
104
106 [[nodiscard]] Result<void> rebase();
107
108private:
109 struct CachedProperty {
110 property_access::PropertyChangeState state = property_access::PropertyChangeState::Missing;
111 std::optional<eve::Value> value;
112
114 bool operator==(const CachedProperty &) const = default;
115 };
116
117 struct ObserverState;
118 void rebuildSchema();
119 void dispatch(std::vector<property_access::PropertyChange> changes);
120 [[nodiscard]] Result<eve::Revision> readProviderRevision() const;
121 [[nodiscard]] Result<void> ensureCurrentRevision() const;
122
123 PropertySchema editorSchema_;
124 SelectionSnapshot selection_;
125 const IPropertyProvider *provider_ = nullptr;
126 PropertyModelSurface surface_ = PropertyModelSurface::Developer;
127 HostProfile profile_;
128 property_access::PropertySchema presentationSchema_;
129 std::map<std::string, CachedProperty> cachedProperties_;
130 EditSink sink_;
131 IEditorTransactionBackend *transactionBackend_ = nullptr;
132 std::set<std::string> pendingPaths_;
133 eve::Revision targetRevision_;
134 bool bound_ = false;
135 std::uint64_t revision_ = 0;
136 std::shared_ptr<ObserverState> observers_;
137 std::vector<std::vector<property_access::PropertyChange>> notificationQueue_;
138 bool dispatchingNotifications_ = false;
139};
140
141} // namespace eve::editor
double value
std::string label
#define EVENGINE_API_ORCHESTRATION
Definition Export.h:111
std::string path
Definition PlayHost.cpp:110
ViewPreparation callback
Move-only operation result carrying either a value or Status.
Definition Result.h:155
EVENGINE_API_FOUNDATION public API.
Definition Runtime.h:189
Move-only RAII token that owns one observer registration.
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
UI-independent property access for an immutable selection snapshot.
Adapts command-backed editor properties to the shared MVVM contract.
std::function< Result< void >(const PropertyEditIntent &)> EditSink
void setEditSink(EditSink sink)
Install the legacy command sink; canonical code should inject a backend.
~EditorPropertyModel() override
Editor property model.
std::uint64_t revision() const override
Revision.
const property_access::PropertySchema & schema() const override
Schema.
eve::Revision targetRevision() const noexcept
Return the authoritative provider revision captured by this model.
Upper capability boundary for one editor host.
Transaction boundary consumed by editor property and other UI models.
Renderer- and transaction-independent MVVM property surface.
PropertyModelSurface
Property visibility/permission surface exposed by an editor model.
PropertyChangeState
Availability of a property in an immutable model snapshot.
EVENGINE_API_PLATFORM public API.
SelectionSnapshot public API.
Command intent emitted by a presenter instead of calling a setter.
Versioned schema for one view model or editable target.
Result of a model write, including a stable diagnostic code.