载入中...
搜索中...
未找到
VersionedRegistry.cpp
浏览该文件的文档.
2
3namespace eve::detail {
4namespace {
5
8} // namespace
9
11 if (nextEventSequence.isZero()) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "registry next event sequence must be positive"));
13}
14
16 if (!present) return eve::Result<Generation>::success(Generation(1));
17 const auto next = current.incremented();
18 if (!next || next->isZero())
20 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "registry generation exhausted"));
22}
23
25 const auto next = current.incremented();
26 if (!next)
28 eve::Diagnostic::error(eve::DiagnosticCode::Failed, "registry event sequence exhausted"));
30}
31
33 bool tombstone) {
34 if (sequence.isZero() || (!previous_.isZero() && sequence <= previous_))
35 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "registry event sequence is not increasing"));
36 if (generation.isZero()) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "registry event generation must be positive"));
37 if (remove && !tombstone) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "remove event must describe a tombstone"));
38 if (!remove && tombstone) return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "only remove events may describe tombstones"));
39 previous_ = sequence;
41}
42
44 if (!previous_.isZero() && nextEventSequence <= previous_)
45 return eve::Result<void>::failure(eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "next event sequence must exceed retained events"));
47}
48
49} // namespace eve::detail
std::unique_ptr< gpgpu::Sequence > sequence
Definition OnnxGpgpu.cpp:43
std::uint32_t generation
double current
Generation-qualified storage for replaceable, non-ECS registry data.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
Move-only operation result carrying either a value or Status.
Definition Result.h:155
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:164
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
eve::Result< void > accept(EventSequence sequence, Generation generation, bool remove, bool tombstone)
Accept one event header; the first failure describes the whole log.
eve::Result< void > finish(EventSequence nextEventSequence) const
Validate the boundary between the retained log and the next sequence.
constexpr bool isZero() const noexcept
Returns whether this value is zero.
eve::Result< EventSequence > nextRegistryEventSequence(EventSequence current)
Next event sequence, or a Failed diagnostic when it is exhausted.
eve::Result< void > validateRegistryNextSequence(EventSequence nextEventSequence)
Validates the next-event-sequence floor of a restored registry image.
eve::Result< Generation > nextRegistryGeneration(Generation current, bool present)
Next generation of one slot; present false means the slot is new.
detail::StrongUint64< detail::GenerationTag > Generation
Registry/object replacement generation used to reject stale handles.
Definition Generation.h:13