载入中...
搜索中...
未找到
GameSaveSession.h
浏览该文件的文档.
1#pragma once
2
5#include "common/Export.h"
6#include "common/Result.h"
7#include "common/Snapshot.h"
8#include "common/Value.h"
9
10#include <functional>
11#include <map>
12#include <memory>
13#include <string>
14#include <string_view>
15
16namespace eve {
17
20public:
21 virtual ~IPreparedGameRestore() = default;
23 virtual void commit() noexcept = 0;
24};
25
33public:
34 virtual ~IGameSaveParticipant() = default;
36 virtual std::string_view saveKey() const noexcept = 0;
38 [[nodiscard]] virtual Result<Value> capture() const = 0;
40 [[nodiscard]] virtual Result<std::unique_ptr<IPreparedGameRestore>> prepare(const Value& state) = 0;
41};
42
49public:
51 explicit GameSaveSession(std::string contentVersion);
52
58 [[nodiscard]] Result<void> add(IGameSaveParticipant& participant);
59
68 [[nodiscard]] Result<void> addContentMigration(std::string fromVersion,
69 std::function<Result<Value>(const Value&)> migrate);
70
77 [[nodiscard]] Result<std::string> snapshotJson(const SnapshotHashProvider& hashProvider) const;
78
87 [[nodiscard]] Result<void> restoreJson(std::string_view json, const SnapshotHashProvider& hashProvider);
88
89private:
90 std::string contentVersion_;
91 std::map<std::string, IGameSaveParticipant*> participants_;
92 std::map<std::string, std::function<Result<Value>(const Value&)>> migrations_;
93};
94
95} // namespace eve
#define EVENGINE_API_FOUNDATION_INLINE
仅供"只有内联成员"的类型使用的组宏:拥有者 dllexport,消费方不导入。
Definition Export.h:170
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
Move-only, checked operation results for the common layer.
Versioned, integrity-checked persistence envelopes.
Owning, renderer-independent dynamic values.
Seal and restore all registered domain owners as one game-save transaction.
One authoritative domain participating in a game save. @lifetime The participant and its live domain ...
virtual std::string_view saveKey() const noexcept=0
Stable unique participant key within the game-save schema.
virtual ~IGameSaveParticipant()=default
Owning prepared state whose publication cannot fail or invoke callbacks.
virtual void commit() noexcept=0
Publish the prepared domain state exactly once on its owner thread.
virtual ~IPreparedGameRestore()=default
Move-only operation result carrying either a value or Status.
Definition Result.h:176
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36