载入中...
搜索中...
未找到
EditorHostProfile.cpp
浏览该文件的文档.
19 profile.features_ = HostFeature::ProjectDocuments | HostFeature::SourceAssets | HostFeature::RuntimeWorld |
40bool HostProfile::hasFeatures(HostFeature required) const { return (features_ & required) == required; }
90void EditorInspector::addFloat(const std::string &id, const std::string &label, float value, float minV, float maxV,
126void EditorInspector::addString(const std::string &id, const std::string &label, const std::string &value) {
136void EditorInspector::addChoice(const std::string &id, const std::string &label, const std::string &choicesCsv,
343Result<EditorPersistenceSnapshot> persistenceError(EditorStatus status, const char *rule, std::string message) {
344 return eve::editing::failed<EditorPersistenceSnapshot>(status, RuleId(rule), std::move(message));
365Result<EditorPersistenceSnapshot> EditorPersistenceAdapter::commit(const EditorPersistenceSnapshot &base,
373 for (const DomainOperation &operation : journal) serializedJournal.push_back(operationValue(operation));
379 store_->compareAndSwap(resourceUri_, base.revision, base.contentHash, EditorValue(std::move(envelope)));
392 const auto *journalValues = journal == envelope->end() ? nullptr : journal->second.getIf<EditorValue::Array>();
401 for (const EditorValue &value : *journalValues) result.journal.push_back(decodeOperation(value));
422eve::Result<void> writeFailure(const Result<T> &result, std::string fallbackCode, std::string fallbackMessage) {
487 return eve::editing::failed<eve::Revision>(editorStatusFor(status.code()), RuleId(rule), status.describe());
491 return eve::editing::failed<void>(EditorStatus::Conflict, RuleId("editor.property.revision-conflict"),
531 if (surface_ == PropertyModelSurface::Runtime && !profile_.hasFeatures(HostFeature::RuntimeWorld)) return;
533 if (surface_ == PropertyModelSurface::Runtime && (!hasPropertyFlag(property.flags, PropertyFlag::Runtime) ||
543 if (found == cachedProperties_.end() || found->second.state != property_access::PropertyChangeState::Value)
549 if (!provider_) return property_access::rejected("editor.property.provider", "No property provider");
552 return writeFailure(revisionCheck, "editor.property.revision", "Property revision is unavailable");
561 return presenter.editIntent(editorSchema_, selection_, PropertyPath(path), editorValue, profile_);
593 return writeFailure(begun, "editor.property.transaction.begin", "Could not begin property transaction");
605 return writeFailure(appended, "editor.property.transaction.append", "Could not stage property operation");
628 return writeFailure(committed, "editor.property.transaction.commit", "Property transaction commit failed");
637 if (!sink_) return property_access::rejected("editor.property.sink", "No command sink is connected");
643 return writeFailure(sinkRevisionCheck, "editor.property.revision", "Property revision is unavailable");
660 return eve::editing::failed<void>(EditorStatus::Conflict, RuleId("editor.property.backend-active"),
673 return eve::editing::failed<TransactionId>(EditorStatus::Conflict, RuleId("editor.property.transaction-active"),
677 return eve::editing::failed<TransactionId>(EditorStatus::Rejected, RuleId("editor.property.target"),
690 return eve::editing::failed<TransactionId>(EditorStatus::Failed, RuleId("editor.property.transaction-id"),
725 return eve::editing::failed<void>(EditorStatus::Unsupported, RuleId("editor.property.transaction-backend"),
784 std::erase_if(state->entries, [id](const ObserverState::Entry &entry) { return entry.id == id; });
790 return eve::editing::failed<eve::Revision>(EditorStatus::Unsupported, RuleId("editor.property.provider"),
803 if (current.value() != targetRevision_) return externalRevisionConflict(targetRevision_, current.value());
813 return eve::editing::failed<void>(EditorStatus::Unsupported, RuleId("editor.property.provider"),
816 return eve::editing::failed<void>(EditorStatus::Conflict, RuleId("editor.property.active-transaction"),
837 case PropertyReadState::Mixed: cached.state = property_access::PropertyChangeState::Mixed; break;
838 case PropertyReadState::Missing: cached.state = property_access::PropertyChangeState::Missing; break;
const T & value() const &
Borrow the value from a const lvalue after checking success.
Definition Result.h:339
const std::vector< Diagnostic > & diagnostics() const noexcept
Inspect all diagnostics; this counts as checking the Result.
Definition Result.h:314
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:286
const Status & status() const noexcept
Inspect the structured operation status.
Definition Result.h:300
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
Move-only RAII token that owns one observer registration.
Definition Subscription.h:27
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:313
static UuidIdAdapter fromUuid(Uuid value)
Builds an adapter from an explicit canonical UUID.
Definition Identity.h:346
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:365
bool empty() const noexcept
True when no compatibility spelling has been assigned.
Definition Identity.h:377
std::optional< PersistentId > generate() const
Generates a UUIDv7 using the injected clock.
Definition Identity.cpp:81
constexpr std::uint64_t value() const noexcept
Returns the underlying value at an explicit protocol boundary.
Definition StrongUint64.h:26
UI-independent property access for an immutable selection snapshot.
Definition EditingProperty.h:141
virtual Result< DomainOperation > makeSet(const SelectionSnapshot &selection, const PropertyPath &path, const Value &value, PropertySetMode mode) const =0
Make set.
virtual PropertyReadResult read(const SelectionSnapshot &selection, const PropertyPath &path) const =0
Reads read.
virtual eve::Result< eve::Revision > currentRevision(const SelectionSnapshot &selection) const
Current revision.
Definition EditingProperty.h:148
Deterministic owning value tree shared by authoring hosts.
Definition EditingValue.h:23
Shared presenter logic that exposes developer-oriented property rows.
Definition EditorPropertyPresenter.h:32
Result< PropertyEditIntent > editIntent(const PropertySchema &schema, const SelectionSnapshot &selection, const PropertyPath &path, const EditorValue &value, PropertySetMode mode=PropertySetMode::Absolute) const
Validate a candidate and emit a command payload without mutating the provider.
Definition EditorPropertyPresenter.cpp:67
void addFloat(const std::string &id, const std::string &label, float value, float minV, float maxV, float step)
Adds float.
Definition EditorHostProfile.cpp:90
std::string getFieldKind(int index) const
Returns the field kind.
Definition EditorHostProfile.cpp:148
void setFloat3(const std::string &id, float x, float y, float z)
Sets the float 3.
Definition EditorHostProfile.cpp:211
float getFloatStep(const std::string &id) const
Returns the float step.
Definition EditorHostProfile.cpp:189
std::string getFieldLabel(int index) const
Returns the field label.
Definition EditorHostProfile.cpp:158
float getFloat3X(const std::string &id) const
Returns the float 3 x.
Definition EditorHostProfile.cpp:195
void setChoice(const std::string &id, const std::string &value)
Sets the choice.
Definition EditorHostProfile.cpp:258
std::string getString(const std::string &id) const
Returns the string.
Definition EditorHostProfile.cpp:237
std::string pollChangedId()
Returns next dirty field id, or "" if none.
Definition EditorHostProfile.cpp:288
void setFloat(const std::string &id, float value)
Sets the float.
Definition EditorHostProfile.cpp:170
std::string getChoice(const std::string &id) const
Returns the choice.
Definition EditorHostProfile.cpp:252
std::string getChoicesCsv(const std::string &id) const
Returns the choices csv.
Definition EditorHostProfile.cpp:267
void addString(const std::string &id, const std::string &label, const std::string &value)
Adds string.
Definition EditorHostProfile.cpp:126
float getFloat3Z(const std::string &id) const
Returns the float 3 z.
Definition EditorHostProfile.cpp:205
void setString(const std::string &id, const std::string &value)
Sets the string.
Definition EditorHostProfile.cpp:243
void addBool(const std::string &id, const std::string &label, bool value)
Adds bool.
Definition EditorHostProfile.cpp:116
float getFloatMax(const std::string &id) const
Returns the float max.
Definition EditorHostProfile.cpp:184
float getFloatMin(const std::string &id) const
Returns the float min.
Definition EditorHostProfile.cpp:179
void addFloat3(const std::string &id, const std::string &label, float x, float y, float z)
Adds float 3.
Definition EditorHostProfile.cpp:104
void addChoice(const std::string &id, const std::string &label, const std::string &choicesCsv, const std::string &selected)
Adds choice.
Definition EditorHostProfile.cpp:136
float getFloat3Y(const std::string &id) const
Returns the float 3 y.
Definition EditorHostProfile.cpp:200
Result< EditorPersistenceSnapshot > commit(const EditorPersistenceSnapshot &base, EditorValue content, std::vector< DomainOperation > journal)
Atomically commit a checkpoint against its loaded revision/hash.
Definition EditorHostProfile.cpp:365
Result< EditorPersistenceSnapshot > load() const
Load the last committed checkpoint and journal.
Definition EditorHostProfile.cpp:349
Result< TransactionReceipt > undo()
Undo the latest committed property transaction.
Definition EditorHostProfile.cpp:748
Result< void > setTransactionBackend(IEditorTransactionBackend *backend)
Set the borrowed canonical transaction boundary.
Definition EditorHostProfile.cpp:654
property_access::Subscription subscribe(ChangeCallback callback) override
Subscribe.
Definition EditorHostProfile.cpp:778
Result< void > rollbackTransaction()
Discard pending property writes without publishing them.
Definition EditorHostProfile.cpp:723
~EditorPropertyModel() override
Editor property model.
Result< EditorDryRunReport > previewTransaction()
Validate pending property writes without changing the target.
Definition EditorHostProfile.cpp:697
Result< TransactionReceipt > redo()
Redo the latest undone property transaction.
Definition EditorHostProfile.cpp:763
EditorPropertyModel(PropertySchema schema, SelectionSnapshot selection, const IPropertyProvider *provider, PropertyModelSurface surface=PropertyModelSurface::Developer, HostProfile profile=HostProfile::developer(), IEditorTransactionBackend *transactionBackend=nullptr)
Editor property model.
Definition EditorHostProfile.cpp:507
Result< TransactionReceipt > commitTransaction()
Commit pending property writes and refresh observers after success.
Definition EditorHostProfile.cpp:707
Result< TransactionId > beginTransaction(std::string label="Edit property")
Begin an explicit property transaction.
Definition EditorHostProfile.cpp:667
Result< TransactionReceipt > retryTransaction()
Retry a retained failed commit.
Definition EditorHostProfile.cpp:732
Result< void > refresh()
Re-read values and adopt the provider's current revision.
Definition EditorHostProfile.cpp:811
Result< void > bind()
Bind to the provider's current revision and values.
Definition EditorHostProfile.cpp:807
Result< void > rebase()
Explicit spelling for refreshing and rebasing this model.
Definition EditorHostProfile.cpp:809
std::optional< eve::Value > read(const std::string &path) const override
Reads .
Definition EditorHostProfile.cpp:540
eve::Result< void > write(const std::string &path, const eve::Value &value) override
Writes .
Definition EditorHostProfile.cpp:548
Upper capability boundary for one editor host.
Definition EditorHostProfile.h:51
static HostProfile runtimeBuilder()
Safe runtime profile that denies commands unless allow-listed.
Definition EditorHostProfile.cpp:27
static HostProfile developer()
Unrestricted developer profile used by legacy sessions.
Definition EditorHostProfile.cpp:17
void allowCommands(std::initializer_list< CommandId > ids)
Allow commands.
Definition EditorHostProfile.cpp:48
static HostProfile automation()
Headless profile that denies commands unless allow-listed.
Definition EditorHostProfile.cpp:33
virtual Result< StoredDocument > read(const std::string &resourceUri) const =0
Read the latest value for a resource URI.
virtual Result< StoredDocument > compareAndSwap(const std::string &resourceUri, Revision expectedRevision, const std::string &expectedContentHash, const EditorValue &content)=0
Replace a value only when the expected disk revision still matches.
Transaction boundary consumed by editor property and other UI models.
Definition EditorTransactionService.h:17
virtual Result< TransactionReceipt > redo()=0
Reapply the latest compensated transaction.
virtual Result< void > discard()=0
Discard pending work after reverting any provisional preview.
virtual Result< TransactionReceipt > undo()=0
Compensate the latest committed transaction.
virtual Result< TransactionReceipt > commit()=0
Publish the pending transaction and retain it for undo.
virtual Result< TransactionReceipt > retry()=0
Retry a failed commit while retaining its original operation list.
virtual Result< void > append(DomainOperation operation)=0
Append a serializable operation to the pending transaction.
virtual bool active() const noexcept=0
Whether a transaction is currently pending.
virtual Result< EditorDryRunReport > preview()=0
Validate the pending transaction without publishing target state.
virtual Result< TransactionId > begin(TransactionSpec specification)=0
Begin an explicit transaction without mutating its target.
Shared presenter logic that exposes only runtime-safe property rows.
Definition EditorPropertyPresenter.h:44
Result< PropertyEditIntent > editIntent(const PropertySchema &schema, const SelectionSnapshot &selection, const PropertyPath &path, const EditorValue &value, const HostProfile &profile, PropertySetMode mode=PropertySetMode::Absolute) const
Validate a runtime-visible candidate and emit the same command payload as developer UI.
Definition EditorPropertyPresenter.cpp:90
std::function< void(const PropertyChange &)> ChangeCallback
Definition PropertyAccess.h:185
RuleId diagnosticRule(const Diagnostic &diagnostic)
Return the projected editing rule, or an empty RuleId when absent.
Definition EditingResult.h:38
Definition ActionPreviewController.cpp:6
eve::editing::Value EditorValue
Compatibility alias for the UI-independent authoring value tree.
Definition EditorValue.h:8
EditorValue toEditorValue(const eve::Value &value)
Compatibility spelling for conversion into the authoring value tree.
Definition EditorProperty.h:29
eve::editing::SelectionItem SelectionItem
Stable item stored in a selection snapshot.
Definition EditorSelection.h:22
eve::editing::SelectionSnapshot SelectionSnapshot
Immutable multi-selection captured for property and command work.
Definition EditorSelection.h:25
EditorPersistenceKind
Persistence target selected by a game/editor host.
Definition EditorPersistence.h:11
HostFeature
Coarse host features used to discover and gate editor extensions.
Definition EditorHostProfile.h:18
@ SourceAssets
@ MultiplayerSubmit
@ SourceControl
@ ArbitraryScript
@ ProjectDocuments
@ UserCreations
@ BuildCook
@ DebugOverride
@ RuntimeWorld
PropertyModelSurface
Property visibility/permission surface exposed by an editor model.
Definition EditorPropertyModel.h:23
eve::editing::DomainOperation DomainOperation
Definition EditorProtocol.h:12
Result< void > rejected(std::string rule, std::string message, DiagnosticCode code=DiagnosticCode::PreconditionViolation)
Build a rejected write/validation result with a stable rule string.
Definition PropertyAccess.h:107
eve::Subscription Subscription
Compatibility alias for the common observer lifetime token.
Definition PropertyAccess.h:174
@ Pending
@ NotFound
@ NoOp
@ Applied
@ Cancelled
@ Unsupported
@ Rejected
@ Failed
@ Conflict
detail::StrongUint64< detail::RevisionTag > Revision
Monotonic content/state revision used for optimistic-concurrency checks.
Definition Revision.h:13
Definition Container.h:602
Loaded checkpoint plus the domain operations recorded with it.
Definition EditorPersistence.h:14
std::string contentHash
Definition EditorPersistence.h:17
EditorPersistenceKind kind
Definition EditorPersistence.h:15
ChangeCallback callback
Definition EditorHostProfile.cpp:501
std::vector< Entry > entries
Definition EditorHostProfile.cpp:504
std::uint64_t nextId
Definition EditorHostProfile.cpp:503
Value snapshot returned by an atomic document store.
Definition EditorDocumentService.h:78
Immutable notification emitted after a model property changes.
Definition PropertyAccess.h:160
One stable property description consumed by any UI shell.
Definition PropertyAccess.h:74
eve::OptionalRef< const PropertyDescriptor > find(const std::string &path) const
Find a property by stable path, or an empty immediate borrow.
Definition PropertyAccess.cpp:9
std::vector< PropertyDescriptor > properties
Definition PropertyAccess.h:91