Document coordinator with revision-safe requestSave/executeSave sequencing. 更多...
#include <EditorDocumentService.h>
Public 类型 | |
| using | ContentValidator = std::function< Result< void >(const EditorValue &)> |
| Synchronous content validator borrowed only for one external reconciliation call. | |
Public 成员函数 | |
| DocumentService (IAtomicDocumentStore *store) | |
| Document service. | |
| Result< DocumentSnapshot > | open (DocumentKey key, std::string title, std::string resourceUri, EditorValue initialContent={}) |
| Open an asset-backed document, loading existing persisted content when present. | |
| Result< DocumentSnapshot > | edit (const DocumentId &document, EditorValue content, std::optional< Revision > expectedRevision=std::nullopt) |
| Replace the working content using an optional expected edit revision. | |
| Result< SaveTicket > | requestSave (const DocumentId &document) |
| Capture an exact content/revision pair for a later CAS save. | |
| Result< DocumentSnapshot > | executeSave (const SaveTicket &ticket) |
| Execute a captured save ticket without reading newer working content. | |
| Result< EditorValue > | content (const DocumentId &document) const |
| Return the current working content snapshot. | |
| Result< DocumentSnapshot > | snapshot (const DocumentId &document) const |
| Return one metadata snapshot. | |
| std::vector< DocumentSnapshot > | documents () const |
| Return all open documents in stable id order. | |
| Result< DocumentSnapshot > | reconcileExternal (const DocumentId &document) |
| Reconcile one open document with the latest store value. Clean documents adopt external content; dirty documents enter Conflict without losing their working content. | |
| Result< DocumentSnapshot > | reconcileExternal (const DocumentId &document, ContentValidator validator) |
| Reconcile external content only after a domain validator accepts the complete candidate. | |
| Result< void > | close (const DocumentId &document) |
| Close and discard in-memory state; persisted content is unchanged. | |
详细描述
Document coordinator with revision-safe requestSave/executeSave sequencing.
The store is non-owning and must outlive this service. A successful old save ticket advances saved only to its captured edit revision, preserving dirty state for edits made while the save was pending.
在文件 EditorDocumentService.h 第 118 行定义.
成员类型定义说明
◆ ContentValidator
| using eve::editor::DocumentService::ContentValidator = std::function<Result<void>(const EditorValue&)> |
Synchronous content validator borrowed only for one external reconciliation call.
在文件 EditorDocumentService.h 第 121 行定义.
构造及析构函数说明
◆ DocumentService()
|
inlineexplicit |
Document service.
在文件 EditorDocumentService.h 第 124 行定义.
成员函数说明
◆ close()
| Result< void > eve::editor::DocumentService::close | ( | const DocumentId & | document | ) |
Close and discard in-memory state; persisted content is unchanged.
在文件 EditorDocumentService.cpp 第 218 行定义.
被这些函数引用 eve::editor::ActionTimelineDocumentWorkspace::close().
◆ content()
| Result< EditorValue > eve::editor::DocumentService::content | ( | const DocumentId & | document | ) | const |
Return the current working content snapshot.
在文件 EditorDocumentService.cpp 第 118 行定义.
引用了 found.
被这些函数引用 eve::editor::EditorSession::autosaveDocument(), edit(), eve::editor::ActionTimelineDocumentWorkspace::open() , 以及 eve::editor::ActionTimelineDocumentWorkspace::reconcile().
◆ documents()
| std::vector< DocumentSnapshot > eve::editor::DocumentService::documents | ( | ) | const |
Return all open documents in stable id order.
在文件 EditorDocumentService.cpp 第 132 行定义.
◆ edit()
| Result< DocumentSnapshot > eve::editor::DocumentService::edit | ( | const DocumentId & | document, |
| EditorValue | content, | ||
| std::optional< Revision > | expectedRevision = std::nullopt |
||
| ) |
Replace the working content using an optional expected edit revision.
在文件 EditorDocumentService.cpp 第 65 行定义.
引用了 content(), error, found , 以及 eve::editor::Ready.
◆ executeSave()
| Result< DocumentSnapshot > eve::editor::DocumentService::executeSave | ( | const SaveTicket & | ticket | ) |
Execute a captured save ticket without reading newer working content.
在文件 EditorDocumentService.cpp 第 93 行定义.
引用了 eve::editor::SaveTicket::capturedEditRevision, eve::editor::IAtomicDocumentStore::compareAndSwap(), eve::editor::Conflict, eve::editor::SaveTicket::document, error, eve::editor::SaveTicket::expectedContentHash, eve::editor::SaveTicket::expectedDiskRevision, eve::editor::Failed, eve::Result< T >::failure(), eve::editor::SaveTicket::id, pending, eve::editor::Ready, eve::editor::Saving , 以及 stored.
被这些函数引用 eve::editor::ActionTimelineDocumentWorkspace::save() , 以及 eve::editor::EditorSession::saveDocument().
◆ open()
| Result< DocumentSnapshot > eve::editor::DocumentService::open | ( | DocumentKey | key, |
| std::string | title, | ||
| std::string | resourceUri, | ||
| EditorValue | initialContent = {} |
||
| ) |
Open an asset-backed document, loading existing persisted content when present.
在文件 EditorDocumentService.cpp 第 34 行定义.
引用了 error, id, key, eve::editor::IAtomicDocumentStore::read(), eve::editor::Ready, snapshot(), stored , 以及 title.
被这些函数引用 eve::editor::ActionTimelineDocumentWorkspace::open().
◆ reconcileExternal() [1/2]
| Result< DocumentSnapshot > eve::editor::DocumentService::reconcileExternal | ( | const DocumentId & | document | ) |
Reconcile one open document with the latest store value. Clean documents adopt external content; dirty documents enter Conflict without losing their working content.
- 参数
-
document Stable identity of the open document to inspect.
- 返回
- Updated snapshot or a structured conflict/failure.
在文件 EditorDocumentService.cpp 第 144 行定义.
引用了 reconcileExternal().
被这些函数引用 eve::editor::EditorSession::pollDocumentChanges(), eve::editor::ActionTimelineDocumentWorkspace::reconcile() , 以及 reconcileExternal().
◆ reconcileExternal() [2/2]
| Result< DocumentSnapshot > eve::editor::DocumentService::reconcileExternal | ( | const DocumentId & | document, |
| ContentValidator | validator | ||
| ) |
Reconcile external content only after a domain validator accepts the complete candidate.
- 参数
-
document Stable identity of the open document to inspect. validator Synchronous callback invoked without a service lock and never retained.
- 返回
- Updated snapshot, or a structured failure preserving the previous working content.
在文件 EditorDocumentService.cpp 第 148 行定义.
引用了 eve::Conflict, eve::editor::Conflict, error, eve::editor::Failed, eve::Result< T >::failure(), found, eve::InvalidArgument, eve::NotFound, eve::editor::IAtomicDocumentStore::read(), eve::editor::Ready, eve::editing::ruleDiagnostic(), status , 以及 stored.
◆ requestSave()
| Result< SaveTicket > eve::editor::DocumentService::requestSave | ( | const DocumentId & | document | ) |
Capture an exact content/revision pair for a later CAS save.
在文件 EditorDocumentService.cpp 第 78 行定义.
引用了 eve::editor::SaveTicket::capturedEditRevision, eve::editor::SaveTicket::document, eve::editor::SaveTicket::expectedContentHash, eve::editor::SaveTicket::expectedDiskRevision, found, eve::editor::SaveTicket::id , 以及 eve::UuidIdAdapter< Tag >::value().
被这些函数引用 eve::editor::ActionTimelineDocumentWorkspace::save() , 以及 eve::editor::EditorSession::saveDocument().
◆ snapshot()
| Result< DocumentSnapshot > eve::editor::DocumentService::snapshot | ( | const DocumentId & | document | ) | const |
Return one metadata snapshot.
在文件 EditorDocumentService.cpp 第 126 行定义.
被这些函数引用 eve::editor::EditorSession::autosaveDocument(), eve::editor::EditorSession::bindDocument(), eve::editor::ActionTimelineDocumentWorkspace::close(), open(), eve::editor::ActionTimelineDocumentWorkspace::tabs() , 以及 eve::editor::EditorSession::update().
该类的文档由以下文件生成:
- src/modules/editor/EditorDocumentService.h
- src/modules/editor/EditorDocumentService.cpp