载入中...
搜索中...
未找到
PlayTrace.h
浏览该文件的文档.
1#pragma once
2
8#include "common/Export.h"
9#include "common/Result.h"
10#include "common/Value.h"
11#include "devtools/PlayHost.h"
12
13#include <cstdint>
14#include <string>
15#include <string_view>
16
17namespace eve::dev {
18
24[[nodiscard]] EVENGINE_API_FOUNDATION Result<std::string> playObservationDigest(const Value& state);
25
30[[nodiscard]] EVENGINE_API_FOUNDATION Result<Value> parsePlayTrace(const Value& recording);
31
39[[nodiscard]] EVENGINE_API_FOUNDATION Result<Value> replayPlayTrace(const Value& recording, IPlayHostRuntime& runtime);
40
51
59public:
61 static PlayTraceBuffer& instance();
62
64 void clear();
66 [[nodiscard]] bool isReplaying() const { return replaying_; }
67 void setReplaying(bool value) { replaying_ = value; }
69 void begin(std::string contractId, std::string contractHash, std::int64_t seed,
70 std::string startCheckpoint);
72 void append(const Value& request, const Value& response, std::uint64_t hostFrame);
74 [[nodiscard]] bool isRecording() const { return begun_; }
76 [[nodiscard]] bool empty() const { return stepCount_ == 0; }
78 [[nodiscard]] Value exportTrace() const;
79
80private:
81 PlayTraceBuffer() = default;
82
83 std::string contractId_;
84 std::string contractHash_;
85 std::int64_t seed_ = 0;
86 std::string startCheckpoint_;
87 Value::Array stepItems_;
88 std::int64_t stepCount_ = 0;
89 bool begun_ = false;
90 bool replaying_ = false;
91};
92
93} // namespace eve::dev
double value
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
const GltfImportRequest & request
Versioned Play Host protocol for Agent pause / step / observe / capture.
std::uint32_t seed
Definition PointSet.cpp:807
float begin
Move-only, checked operation results for the common layer.
Owning, renderer-independent dynamic values.
The canonical owning dynamic value used by data-facing protocols.
Definition Value.h:31
std::vector< Value > Array
Definition Value.h:33
RAII flag so nested Play requests during replay are not recorded.
Definition PlayTrace.h:42
PlayReplayGuard(const PlayReplayGuard &)=delete
PlayReplayGuard & operator=(const PlayReplayGuard &)=delete
Process-owned append buffer for trace=append.
Definition PlayTrace.h:58
bool empty() const
Empty.
Definition PlayTrace.h:76
bool isRecording() const
True when recording.
Definition PlayTrace.h:74
void setReplaying(bool value)
Definition PlayTrace.h:67
bool isReplaying() const
True while replayPlayTrace is executing.
Definition PlayTrace.h:66
Result< Value > parsePlayTrace(const Value &recording)
Parse and reject unknown fields on a Play Trace recording.
Definition PlayTrace.cpp:63
Result< Value > replayPlayTrace(const Value &recording, IPlayHostRuntime &runtime)
Replay a parsed recording against a host runtime.
Result< std::string > playObservationDigest(const Value &state)
Canonical digest of a Play observation state object.
Definition PlayTrace.cpp:57