|
libxr
1.0
Want to be the best embedded framework
|
槽索引必须是整数类型。 Slot indices must use an integral type. More...
#include <object_pool.hpp>
Public Member Functions | |
| Handle ()=default | |
| 构造一个空 handle。 | |
| Handle (BasicObjectPool *pool, IndexType index) | |
| 用指定 pool 和槽位索引构造 handle。 | |
| Handle (const Handle &)=delete | |
| 禁止拷贝构造。 Non-copyable. | |
| Handle & | operator= (const Handle &)=delete |
| 禁止拷贝赋值。 Non-copy-assignable. | |
| Handle (Handle &&other) noexcept | |
| 移动构造 handle,并转移槽位所有权。 | |
| Handle & | operator= (Handle &&other) noexcept |
| 移动赋值 handle,并转移槽位所有权。 | |
| ~Handle () | |
| 析构 handle,并自动归还槽位。 | |
| bool | Valid () const |
| 判断当前 handle 是否持有有效槽位。 | |
| Data & | Get () |
| 返回当前槽位对象的可写引用。 | |
| const Data & | Get () const |
| 返回当前槽位对象的只读引用。 | |
| Data * | operator-> () |
| 以指针形式访问当前槽位对象。 | |
| const Data * | operator-> () const |
| 以只读指针形式访问当前槽位对象。 | |
| Data & | operator* () |
| 解引用当前槽位对象。 | |
| const Data & | operator* () const |
| 只读解引用当前槽位对象。 | |
| IndexType | Index () const |
| 返回当前持有的槽位索引。 | |
| void | Reset () |
| 主动归还当前槽位,并使 handle 失效。 | |
Private Attributes | |
| BasicObjectPool * | pool_ = nullptr |
| 所属对象池。 Owning object pool. | |
| IndexType | index_ = {} |
| 当前槽位索引。 Current slot index. | |
槽索引必须是整数类型。 Slot indices must use an integral type.
槽索引必须是无符号整数类型。 Slot indices must use an unsigned integral type.
对象池槽位的 move-only RAII 句柄。
Move-only RAII handle for one object-pool slot.
句柄持有一个槽位索引及所属 pool 指针;析构时会自动把索引归还到空闲队列。 The handle stores one slot index plus its owning pool pointer, and returns the index to the free queue automatically on destruction.
Definition at line 81 of file object_pool.hpp.
|
default |
构造一个空 handle。
Construct an empty handle.
|
inline |
用指定 pool 和槽位索引构造 handle。
Construct a handle from the given pool and slot index.
| pool | 所属对象池。 Owning object pool. |
| index | 槽位索引。 Slot index. |
Definition at line 96 of file object_pool.hpp.
|
inlinenoexcept |
移动构造 handle,并转移槽位所有权。
Move-construct the handle and transfer slot ownership.
| other | 被转移的源 handle。 Source handle being moved from. |
Definition at line 108 of file object_pool.hpp.
|
inline |
析构 handle,并自动归还槽位。
Destroy the handle and return the slot automatically.
Definition at line 137 of file object_pool.hpp.
|
inlinenodiscard |
返回当前槽位对象的可写引用。
Return a writable reference to the current slot object.
Definition at line 152 of file object_pool.hpp.
|
inlinenodiscard |
|
inlinenodiscard |
返回当前持有的槽位索引。
Return the currently owned slot index.
Definition at line 202 of file object_pool.hpp.
|
inlinenodiscard |
解引用当前槽位对象。
Dereference the current slot object.
Definition at line 188 of file object_pool.hpp.
|
inlinenodiscard |
只读解引用当前槽位对象。
Dereference the current slot object as const.
Definition at line 195 of file object_pool.hpp.
|
inlinenodiscard |
以指针形式访问当前槽位对象。
Access the current slot object as a pointer.
Definition at line 174 of file object_pool.hpp.
|
inlinenodiscard |
以只读指针形式访问当前槽位对象。
Access the current slot object as a const pointer.
Definition at line 181 of file object_pool.hpp.
|
inlinenoexcept |
移动赋值 handle,并转移槽位所有权。
Move-assign the handle and transfer slot ownership.
| other | 被转移的源 handle。 Source handle being moved from. |
Definition at line 120 of file object_pool.hpp.
|
inline |
主动归还当前槽位,并使 handle 失效。
Return the current slot explicitly and invalidate the handle.
Definition at line 212 of file object_pool.hpp.
|
inlinenodiscard |
判断当前 handle 是否持有有效槽位。
Return whether this handle currently owns a valid slot.
true,否则返回 false。 Returns true when this handle owns a valid slot, otherwise false. Definition at line 145 of file object_pool.hpp.
|
private |
|
private |
所属对象池。 Owning object pool.
Definition at line 226 of file object_pool.hpp.