载入中...
搜索中...
未找到
eve::script::RuntimeObjectRegistry< T, Tag > 模板类 参考

Slot/generation registry whose objects are exclusively unique-owned. 更多...

#include <RuntimeRegistry.h>

Public 类型

using Handle = RuntimeHandle< Tag >
 
using Ref = RuntimeHandleRef< Tag >
 

Public 成员函数

 RuntimeObjectRegistry ()
 Creates an empty registry with a unique owner-lifetime epoch.
 
 RuntimeObjectRegistry (const RuntimeObjectRegistry &)=delete
 
RuntimeObjectRegistry & operator= (const RuntimeObjectRegistry &)=delete
 
 RuntimeObjectRegistry (RuntimeObjectRegistry &&) noexcept=default
 Constructs a RuntimeObjectRegistry.
 
RuntimeObjectRegistry & operator= (RuntimeObjectRegistry &&) noexcept=default
 Operator =.
 
eve::Result< Ref > emplace (Owned< T > object)
 Transfers one unique-owned object into a fresh registry slot.
 
Borrowed< T > resolve (Ref ref) noexcept
 Resolves a live object as a non-owning observation.
 
Borrowed< const T > resolve (Ref ref) const noexcept
 Const overload of resolve(); see the non-const form for its contract.
 
eve::Result< void > erase (Ref ref)
 Destroys the object identified by a live handle.
 
eve::Result< RuntimePin< T, Tag > > pin (Ref ref)
 Keeps one entry alive until the returned pin is released.
 
bool isStale (Ref ref) const noexcept
 Reports whether a non-invalid handle can no longer resolve.
 
template<class F >
void forEachLive (F &&visit)
 Visit every live object with its slot index, in slot order.
 
template<class F >
void forEachLive (F &&visit) const
 Read-only overload: the callback receives const T&.
 
void clear ()
 Invalidates all slots and releases every unique-owned object.
 
std::uint64_t ownerEpoch () const noexcept
 Returns the non-reusable lifetime epoch of this registry.
 

详细描述

template<class T, class Tag>
class eve::script::RuntimeObjectRegistry< T, Tag >

Slot/generation registry whose objects are exclusively unique-owned.

模板参数
TNon-ECS object type stored in slots.
TagEmpty tag making the handle type domain-specific.

All methods are owner-thread-affine. resolve() returns Borrowed and never extends object lifetime. clear() and destruction invalidate every prior handle; a new registry instance receives a distinct owner epoch.

备注
Only the coordinate arithmetic in Ref and the pointer cast are per-(T, Tag); the store below performs the bookkeeping once.

RuntimeObjectRegistry public API.

在文件 RuntimeRegistry.h 第 359 行定义.

成员类型定义说明

◆ Handle

template<class T , class Tag >
using eve::script::RuntimeObjectRegistry< T, Tag >::Handle = RuntimeHandle<Tag>

在文件 RuntimeRegistry.h 第 361 行定义.

◆ Ref

template<class T , class Tag >
using eve::script::RuntimeObjectRegistry< T, Tag >::Ref = RuntimeHandleRef<Tag>

在文件 RuntimeRegistry.h 第 362 行定义.

构造及析构函数说明

◆ RuntimeObjectRegistry() [1/3]

template<class T , class Tag >
eve::script::RuntimeObjectRegistry< T, Tag >::RuntimeObjectRegistry ( )
inline

Creates an empty registry with a unique owner-lifetime epoch.

在文件 RuntimeRegistry.h 第 365 行定义.

引用了 detail.

◆ RuntimeObjectRegistry() [2/3]

template<class T , class Tag >
eve::script::RuntimeObjectRegistry< T, Tag >::RuntimeObjectRegistry ( const RuntimeObjectRegistry< T, Tag > &  )
delete

◆ RuntimeObjectRegistry() [3/3]

template<class T , class Tag >
eve::script::RuntimeObjectRegistry< T, Tag >::RuntimeObjectRegistry ( RuntimeObjectRegistry< T, Tag > &&  )
defaultnoexcept

Constructs a RuntimeObjectRegistry.

成员函数说明

◆ clear()

template<class T , class Tag >
void eve::script::RuntimeObjectRegistry< T, Tag >::clear ( )
inline

Invalidates all slots and releases every unique-owned object.

在文件 RuntimeRegistry.h 第 481 行定义.

◆ emplace()

template<class T , class Tag >
eve::Result< Ref > eve::script::RuntimeObjectRegistry< T, Tag >::emplace ( Owned< T >  object)
inline

Transfers one unique-owned object into a fresh registry slot.

参数
objectNon-null object whose destruction becomes registry-owned.
返回
Generation-qualified handle and owner epoch.

Failure.

Success.

在文件 RuntimeRegistry.h 第 381 行定义.

引用了 eve::Diagnostic::error(), eve::Result< T >::failure(), eve::script::detail::RuntimeSlotCoordinates::generation, eve::script::detail::RuntimeSlotCoordinates::index, eve::InvalidArgument , 以及 eve::Result< T >::success().

◆ erase()

template<class T , class Tag >
eve::Result< void > eve::script::RuntimeObjectRegistry< T, Tag >::erase ( Ref  ref)
inline

Destroys the object identified by a live handle.

返回
Applied, or StaleHandle/InvalidArgument/Failed.
备注
When a pin still holds the object, the handle becomes stale at once but the object is destroyed only when the last pin is released.

在文件 RuntimeRegistry.h 第 426 行定义.

引用了 eve::script::RuntimeHandleRef< Tag >::handle , 以及 eve::script::RuntimeHandleRef< Tag >::ownerEpoch.

◆ forEachLive() [1/2]

template<class T , class Tag >
template<class F >
void eve::script::RuntimeObjectRegistry< T, Tag >::forEachLive ( F &&  visit)
inline

Visit every live object with its slot index, in slot order.

Exists for diagnostics and automation surfaces that must enumerate owned objects - a debug tool cannot know the handles a game script created. The callback receives a non-owning observation valid only for the duration of the call; it must not retain the reference or release objects.

参数
visitCallable taking (std::uint32_t index, T& object). @ownership The registry keeps sole ownership; visit never receives one. @lifetime The observed object is valid only inside the call. @thread Owner thread only; the callback runs under no lock and must not re-enter the registry.

For each live.

在文件 RuntimeRegistry.h 第 465 行定义.

引用了 index.

◆ forEachLive() [2/2]

template<class T , class Tag >
template<class F >
void eve::script::RuntimeObjectRegistry< T, Tag >::forEachLive ( F &&  visit) const
inline

Read-only overload: the callback receives const T&.

For each live.

Visit.

在文件 RuntimeRegistry.h 第 473 行定义.

引用了 index.

◆ isStale()

template<class T , class Tag >
bool eve::script::RuntimeObjectRegistry< T, Tag >::isStale ( Ref  ref) const
inlinenoexcept

Reports whether a non-invalid handle can no longer resolve.

在文件 RuntimeRegistry.h 第 446 行定义.

◆ operator=() [1/2]

template<class T , class Tag >
RuntimeObjectRegistry & eve::script::RuntimeObjectRegistry< T, Tag >::operator= ( const RuntimeObjectRegistry< T, Tag > &  )
delete

◆ operator=() [2/2]

template<class T , class Tag >
RuntimeObjectRegistry & eve::script::RuntimeObjectRegistry< T, Tag >::operator= ( RuntimeObjectRegistry< T, Tag > &&  )
defaultnoexcept

Operator =.

◆ ownerEpoch()

template<class T , class Tag >
std::uint64_t eve::script::RuntimeObjectRegistry< T, Tag >::ownerEpoch ( ) const
inlinenoexcept

Returns the non-reusable lifetime epoch of this registry.

在文件 RuntimeRegistry.h 第 484 行定义.

◆ pin()

template<class T , class Tag >
eve::Result< RuntimePin< T, Tag > > eve::script::RuntimeObjectRegistry< T, Tag >::pin ( Ref  ref)
inline

Keeps one entry alive until the returned pin is released.

参数
refReference returned by emplace().
返回
A move-only keep-alive pin, or a stale-handle failure. @ownership The registry keeps owning the object; the pin postpones its destruction across erase()/clear(). @lifetime The pin must not outlive this registry. @thread Owner-thread-affine; no synchronization is provided.

在文件 RuntimeRegistry.h 第 439 行定义.

引用了 eve::script::RuntimeHandleRef< Tag >::handle, ok, eve::script::RuntimeHandleRef< Tag >::ownerEpoch , 以及 status.

◆ resolve() [1/2]

template<class T , class Tag >
Borrowed< const T > eve::script::RuntimeObjectRegistry< T, Tag >::resolve ( Ref  ref) const
inlinenoexcept

Const overload of resolve(); see the non-const form for its contract.

在文件 RuntimeRegistry.h 第 414 行定义.

◆ resolve() [2/2]

template<class T , class Tag >
Borrowed< T > eve::script::RuntimeObjectRegistry< T, Tag >::resolve ( Ref  ref)
inlinenoexcept

Resolves a live object as a non-owning observation.

返回
An empty Borrowed value when the generation/owner epoch is stale; otherwise a borrowed observation owned by this registry. @ownership Borrowed; the registry remains responsible for destruction. @nullable The returned Borrowed may be unbound. @lifetime Valid until registry mutation, clear, destruction or owner-epoch change; never retain it across those boundaries. @thread Owner-thread-affine; no synchronization is provided. @reentrancy Side-effect free and does not invoke callbacks.

在文件 RuntimeRegistry.h 第 407 行定义.


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