Owns one strongly typed runtime state and its definition identity. 更多...
#include <DefinitionRuntime.h>
Public 类型 | |
| using | RebuildFunction = std::function< eve::Result< State >(const State &, const InstanceIdentity &, const DefinitionHandle &)> |
Public 成员函数 | |
| RuntimeInstance (const RuntimeInstance &)=default | |
| Copy a typed runtime instance. | |
| RuntimeInstance & | operator= (const RuntimeInstance &)=default |
| Copy-assign a typed runtime instance. | |
| RuntimeInstance (RuntimeInstance &&) noexcept=default | |
| Move a typed runtime instance. | |
| RuntimeInstance & | operator= (RuntimeInstance &&) noexcept=default |
| Move-assign a typed runtime instance. | |
| ~RuntimeInstance ()=default | |
| Destroy a typed runtime instance. | |
| const InstanceIdentity & | identity () const noexcept |
| Borrow the complete immutable identity. | |
| const State & | state () const noexcept |
| Borrow the current typed state. | |
| State & | state () noexcept |
| Mutate typed state on the owning domain thread. | |
| bool | isActive () const noexcept |
| Whether the instance participates in active simulation. | |
| void | setActive (bool active) noexcept |
| Set active state; this does not reload or rebuild the instance. | |
| eve::Result< void > | checkDefinition (const DefinitionHandle &handle) const |
| Verify that a caller's definition handle is the exact current incarnation. | |
| eve::Result< ReloadOutcome > | reload (const DefinitionHandle &next, ReloadPolicy policy, const State &defaults, RebuildFunction rebuild={}) |
| Apply a definition replacement with an atomic typed-state policy. | |
| eve::Result< void > | restoreExact (const InstanceIdentity &identity, State state, bool active) |
| Restore an already validated snapshot of this exact instance. | |
静态 Public 成员函数 | |
| static eve::Result< RuntimeInstance > | create (eve::PersistentId instanceId, eve::DefinitionRef definition, eve::Generation definitionGeneration, State state, bool active=true) |
| Construct a runtime instance after validating its identity. | |
详细描述
class eve::definition::RuntimeInstance< State >
Owns one strongly typed runtime state and its definition identity.
State is supplied by a domain adapter; the typed accessors below keep it strongly typed, and only the shared bookkeeping is type-erased into RuntimeInstanceCore. Reload first prepares a complete candidate state and then swaps it at one commit boundary. A parser, default factory or rebuild callback failure therefore leaves both state and identity unchanged.
The object is confined to its owning simulation/domain thread. Callbacks run synchronously without an internal lock and must not retain references to the instance. The instance itself owns state(); references returned by that accessor are borrowed until the next successful reload or destruction.
- 模板参数
-
State Domain-specific, copyable runtime state. Candidate state is prepared behind an owning pointer so the commit itself is a non-throwing pointer swap.
RuntimeInstance public API.
在文件 DefinitionRuntime.h 第 292 行定义.
成员类型定义说明
◆ RebuildFunction
| using eve::definition::RuntimeInstance< State >::RebuildFunction = std::function<eve::Result<State>(const State&, const InstanceIdentity&, const DefinitionHandle&)> |
在文件 DefinitionRuntime.h 第 296 行定义.
构造及析构函数说明
◆ RuntimeInstance() [1/2]
|
default |
Copy a typed runtime instance.
◆ RuntimeInstance() [2/2]
|
defaultnoexcept |
Move a typed runtime instance.
◆ ~RuntimeInstance()
|
default |
Destroy a typed runtime instance.
成员函数说明
◆ checkDefinition()
|
inline |
Verify that a caller's definition handle is the exact current incarnation.
- 返回
- Success for an exact match, or StaleHandle/invalid-argument otherwise.
在文件 DefinitionRuntime.h 第 348 行定义.
引用了 eve::definition::RuntimeInstanceCore::checkDefinition() , 以及 handle.
◆ create()
|
inlinestatic |
Construct a runtime instance after validating its identity.
- 返回
- An owning typed instance or a structured invalid-identity error.
Success.
Constructs a RuntimeInstance.
在文件 DefinitionRuntime.h 第 321 行定义.
引用了 active, eve::definition::InstanceIdentity::create(), eve::Result< T >::failure(), eve::definition::RuntimeInstance< State >::identity(), eve::definition::RuntimeInstance< State >::state() , 以及 eve::Result< T >::success().
被这些函数引用 eve::card::CardDefinitionRuntime::create(), eve::rpg::SkillDefinitionRuntime::create(), eve::vehicle::VehicleDefinitionRuntime::create(), eve::weapon::WeaponDefinitionRuntime::create() , 以及 eve::effects::EffectDefinitionRuntime::create().
◆ identity()
|
inlinenoexcept |
Borrow the complete immutable identity.
在文件 DefinitionRuntime.h 第 334 行定义.
引用了 eve::definition::RuntimeInstanceCore::identity().
被这些函数引用 eve::definition::RuntimeInstance< State >::create() , 以及 eve::definition::RuntimeInstance< State >::restoreExact().
◆ isActive()
|
inlinenoexcept |
Whether the instance participates in active simulation.
在文件 DefinitionRuntime.h 第 340 行定义.
◆ operator=() [1/2]
|
default |
Copy-assign a typed runtime instance.
◆ operator=() [2/2]
|
defaultnoexcept |
Move-assign a typed runtime instance.
◆ reload()
|
inline |
Apply a definition replacement with an atomic typed-state policy.
- 参数
-
next Exact current handle returned by the DefinitionRegistry. policy Policy to execute for this instance. defaults Typed defaults parsed from next; used only by ReapplyDefaults.rebuild Callback used only by RebuildInstance. It returns a fully prepared State and may inspect the old state and new handle.
- 返回
- Reload transition, or a failure leaving state and identity intact.
Success.
在文件 DefinitionRuntime.h 第 362 行定义.
◆ restoreExact()
|
inline |
Restore an already validated snapshot of this exact instance.
- 参数
-
identity Snapshot identity; it must exactly match the current instance identity, including definition generation. state Fully decoded candidate state. The core adopts it and destroys it when the identity does not match. active Active flag restored with the state.
- 返回
- Success, or Conflict/StaleHandle when the snapshot belongs to a different instance or definition incarnation.
- 备注
- This deliberately does not permit changing identity. A caller that wants to apply a newer definition must first perform the normal reload protocol and then capture a new snapshot.
在文件 DefinitionRuntime.h 第 390 行定义.
引用了 active, eve::definition::RuntimeInstance< State >::identity(), eve::definition::RuntimeInstanceCore::restoreExact() , 以及 eve::definition::RuntimeInstance< State >::state().
◆ setActive()
|
inlinenoexcept |
Set active state; this does not reload or rebuild the instance.
在文件 DefinitionRuntime.h 第 342 行定义.
引用了 active , 以及 eve::definition::RuntimeInstanceCore::setActive().
◆ state() [1/2]
|
inlinenoexcept |
Borrow the current typed state.
在文件 DefinitionRuntime.h 第 336 行定义.
引用了 eve::definition::RuntimeInstanceCore::state().
被这些函数引用 eve::definition::RuntimeInstance< State >::create() , 以及 eve::definition::RuntimeInstance< State >::restoreExact().
◆ state() [2/2]
|
inlinenoexcept |
Mutate typed state on the owning domain thread.
在文件 DefinitionRuntime.h 第 338 行定义.
该类的文档由以下文件生成:
- src/engine/common/definitions/DefinitionRuntime.h