载入中...
搜索中...
未找到
eve::definition::RuntimeInstance< State > 模板类 参考

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.
 

详细描述

template<class State>
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.

模板参数
StateDomain-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

template<class State >
using eve::definition::RuntimeInstance< State >::RebuildFunction = std::function<eve::Result<State>(const State&, const InstanceIdentity&, const DefinitionHandle&)>

在文件 DefinitionRuntime.h 第 296 行定义.

构造及析构函数说明

◆ RuntimeInstance() [1/2]

template<class State >
eve::definition::RuntimeInstance< State >::RuntimeInstance ( const RuntimeInstance< State > &  )
default

Copy a typed runtime instance.

◆ RuntimeInstance() [2/2]

template<class State >
eve::definition::RuntimeInstance< State >::RuntimeInstance ( RuntimeInstance< State > &&  )
defaultnoexcept

Move a typed runtime instance.

◆ ~RuntimeInstance()

template<class State >
eve::definition::RuntimeInstance< State >::~RuntimeInstance ( )
default

Destroy a typed runtime instance.

成员函数说明

◆ checkDefinition()

template<class State >
eve::Result< void > eve::definition::RuntimeInstance< State >::checkDefinition ( const DefinitionHandle &  handle) const
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()

template<class State >
static eve::Result< RuntimeInstance > eve::definition::RuntimeInstance< State >::create ( eve::PersistentId  instanceId,
eve::DefinitionRef  definition,
eve::Generation  definitionGeneration,
State  state,
bool  active = true 
)
inlinestatic

◆ identity()

template<class State >
const InstanceIdentity & eve::definition::RuntimeInstance< State >::identity ( ) const
inlinenoexcept

◆ isActive()

template<class State >
bool eve::definition::RuntimeInstance< State >::isActive ( ) const
inlinenoexcept

Whether the instance participates in active simulation.

在文件 DefinitionRuntime.h 第 340 行定义.

引用了 eve::definition::RuntimeInstanceCore::isActive().

◆ operator=() [1/2]

template<class State >
RuntimeInstance & eve::definition::RuntimeInstance< State >::operator= ( const RuntimeInstance< State > &  )
default

Copy-assign a typed runtime instance.

◆ operator=() [2/2]

template<class State >
RuntimeInstance & eve::definition::RuntimeInstance< State >::operator= ( RuntimeInstance< State > &&  )
defaultnoexcept

Move-assign a typed runtime instance.

◆ reload()

template<class State >
eve::Result< ReloadOutcome > eve::definition::RuntimeInstance< State >::reload ( const DefinitionHandle &  next,
ReloadPolicy  policy,
const State &  defaults,
RebuildFunction  rebuild = {} 
)
inline

Apply a definition replacement with an atomic typed-state policy.

参数
nextExact current handle returned by the DefinitionRegistry.
policyPolicy to execute for this instance.
defaultsTyped defaults parsed from next; used only by ReapplyDefaults.
rebuildCallback 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()

template<class State >
eve::Result< void > eve::definition::RuntimeInstance< State >::restoreExact ( const InstanceIdentity &  identity,
State  state,
bool  active 
)
inline

Restore an already validated snapshot of this exact instance.

参数
identitySnapshot identity; it must exactly match the current instance identity, including definition generation.
stateFully decoded candidate state. The core adopts it and destroys it when the identity does not match.
activeActive 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()

template<class State >
void eve::definition::RuntimeInstance< State >::setActive ( bool  active)
inlinenoexcept

Set active state; this does not reload or rebuild the instance.

在文件 DefinitionRuntime.h 第 342 行定义.

引用了 active , 以及 eve::definition::RuntimeInstanceCore::setActive().

◆ state() [1/2]

template<class State >
const State & eve::definition::RuntimeInstance< State >::state ( ) const
inlinenoexcept

◆ state() [2/2]

template<class State >
State & eve::definition::RuntimeInstance< State >::state ( )
inlinenoexcept

Mutate typed state on the owning domain thread.

在文件 DefinitionRuntime.h 第 338 行定义.

引用了 eve::definition::RuntimeInstanceCore::state().


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