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
| using eve::definitions::DefinitionRegistry::ChangeCallback = std::function<void(const DefinitionEvent&)> |
在文件 Definitions.h 第 66 行定义.
构造及析构函数说明
◆ DefinitionRegistry()
|
explicit |
Creates a definition registry with an optional persistent identity.
- 参数
-
instanceId Identity 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 |
Returns a definition by id order within one type, or nullptr.
在文件 Definitions.cpp 第 364 行定义.
引用了 eve::VersionedRegistry< Key, Value, EventData, Compare >::at(), index, key, eve::VersionedRegistry< Key, Value, EventData, Compare >::keyAt(), position , 以及 type.
被这些函数引用 eve::vehicle::Vehicle::clearVehicleDefinitions() , 以及 eve::weapon::Weapon::clearWeaponDefinitions().
◆ 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 |
Returns the number of definitions registered for a type.
在文件 Definitions.cpp 第 349 行定义.
引用了 index, key, eve::VersionedRegistry< Key, Value, EventData, Compare >::keyAt() , 以及 type.
被这些函数引用 eve::vehicle::Vehicle::clearVehicleDefinitions(), eve::weapon::Weapon::clearWeaponDefinitions(), eve::vehicle::Vehicle::getVehicleDefinitionCount() , 以及 eve::weapon::Weapon::getWeaponDefinitionCount().
◆ 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 | ||
| ) |
Inserts a definition using the common generation-qualified registry.
- 返回
- The new handle, or a structured validation/conflict failure.
在文件 Definitions.cpp 第 257 行定义.
引用了 eve::Result< T >::failure(), handle, eve::detail::StrongUint64< Tag >::incremented(), eve::VersionedRegistry< Key, Value, EventData, Compare >::insert(), eve::Result< T >::success(), type , 以及 value.
被这些函数引用 eve::rts::RTSContentLoader::load(), eve::definitions_editing::DefinitionRuntimePublisher::publish(), eve::vehicle::Vehicle::registerVehiclesFromJson() , 以及 eve::weapon::Weapon::registerWeaponsFromJson().
◆ isStale()
|
noexcept |
◆ isTombstone()
|
noexcept |
◆ 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 | ||
| ) |
Removes a definition and returns the retained tombstone handle.
- 返回
- A stale tombstone handle, or a structured failure.
在文件 Definitions.cpp 第 295 行定义.
引用了 current, eve::Result< T >::failure(), handle, eve::detail::StrongUint64< Tag >::incremented(), key, eve::VersionedRegistry< Key, Value, EventData, Compare >::remove(), eve::VersionedRegistry< Key, Value, EventData, Compare >::resolve(), eve::Result< T >::success() , 以及 type.
被这些函数引用 eve::vehicle::Vehicle::clearVehicleDefinitions() , 以及 eve::weapon::Weapon::clearWeaponDefinitions().
◆ replace()
| eve::Result< DefinitionHandle > eve::definitions::DefinitionRegistry::replace | ( | const std::string & | type, |
| const std::string & | id, | ||
| int | version, | ||
| const std::string & | json | ||
| ) |
Replaces a live definition and invalidates its previous handle.
- 返回
- The replacement handle, or a structured failure.
在文件 Definitions.cpp 第 276 行定义.
引用了 eve::Result< T >::failure(), handle, eve::detail::StrongUint64< Tag >::incremented(), eve::VersionedRegistry< Key, Value, EventData, Compare >::replace(), eve::Result< T >::success(), type , 以及 value.
被这些函数引用 eve::rts::RTSContentLoader::load(), eve::definitions_editing::DefinitionRuntimePublisher::publish(), eve::vehicle::Vehicle::registerVehiclesFromJson() , 以及 eve::weapon::Weapon::registerWeaponsFromJson().
◆ resolve()
| eve::ResultRef< const Definition > eve::definitions::DefinitionRegistry::resolve | ( | const std::string & | type, |
| const std::string & | id | ||
| ) | const |
Resolves a definition through the common registry API.
- 返回
- A borrowed reference valid until the next registry mutation.
在文件 Definitions.cpp 第 313 行定义.
引用了 eve::Result< T >::failure(), eve::VersionedRegistry< Key, Value, EventData, Compare >::resolve(), eve::Result< T >::success() , 以及 type.
被这些函数引用 eve::vehicle::Vehicle::hasVehicleDefinition(), eve::weapon::Weapon::hasWeaponDefinition(), eve::vehicle::Vehicle::registerVehiclesFromJson() , 以及 eve::weapon::Weapon::registerWeaponsFromJson().
◆ resolveHandle()
| eve::ResultRef< const Definition > eve::definitions::DefinitionRegistry::resolveHandle | ( | const DefinitionHandle & | handle | ) | const |
Resolves a generation-qualified handle and reports stale identities.
在文件 Definitions.cpp 第 319 行定义.
引用了 eve::Result< T >::failure(), handle, eve::VersionedRegistry< Key, Value, EventData, Compare >::resolve() , 以及 eve::Result< T >::success().
被这些函数引用 eve::rpg::SkillDefinitionRuntime::create(), eve::vehicle::VehicleDefinitionRuntime::create(), eve::rpg::SkillDefinitionRuntime::definition(), eve::vehicle::VehicleDefinitionRuntime::definition(), eve::rpg::SkillDefinitionRuntime::reload() , 以及 eve::vehicle::VehicleDefinitionRuntime::reload().
◆ restoreJson()
| eve::Result< void > eve::definitions::DefinitionRegistry::restoreJson | ( | const std::string & | json | ) |
Transactionally restores registry state from snapshotJson() output.
在文件 Definitions.cpp 第 445 行定义.
引用了 eve::Applied, definitions, eve::Diagnostic::error(), events, eve::Result< T >::failure(), eve::Value::fromJson(), generation, generations, eve::Value::getIf(), id, index, eve::Insert, eve::InvariantViolation, eve::detail::StrongUint64< Tag >::isZero(), key, name, eve::ParseError, eve::Remove, removed, eve::Replace, eve::VersionedRegistry< Key, Value, EventData, Compare >::restoreState(), root, sequence, eve::Status::success(), eve::Result< T >::success(), type, eve::detail::StrongUint64< Tag >::value() , 以及 value.
被这些函数引用 eve::rts::RTSContentLoader::load() , 以及 restoreSnapshot().
◆ restoreSnapshot()
| eve::Result< void > eve::definitions::DefinitionRegistry::restoreSnapshot | ( | const eve::SnapshotEnvelope & | snapshot, |
| const eve::SnapshotHashProvider & | hashProvider | ||
| ) |
Restores a verified or migratable snapshot transactionally.
- 参数
-
snapshot Source envelope. Its schema must be definitions:registry.hashProvider Explicit 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.
- 参数
-
json Canonical snapshot envelope JSON. hashProvider Explicit 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.
- 参数
-
hashProvider Explicit 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.
- 参数
-
hashProvider Explicit 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 |
Exports all registry state as deterministic canonical JSON.
在文件 Definitions.cpp 第 395 行定义.
引用了 definitions, eve::VersionedRegistry< Key, Value, EventData, Compare >::eventCount(), events, generation, generations, key, root, eve::VersionedRegistry< Key, Value, EventData, Compare >::size(), eve::VersionedRegistry< Key, Value, EventData, Compare >::snapshotState(), state , 以及 eve::Value::toJson().
被这些函数引用 eve::rts::RTSContentLoader::load() , 以及 snapshot().
◆ subscribe()
| eve::Subscription eve::definitions::DefinitionRegistry::subscribe | ( | ChangeCallback | callback | ) |
Subscribes to successful definition register, replace and remove operations.
- 参数
-
callback Synchronously 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().
该类的文档由以下文件生成:
- src/modules/definitions/Definitions.h
- src/modules/definitions/Definitions.cpp