载入中...
搜索中...
未找到
eve::definitions::DefinitionRegistry类 参考

Deterministic registry of topic-neutral, versioned JSON definitions. 更多...

#include <Definitions.h>

Public 类型

using ChangeCallback = std::function< void(const DefinitionEvent &)>
 

Public 成员函数

 DefinitionRegistry (eve::PersistentId instanceId={})
 Creates a definition registry with an optional persistent identity.
 
eve::Result< DefinitionHandle > insert (const std::string &type, const std::string &id, int version, const std::string &json)
 Inserts a definition using the common generation-qualified registry.
 
eve::Result< DefinitionHandle > replace (const std::string &type, const std::string &id, int version, const std::string &json)
 Replaces a live definition and invalidates its previous handle.
 
eve::Result< DefinitionHandle > remove (const std::string &type, const std::string &id)
 Removes a definition and returns the retained tombstone handle.
 
eve::ResultRef< const Definition > resolve (const std::string &type, const std::string &id) const
 Resolves a definition through the common registry API.
 
eve::ResultRef< const Definition > resolveHandle (const DefinitionHandle &handle) const
 Resolves a generation-qualified handle and reports stale identities.
 
eve::Result< DefinitionHandle > handle (const std::string &type, const std::string &id) const
 Returns the current generation-qualified handle through Result.
 
eve::Result< eve::Generation > generationOf (const std::string &type, const std::string &id) const
 Returns the latest generation, including a retained tombstone.
 
bool isTombstone (const std::string &type, const std::string &id) const noexcept
 Returns whether a key is retained as a tombstone.
 
bool isStale (const DefinitionHandle &handle) const noexcept
 Returns whether a generation-qualified handle is stale.
 
DefinitionRef reference (const std::string &type, const std::string &id) const
 Creates a reload-safe logical reference containing only type and id.
 
int size () const
 Returns the total number of definitions.
 
int countType (const std::string &type) const
 Returns the number of definitions registered for a type.
 
const Definition * at (int index) const
 Returns a definition by globally sorted type/id order, or nullptr.
 
const Definition * atType (const std::string &type, int index) const
 Returns a definition by id order within one type, or nullptr.
 
int eventCount () const
 Returns the number of retained mutation events.
 
const DefinitionEvent * eventAt (int index) const
 Returns a retained mutation event by sequence order, or nullptr.
 
void clearEvents ()
 Clears retained events without resetting their sequence allocator.
 
std::string snapshotJson () const
 Exports all registry state as deterministic canonical JSON.
 
eve::Result< void > restoreJson (const std::string &json)
 Transactionally restores registry state from snapshotJson() output.
 
eve::Result< eve::SnapshotEnvelope > snapshot (const eve::SnapshotHashProvider &hashProvider) const
 Captures this registry in the common versioned snapshot envelope.
 
eve::Result< void > restoreSnapshot (const eve::SnapshotEnvelope &snapshot, const eve::SnapshotHashProvider &hashProvider)
 Restores a verified or migratable snapshot transactionally.
 
eve::Result< std::string > snapshotEnvelopeJson (const eve::SnapshotHashProvider &hashProvider) const
 Serializes the common snapshot envelope as canonical JSON.
 
eve::Result< void > restoreSnapshotJson (std::string_view json, const eve::SnapshotHashProvider &hashProvider)
 Parses and transactionally restores a common snapshot envelope.
 
eve::Subscription subscribe (ChangeCallback callback)
 Subscribes to successful definition register, replace and remove operations.
 

详细描述

Deterministic registry of topic-neutral, versioned JSON definitions.

Returned Definition references remain valid until that key is replaced or removed, or until restoreJson() replaces registry state. The reference is a synchronous borrow; callers must not retain it across registry mutation.

在文件 Definitions.h 第 58 行定义.

成员类型定义说明

◆ ChangeCallback

在文件 Definitions.h 第 66 行定义.

构造及析构函数说明

◆ DefinitionRegistry()

eve::definitions::DefinitionRegistry::DefinitionRegistry ( eve::PersistentId  instanceId = {})
explicit

Creates a definition registry with an optional persistent identity.

参数
instanceIdIdentity carried by new SnapshotEnvelope values; nil is a valid legacy identity.

在文件 Definitions.cpp 第 231 行定义.

引用了 generation , 以及 value.

成员函数说明

◆ at()

const Definition * eve::definitions::DefinitionRegistry::at ( int  index) const

Returns a definition by globally sorted type/id order, or nullptr.

在文件 Definitions.cpp 第 359 行定义.

引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::at() , 以及 index.

◆ atType()

const Definition * eve::definitions::DefinitionRegistry::atType ( const std::string &  type,
int  index 
) const

◆ clearEvents()

void eve::definitions::DefinitionRegistry::clearEvents ( )

Clears retained events without resetting their sequence allocator.

在文件 Definitions.cpp 第 389 行定义.

引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::clearEvents() , 以及 eve::detail::StrongUint64< Tag >::incremented().

◆ countType()

int eve::definitions::DefinitionRegistry::countType ( const std::string &  type) const

◆ eventAt()

const DefinitionEvent * eve::definitions::DefinitionRegistry::eventAt ( int  index) const

Returns a retained mutation event by sequence order, or nullptr.

在文件 Definitions.cpp 第 378 行定义.

引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::eventAt(), eve::VersionedRegistry< Key, Value, EventData, Compare >::eventCount() , 以及 index.

◆ eventCount()

int eve::definitions::DefinitionRegistry::eventCount ( ) const

Returns the number of retained mutation events.

在文件 Definitions.cpp 第 376 行定义.

引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::eventCount().

◆ generationOf()

eve::Result< eve::Generation > eve::definitions::DefinitionRegistry::generationOf ( const std::string &  type,
const std::string &  id 
) const

Returns the latest generation, including a retained tombstone.

在文件 Definitions.cpp 第 331 行定义.

引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::generationOf() , 以及 type.

◆ handle()

eve::Result< DefinitionHandle > eve::definitions::DefinitionRegistry::handle ( const std::string &  type,
const std::string &  id 
) const

Returns the current generation-qualified handle through Result.

在文件 Definitions.cpp 第 325 行定义.

引用了 eve::Result< T >::failure(), eve::VersionedRegistry< Key, Value, EventData, Compare >::handle(), eve::Result< T >::success() , 以及 type.

被这些函数引用 eve::rts::RTSContentLoader::load().

◆ insert()

eve::Result< DefinitionHandle > eve::definitions::DefinitionRegistry::insert ( const std::string &  type,
const std::string &  id,
int  version,
const std::string &  json 
)

◆ isStale()

bool eve::definitions::DefinitionRegistry::isStale ( const DefinitionHandle &  handle) const
noexcept

Returns whether a generation-qualified handle is stale.

在文件 Definitions.cpp 第 339 行定义.

引用了 handle.

◆ isTombstone()

bool eve::definitions::DefinitionRegistry::isTombstone ( const std::string &  type,
const std::string &  id 
) const
noexcept

Returns whether a key is retained as a tombstone.

在文件 Definitions.cpp 第 335 行定义.

引用了 type.

◆ reference()

DefinitionRef eve::definitions::DefinitionRegistry::reference ( const std::string &  type,
const std::string &  id 
) const

Creates a reload-safe logical reference containing only type and id.

在文件 Definitions.cpp 第 343 行定义.

引用了 type.

◆ remove()

eve::Result< DefinitionHandle > eve::definitions::DefinitionRegistry::remove ( const std::string &  type,
const std::string &  id 
)

◆ replace()

eve::Result< DefinitionHandle > eve::definitions::DefinitionRegistry::replace ( const std::string &  type,
const std::string &  id,
int  version,
const std::string &  json 
)

◆ resolve()

eve::ResultRef< const Definition > eve::definitions::DefinitionRegistry::resolve ( const std::string &  type,
const std::string &  id 
) const

◆ resolveHandle()

◆ restoreJson()

◆ restoreSnapshot()

eve::Result< void > eve::definitions::DefinitionRegistry::restoreSnapshot ( const eve::SnapshotEnvelope &  snapshot,
const eve::SnapshotHashProvider &  hashProvider 
)

Restores a verified or migratable snapshot transactionally.

参数
snapshotSource envelope. Its schema must be definitions:registry.
hashProviderExplicit provider used to verify and reseal the payload.
返回
Success, or a failure leaving all registry state unchanged.

在文件 Definitions.cpp 第 583 行定义.

引用了 eve::Conflict, eve::Diagnostic::error(), eve::Result< T >::failure(), eve::InvalidArgument, eve::detail::Id128< Tag >::isNil(), payload, restoreJson(), source, eve::Result< T >::success() , 以及 eve::validateSnapshotPayloadMetadata().

被这些函数引用 restoreSnapshotJson().

◆ restoreSnapshotJson()

eve::Result< void > eve::definitions::DefinitionRegistry::restoreSnapshotJson ( std::string_view  json,
const eve::SnapshotHashProvider &  hashProvider 
)

Parses and transactionally restores a common snapshot envelope.

参数
jsonCanonical snapshot envelope JSON.
hashProviderExplicit provider used to verify contentHash.
返回
Success, or a failure leaving all registry state unchanged.

在文件 Definitions.cpp 第 618 行定义.

引用了 eve::Result< T >::failure(), eve::parseSnapshotEnvelope(), restoreSnapshot() , 以及 source.

◆ size()

int eve::definitions::DefinitionRegistry::size ( ) const

Returns the total number of definitions.

在文件 Definitions.cpp 第 347 行定义.

引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::size().

◆ snapshot()

eve::Result< eve::SnapshotEnvelope > eve::definitions::DefinitionRegistry::snapshot ( const eve::SnapshotHashProvider &  hashProvider) const

Captures this registry in the common versioned snapshot envelope.

参数
hashProviderExplicit content-digest provider; it is never defaulted silently.
返回
A sealed snapshot, or a structured serialization/hash failure.

在文件 Definitions.cpp 第 576 行定义.

引用了 eve::Result< T >::failure(), eve::Value::fromJson(), eve::makeSnapshotEnvelope(), payload , 以及 snapshotJson().

被这些函数引用 snapshotEnvelopeJson().

◆ snapshotEnvelopeJson()

eve::Result< std::string > eve::definitions::DefinitionRegistry::snapshotEnvelopeJson ( const eve::SnapshotHashProvider &  hashProvider) const

Serializes the common snapshot envelope as canonical JSON.

参数
hashProviderExplicit content-digest provider.
返回
Canonical envelope JSON or a structured failure.

在文件 Definitions.cpp 第 611 行定义.

引用了 eve::Result< T >::failure(), eve::serializeSnapshotEnvelope(), snapshot() , 以及 value.

◆ snapshotJson()

std::string eve::definitions::DefinitionRegistry::snapshotJson ( ) const

◆ subscribe()

eve::Subscription eve::definitions::DefinitionRegistry::subscribe ( ChangeCallback  callback)

Subscribes to successful definition register, replace and remove operations.

参数
callbackSynchronously invoked after the registry state and event sequence have been updated. The callback receives a borrowed immutable event valid only for the callback call.
返回
Move-only token that cancels this registration on destruction.
警告
The registry and token are thread-affine. Subscribe, dispose, and registry mutations must run on the registry owner thread.
Callback dispatch is reentrant: a callback may add or remove subscriptions and may perform another registry operation. No registry lock is held while the callback runs.
备注
A successful restoreJson() is a bulk replacement and does not synthesize per-definition events; callers must re-query after restore because previously borrowed Definition references expire.

在文件 Definitions.cpp 第 625 行定义.

引用了 callback , 以及 eve::VersionedRegistry< Key, Value, EventData, Compare >::subscribe().


该类的文档由以下文件生成: