载入中...
搜索中...
未找到
EditorSession.cpp
浏览该文件的文档.
15IEditableTarget* EditorContext::target() const { return session_ ? session_->target() : nullptr; }
25 return eve::editing::failed<void>(EditorStatus::Failed, RuleId("editor.context.missing-session"),
86void EditorSession::invalidateTrackedTarget(EditorTargetCoordinator& coordinator, const TargetId& target,
88 if (targetCoordinator_ != &coordinator || boundTargetId_ != target || targetGeneration_ != generation) return;
113Result<EditorValue> EditorSession::executeCommand(const CommandId& id, const EditorValue& payload,
116 return eve::editing::failed<EditorValue>(EditorStatus::Failed, RuleId("editor.command.missing-service"),
120 const bool ownsTransaction = descriptor && descriptor->createsTransaction && !transactions_.isActive();
122 auto begun = transactions_.beginTransaction(descriptor->displayName.empty() ? id.value() : descriptor->displayName);
178 return eve::editing::failed<CommandPlan>(EditorStatus::Failed, RuleId("editor.command.missing-service"),
190Result<TransactionReceipt> EditorSession::executePlan(const CommandPlan& plan, const EditorValue& payload,
193 return eve::editing::failed<TransactionReceipt>(EditorStatus::Failed, RuleId("editor.command.missing-service"),
200 if (request.context.target != plan.target || request.context.targetRevision != plan.baseRevision ||
202 return eve::editing::failed<TransactionReceipt>(EditorStatus::Conflict, RuleId("editor.command.stale-plan"),
208Result<TransactionReceipt> EditorSession::executeCommandReceipt(const CommandId& id, const EditorValue& payload,
211 receipt.id = TransactionId((sessionId_.empty() ? std::string("editor.session") : sessionId_.value()) +
228 return commandService_ ? commandService_->commands(hostProfile_) : std::vector<CommandDescriptor>{};
231Result<PlanId> EditorSession::retainPlan(const CommandId& id, const EditorValue& payload, CommandSource source,
243Result<TransactionReceipt> EditorSession::executeRetainedPlan(const PlanId& id, CommandSource source) {
247 return eve::editing::failed<TransactionReceipt>(EditorStatus::NotFound, RuleId("editor.command.plan-not-found"),
258 return eve::editing::failed<void>(EditorStatus::NotFound, RuleId("editor.command.plan-not-found"),
273void EditorSession::bindDocumentServices(DocumentService& documents, AutosaveService* autosave) {
341 Result<StoredDocument> result = autosaveService_->writeDraft(snapshot.value(), content.value());
358void EditorSession::setAutosaveInterval(float seconds) { autosaveInterval_ = std::max(0.f, seconds); }
439std::string EditorSession::activeToolId() const { return activeTool_ ? activeTool_->descriptor().id : std::string{}; }
453 if (event.phase == EditorPointerEvent::Phase::Cancel && capturedPointerId_ == event.pointerId) {
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:480
const std::vector< Diagnostic > & diagnostics() const noexcept
Inspect all diagnostics; this counts as checking the Result.
Definition Result.h:501
const T & value() const &
Borrow the value from a const lvalue after checking success.
Definition Result.h:308
const std::vector< Diagnostic > & diagnostics() const noexcept
Inspect all diagnostics; this counts as checking the Result.
Definition Result.h:283
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:255
const Status & status() const noexcept
Inspect the structured operation status.
Definition Result.h:269
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
const std::string & value() const noexcept
Returns the exact legacy or canonical compatibility spelling.
Definition Identity.h:362
bool empty() const noexcept
True when no compatibility spelling has been assigned.
Definition Identity.h:374
Deterministic owning value tree shared by authoring hosts.
Definition EditingValue.h:19
Autosave coordinator that never overwrites the formal document URI.
Definition EditorDiskDocumentStore.h:58
Result< StoredDocument > writeDraft(const DocumentSnapshot &snapshot, const EditorValue &content)
Write one revisioned draft under autosave://project/document.draft.
Definition EditorDiskDocumentStore.cpp:174
Document coordinator with revision-safe requestSave/executeSave sequencing.
Definition EditorDocumentService.h:118
Result< DocumentSnapshot > reconcileExternal(const DocumentId &document)
Reconcile one open document with the latest store value. Clean documents adopt external content; dirt...
Definition EditorDocumentService.cpp:144
Result< DocumentSnapshot > edit(const DocumentId &document, EditorValue content, std::optional< Revision > expectedRevision=std::nullopt)
Replace the working content using an optional expected edit revision.
Definition EditorDocumentService.cpp:65
Result< DocumentSnapshot > snapshot(const DocumentId &document) const
Return one metadata snapshot.
Definition EditorDocumentService.cpp:126
Result< DocumentSnapshot > executeSave(const SaveTicket &ticket)
Execute a captured save ticket without reading newer working content.
Definition EditorDocumentService.cpp:93
Result< EditorValue > content(const DocumentId &document) const
Return the current working content snapshot.
Definition EditorDocumentService.cpp:118
Result< SaveTicket > requestSave(const DocumentId &document)
Capture an exact content/revision pair for a later CAS save.
Definition EditorDocumentService.cpp:78
Result< void > evaluateChecked(EditorContext &context, IEditCommand &command)
Evaluate the chain and return structured allow/warning/reject diagnostics.
Definition EditConstraint.cpp:36
Result< EditorValue > execute(const CommandId &id, const CommandContext &context, const EditorValue &payload) const
Execute a command after payload and profile checks.
Definition EditorCommandService.cpp:128
const CommandDescriptor * find(const CommandId &id) const
Return command metadata or nullptr when it is not registered.
Definition EditorCommandService.cpp:107
std::vector< CommandDescriptor > commands(const HostProfile &profile) const
Return descriptors visible to a host profile.
Definition EditorCommandService.cpp:119
Result< TransactionReceipt > executePlan(const CommandRequest &request, const CommandPlan &plan, const HostProfile &profile) const
Execute a plan only when its lifetime, registration, policy and input bindings remain valid.
Definition EditorCommandService.cpp:195
Result< CommandPlan > plan(const CommandRequest &request, const HostProfile &profile) const
Produce a side-effect-free plan bound to the target, command generation, payload and source.
Definition EditorCommandService.cpp:154
bool execute(std::unique_ptr< IEditCommand > command) const
Send a command through constraints into the active transaction.
Definition EditorSession.cpp:19
Result< void > executeChecked(std::unique_ptr< IEditCommand > command) const
Send a command without discarding validation or transaction diagnostics.
Definition EditorSession.cpp:23
IEditableTarget * target() const
Target currently bound to the session.
Definition EditorSession.cpp:15
IEditableTarget * target() const
Return the live borrowed target, or null after an explicit or tracked unbind.
Definition EditorSession.cpp:107
Result< StoredDocument > autosaveDocument()
Write the active dirty revision to its separate autosave draft.
Definition EditorSession.cpp:330
void clearTarget()
Clear the active target and invalidate retained plans derived from it.
Definition EditorSession.cpp:84
void unbindDocument()
Stop coordinating the active document without closing it.
Definition EditorSession.cpp:299
bool addTool(IEditorTool *tool)
Register a tool. Returns false for null or duplicate id/pointer.
Definition EditorSession.cpp:375
bool execute(std::unique_ptr< IEditCommand > command)
Validate then execute a command in the active transaction.
Definition EditorSession.cpp:30
bool removeTool(const std::string &id)
Remove a registered tool by id, deactivating it when necessary.
Definition EditorSession.cpp:384
EditorContextSnapshot contextSnapshot() const
Capture target revision and host identity for delayed command work.
Definition EditorSession.cpp:162
ToolResponse dispatchPointer(const EditorPointerEvent &event)
Route input to the active tool and apply pointer-capture response.
Definition EditorSession.cpp:441
ToolResponse dispatchKey(const EditorKeyEvent &event)
Route keyboard input to the active tool.
Definition EditorSession.cpp:459
void clearDocumentServices()
Clear document service bindings and unbind the active document.
Definition EditorSession.cpp:279
Result< void > cancelRetainedPlan(const PlanId &id)
Discard one retained plan without executing it.
Definition EditorSession.cpp:254
void drawOverlay(IEditorOverlay &overlay)
Ask the active tool to emit viewport feedback.
Definition EditorSession.cpp:484
Result< TransactionReceipt > executeCommandReceipt(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a legacy-compatible command and return a V2 transaction receipt.
Definition EditorSession.cpp:208
bool activateTool(const std::string &id)
Activate a registered tool by id. Empty id deactivates all tools.
Definition EditorSession.cpp:413
void clearRetainedPlans()
Discard all retained plans, for example after replacing a document or target.
Definition EditorSession.cpp:264
Result< void > executeChecked(std::unique_ptr< IEditCommand > command)
Validate and execute a command while preserving constraint and transaction diagnostics.
Definition EditorSession.cpp:34
Result< CommandPlan > planCommand(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api, std::optional< Revision > expectedRevision=std::nullopt) const
Plan a registered command without applying target mutations.
Definition EditorSession.cpp:174
Result< DocumentSnapshot > pollDocumentChanges()
Detect external disk changes, adopting only when the document is clean.
Definition EditorSession.cpp:349
Result< DocumentSnapshot > bindDocument(const DocumentId &document)
Select an already-open document for save, autosave and conflict polling.
Definition EditorSession.cpp:285
Result< TransactionReceipt > executeRetainedPlan(const PlanId &id, CommandSource source=CommandSource::Api)
Execute a retained plan. Successful plans are consumed exactly once.
Definition EditorSession.cpp:243
void inspect(IEditorInspector &inspector)
Ask the active tool to expose its configurable properties.
Definition EditorSession.cpp:488
Result< DocumentSnapshot > editDocument(EditorValue content, std::optional< Revision > expectedRevision=std::nullopt)
Replace active working content using optional optimistic edit revision.
Definition EditorSession.cpp:306
void cancelActiveTool()
Cancel its gesture and clear pointer capture.
Definition EditorSession.cpp:492
Result< TransactionReceipt > executePlan(const CommandPlan &plan, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a previously returned plan through its registered executor.
Definition EditorSession.cpp:190
void setExternalPollInterval(float seconds)
Configure external-store polling cadence.
Definition EditorSession.cpp:360
void bindTarget(IEditableTarget &target)
Bind a caller-managed editable target available to every tool callback.
Definition EditorSession.cpp:45
Result< EditorValue > executeCommand(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api)
Execute a registered V2 command in this session.
Definition EditorSession.cpp:113
std::vector< CommandDescriptor > availableCommands() const
Return commands visible through this session's host profile.
Definition EditorSession.cpp:227
Result< DocumentSnapshot > saveDocument()
Persist the current active revision through the document CAS store.
Definition EditorSession.cpp:315
void setDocumentServices(DocumentService *documents, AutosaveService *autosave=nullptr)
Bind non-owning persistence services used by the active document.
Definition EditorSession.cpp:266
Result< PlanId > retainPlan(const CommandId &id, const EditorValue &payload={}, CommandSource source=CommandSource::Api, std::optional< Revision > expectedRevision=std::nullopt)
Plan a command and retain its immutable payload under the returned plan id.
Definition EditorSession.cpp:231
void bindDocumentServices(DocumentService &documents, AutosaveService *autosave=nullptr)
Bind document services; documents must outlive this binding.
Definition EditorSession.cpp:273
Coordinates editable targets, per-target histories and domain commands.
Definition EditorTargetCoordinator.h:25
Executes, groups, rolls back and replays arbitrary edit commands.
Definition EditorTransactions.h:13
eve::Result< TransactionId > beginTransaction(TransactionSpec specification)
Begin a canonical checked transaction.
Definition EditorTransactions.cpp:5
eve::Result< void > rollbackTransaction()
Discard the active transaction and restore its preview state.
Definition EditorTransactions.cpp:19
eve::Result< void > append(std::unique_ptr< IEditCommand > command)
Stage and preview one command without discarding diagnostics.
Definition EditorTransactions.cpp:13
eve::Result< EditorTransactionRecord > commitTransaction()
Commit the active transaction and return its complete record.
Definition EditorTransactions.cpp:17
UI-independent property editor used by tools to expose settings.
Definition EditorPresentation.h:47
Sink implemented by a 2D or 3D viewport to render tool feedback.
Definition EditorPresentation.h:27
virtual void update(EditorContext &context, float dt)
Per-frame hook for an active tool.
Definition EditorTool.h:140
virtual void inspect(EditorContext &context, IEditorInspector &inspector)
Expose configurable settings through a host-provided inspector.
Definition EditorTool.h:152
virtual void drawOverlay(EditorContext &context, IEditorOverlay &overlay)
Emit renderer-independent feedback for the active viewport.
Definition EditorTool.h:146
virtual ToolResponse pointerEvent(EditorContext &context, const EditorPointerEvent &event)
Handle normalized pointer input.
Definition EditorTool.h:124
virtual ToolResponse keyEvent(EditorContext &context, const EditorKeyEvent &event)
Handle normalized keyboard input.
Definition EditorTool.h:132
virtual void activate(EditorContext &context)
Called exactly once when this tool becomes active.
Definition EditorTool.h:119
virtual void cancel(EditorContext &context)
Cancel the active gesture while keeping the tool selected.
Definition EditorTool.h:158
virtual const ToolDescriptor & descriptor() const =0
Stable tool identity and presentation metadata.
Definition ActionPreviewController.cpp:6
void appendProjectedDiagnostics(std::vector< eve::Diagnostic > &destination, const eve::Status &status)
Append diagnostics while assembling a new immutable Result status.
Definition EditorResultProjection.h:16
std::uint64_t targetGeneration
Target lifetime generation captured while planning.
Definition EditingProtocol.h:71
std::uint64_t targetGeneration
Monotonic lifetime generation of the bound target instance.
Definition EditingProtocol.h:39
Revision afterRevision
Definition EditingProtocol.h:110
std::vector< Diagnostic > diagnostics
Definition EditingProtocol.h:112
Revision beforeRevision
Definition EditingProtocol.h:109
Immutable execution context captured for a synchronous command.
Definition EditorCommandService.h:20
uint64_t targetRevision
Definition EditorCommandService.h:24
Presentation and execution metadata for a registered command.
Definition EditorCommandService.h:29
bool createsTransaction
Definition EditorCommandService.h:35
Pointer input normalized by an editor viewport adapter.
Definition EditorTool.h:20
Result returned by a tool after processing input.
Definition EditorTool.h:50