A thread-safe registry of AsyncNodes keyed by id.
More...
#include <cpp/a11/nodes/node_map.h>
|
| | ~NodeMap ()=default |
| |
| absl::StatusOr< std::shared_ptr< AsyncNode > > | Get (std::string node_id) |
| | Return the node for an id, creating it if it does not exist.
|
| |
| absl::StatusOr< std::shared_ptr< AsyncNode > > | GetIfExists (std::string_view node_id) const |
| | Return the node for an id without creating it.
|
| |
| absl::StatusOr< std::shared_ptr< AsyncNode > > | Discard (std::string_view node_id, const std::shared_ptr< AsyncNode > &expected=nullptr) |
| | Remove the node for an id.
|
| |
| bool | Contains (std::string_view node_id) const |
| | Report whether a node with the given id exists.
|
| |
| size_t | Size () const |
| | Return the number of nodes currently in the map.
|
| |
| std::vector< std::string > | Ids () const |
| | Return the id of every node the map holds, sorted.
|
| |
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.
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).
◆ Ids()
| std::vector< std::string > a11::nodes::NodeMap::Ids |
( |
| ) |
const |
Return the id of every node the map holds, sorted.
A snapshot: nodes are created on demand, so the answer is what was there when it was asked for. Sorted rather than in hash order so a caller comparing two snapshots – a test, a diagnostic dump – sees a stable list.
- Returns
- The ids.
◆ 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: