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. | |
详细描述
class eve::script::RuntimeObjectRegistry< T, Tag >
Slot/generation registry whose objects are exclusively unique-owned.
- 模板参数
-
T Non-ECS object type stored in slots. Tag Empty 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
| using eve::script::RuntimeObjectRegistry< T, Tag >::Handle = RuntimeHandle<Tag> |
在文件 RuntimeRegistry.h 第 361 行定义.
◆ Ref
| using eve::script::RuntimeObjectRegistry< T, Tag >::Ref = RuntimeHandleRef<Tag> |
在文件 RuntimeRegistry.h 第 362 行定义.
构造及析构函数说明
◆ RuntimeObjectRegistry() [1/3]
|
inline |
Creates an empty registry with a unique owner-lifetime epoch.
在文件 RuntimeRegistry.h 第 365 行定义.
引用了 detail.
◆ RuntimeObjectRegistry() [2/3]
|
delete |
◆ RuntimeObjectRegistry() [3/3]
|
defaultnoexcept |
Constructs a RuntimeObjectRegistry.
成员函数说明
◆ clear()
|
inline |
Invalidates all slots and releases every unique-owned object.
在文件 RuntimeRegistry.h 第 481 行定义.
◆ emplace()
|
inline |
Transfers one unique-owned object into a fresh registry slot.
- 参数
-
object Non-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()
|
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]
|
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.
- 参数
-
visit Callable taking (std::uint32_t index, T& object). @ownership The registry keeps sole ownership;visitnever 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]
|
inline |
Read-only overload: the callback receives const T&.
For each live.
Visit.
在文件 RuntimeRegistry.h 第 473 行定义.
引用了 index.
◆ isStale()
|
inlinenoexcept |
Reports whether a non-invalid handle can no longer resolve.
在文件 RuntimeRegistry.h 第 446 行定义.
◆ operator=() [1/2]
|
delete |
◆ operator=() [2/2]
|
defaultnoexcept |
Operator =.
◆ ownerEpoch()
|
inlinenoexcept |
Returns the non-reusable lifetime epoch of this registry.
在文件 RuntimeRegistry.h 第 484 行定义.
◆ pin()
|
inline |
Keeps one entry alive until the returned pin is released.
- 参数
-
ref Reference 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]
|
inlinenoexcept |
Const overload of resolve(); see the non-const form for its contract.
在文件 RuntimeRegistry.h 第 414 行定义.
◆ resolve() [2/2]
|
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 行定义.
该类的文档由以下文件生成:
- src/engine/common/RuntimeRegistry.h