|
dxFeed Graal CXX API v8.1.0
|
Thread-safe registry that associates callback identifiers with entities without owning them. More...
#include <EntityManager.hpp>
Public Types | |
| using | EntityType = EntityType_ |
| The registered entity type. | |
| using | EntityIdType = EntityIdType_ |
| The type whose identifier domain is used by the registry. | |
Public Member Functions | |
| WeakEntityManager ()=default | |
| Constructs an empty weak entity registry. | |
| Id< EntityIdType > | registerEntity (const std::shared_ptr< EntityType > &entity) |
| Registers an entity and returns its callback identifier. | |
| std::size_t | getLastId () |
| bool | unregisterEntity (const std::shared_ptr< EntityType > &entity) |
| Unregisters an entity. | |
| bool | unregisterEntity (Id< EntityIdType > id) |
| Unregisters an entity by identifier. | |
| template<typename H> | |
| bool | unregisterEntity (H *handle) |
| Unregisters an entity using an opaque callback handle. | |
| template<typename H> | |
| bool | unregisterEntity (const H *handle) |
| Unregisters an entity using a constant opaque callback handle. | |
| std::shared_ptr< EntityType > | getEntity (Id< EntityIdType > id) |
| Locks and returns the entity registered for an identifier. | |
| template<typename H> | |
| std::shared_ptr< EntityType > | getEntity (H *handle) |
| Locks and returns the entity identified by an opaque callback handle. | |
| template<typename H> | |
| std::shared_ptr< EntityType > | getEntity (const H *handle) |
| Locks and returns the entity identified by a constant opaque callback handle. | |
| bool | contains (Id< EntityIdType > id) |
| std::optional< Id< EntityIdType > > | getId (const std::shared_ptr< EntityType > &entity) |
| bool | contains (const std::shared_ptr< EntityType > &entity) |
Thread-safe registry that associates callback identifiers with entities without owning them.
A callback obtains a temporary shared pointer with getEntity(), so an entity cannot be destroyed while that callback is using it. Unlike EntityManager, this registry does not keep an otherwise unused entity alive. Expired entries are removed lazily during lookups and explicitly by entity destructors.
| EntityType_ | The registered entity type. |
| EntityIdType_ | The type used to distinguish the identifier domain. |
|
inline |
true if the entity is currently registered and alive.
|
inline |
true if the identifier currently refers to a live entity.
|
inline |
Locks and returns the entity identified by a constant opaque callback handle.
| H | The callback handle type. |
| handle | The handle containing the registration identifier. |
|
inline |
Locks and returns the entity identified by an opaque callback handle.
| H | The callback handle type. |
| handle | The handle containing the registration identifier. |
|
inline |
Locks and returns the entity registered for an identifier.
The returned shared pointer keeps the entity alive until the caller finishes using it.
| id | The registration identifier. |
|
inline |
|
inline |
|
inline |
Registers an entity and returns its callback identifier.
Registering the same live entity more than once returns its existing identifier.
| entity | The entity to register. |
|
inline |
Unregisters an entity using a constant opaque callback handle.
| H | The callback handle type. |
| handle | The handle containing the registration identifier. |
true if a registration was removed.
|
inline |
Unregisters an entity.
| entity | The entity to unregister. |
true if a registration was removed.
|
inline |
Unregisters an entity using an opaque callback handle.
| H | The callback handle type. |
| handle | The handle containing the registration identifier. |
true if a registration was removed.
|
inline |
Unregisters an entity by identifier.
| id | The registration identifier. |
true if a registration was removed.