A thread-safe registry of AsyncNodes keyed by id.
More...
#include <cpp/a11/nodes/node_map.h>
A thread-safe registry of AsyncNodes keyed by id.
Nodes are created lazily on first access via the map's ChunkStoreFactory. Instances are heap-allocated and shared via Create.
◆ ~NodeMap()
| a11::nodes::NodeMap::~NodeMap |
( |
| ) |
|
|
default |
◆ Contains()
| bool a11::nodes::NodeMap::Contains |
( |
std::string_view |
node_id | ) |
const |
Report whether a node with the given id exists.
- Parameters
-
| node_id | The node identifier. |
- Returns
- True if the map holds a node under that id.
◆ Create()
Create a node map.
- Parameters
-
| factory | Factory invoked to build the backing store for each new node; a default store is used when omitted. |
- Returns
- The new map, or an error status on failure.
◆ Discard()
| absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::Discard |
( |
std::string_view |
node_id, |
|
|
const std::shared_ptr< AsyncNode > & |
expected = nullptr |
|
) |
| |
Remove the node for an id.
- Parameters
-
| node_id | The node identifier. |
| expected | If non-null, only remove when the stored node matches this one (compare-and-remove). |
- Returns
- The removed node, or an error status on failure.
◆ Get()
| absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::Get |
( |
std::string |
node_id | ) |
|
Return the node for an id, creating it if it does not exist.
- Parameters
-
| node_id | The node identifier. |
- Returns
- The node, or an error status on failure.
◆ GetIfExists()
| absl::StatusOr< std::shared_ptr< AsyncNode > > a11::nodes::NodeMap::GetIfExists |
( |
std::string_view |
node_id | ) |
const |
Return the node for an id without creating it.
- Parameters
-
| node_id | The node identifier. |
- Returns
- The node, or nullptr if it does not exist (or an error status).
◆ Size()
| size_t a11::nodes::NodeMap::Size |
( |
| ) |
const |
Return the number of nodes currently in the map.
- Returns
- The node count.
The documentation for this class was generated from the following files: