载入中...
搜索中...
未找到
EditorDiskDocumentStore.h
浏览该文件的文档.
1#pragma once
2#include "common/Export.h"
3
4
6
7#include <filesystem>
8#include <functional>
9#include <string>
10
11namespace eve::editor {
12
21public:
23 explicit DiskAtomicDocumentStore(std::filesystem::path projectRoot);
24
26 Result<StoredDocument> read(const std::string& resourceUri) const override;
28 Result<StoredDocument> compareAndSwap(const std::string& resourceUri, Revision expectedRevision,
29 const std::string& expectedContentHash,
30 const EditorValue& content) override;
31
33 std::filesystem::path resolve(const std::string& resourceUri) const;
35 void setBeforeReplaceHook(std::function<bool(const std::filesystem::path&)> hook) {
36 beforeReplace_ = std::move(hook);
37 }
38
39private:
40 static Result<StoredDocument> failure(EditorStatus status, const char* rule, std::string message);
41 bool replace(const std::filesystem::path& temporary, const std::filesystem::path& destination) const;
42
43 std::filesystem::path root_;
44 std::function<bool(const std::filesystem::path&)> beforeReplace_;
45 std::uint64_t sequence_ = 0;
46};
47
56
59public:
65 AutosaveService(IAtomicDocumentStore* store, std::string projectId)
67 : store_(store), projectId_(std::move(projectId)) {}
68
70 Result<StoredDocument> writeDraft(const DocumentSnapshot& snapshot, const EditorValue& content);
72 Result<AutosaveDraft> readDraft(const DocumentId& document) const;
74 bool shouldOfferRecovery(const AutosaveDraft& draft, const DocumentSnapshot& formal) const;
76 std::string draftUri(const DocumentId& document) const;
77
78private:
79 IAtomicDocumentStore* store_ = nullptr;
80 std::string projectId_;
81};
82
83} // namespace eve::editor
#define EVENGINE_API_ORCHESTRATION
Definition Export.h:111
std::string message
wgpu::PopErrorScopeStatus status
Move-only operation result carrying either a value or Status.
Definition Result.h:155
UUID-backed identifier adapter for legacy textual boundaries.
Definition Identity.h:314
Deterministic owning value tree shared by authoring hosts.
Autosave coordinator that never overwrites the formal document URI.
AutosaveService(IAtomicDocumentStore *store, std::string projectId)
Create an autosave namespace.
Project-rooted JSON document store with sibling-temp atomic replacement.
void setBeforeReplaceHook(std::function< bool(const std::filesystem::path &)> hook)
Test seam invoked after temp write and before atomic replacement.
Compare-and-swap persistence boundary used by DocumentService.
eve::editing::Revision Revision
StatusCode
Stable outcome category for an operation.
Definition Status.h:27
Persisted draft metadata used to decide whether recovery should be offered.
Immutable document metadata snapshot.