Maintains transient UID-to-DataNode mappings for the REST API.
More...
#include <mitkNodeUidMapper.h>
|
| static constexpr const char * | UID_PROPERTY_KEY |
| | Property key for storing the UID on nodes (for debugging visibility). More...
|
| |
Maintains transient UID-to-DataNode mappings for the REST API.
This class provides a bidirectional mapping between string UIDs and DataNode pointers. UIDs are:
- Generated on first access (format: "node_<counter>")
- Stored as a node property under the key "restapi.uid" for debugging visibility
- Cleared from the cache when the node is removed from the DataStorage
- Never reused during a session lifetime
- NOT persisted when a scene is saved (transient property)
All public methods are thread-safe.
- See also
- DataStorageBridge
Definition at line 44 of file mitkNodeUidMapper.h.
◆ NodeUidMapper() [1/3]
| mitk::NodeUidMapper::NodeUidMapper |
( |
| ) |
|
◆ ~NodeUidMapper()
| mitk::NodeUidMapper::~NodeUidMapper |
( |
| ) |
|
Destructor. Disconnects from the DataStorage if connected.
◆ NodeUidMapper() [2/3]
◆ NodeUidMapper() [3/3]
◆ ClearDataStorage()
| void mitk::NodeUidMapper::ClearDataStorage |
( |
| ) |
|
Disconnect from the current DataStorage.
Equivalent to calling SetDataStorage(nullptr).
◆ FindNodeByUid()
| DataNode::Pointer mitk::NodeUidMapper::FindNodeByUid |
( |
const std::string & |
uid | ) |
const |
Find a node by its UID.
Returns a strong SmartPointer reference to guarantee the node stays alive after the internal lock is released.
- Parameters
-
| [in] | uid | The UID to look up. |
- Returns
- A SmartPointer to the node, or a null pointer if not found or if the node has already been destroyed.
◆ GetOrCreateUid()
| std::string mitk::NodeUidMapper::GetOrCreateUid |
( |
DataNode * |
node | ) |
|
Get or create a UID for the given node.
If the node already has a cached UID, it is returned. Otherwise a new unique UID is generated, stored in the cache, and set as a property on the node.
- Parameters
-
| [in] | node | The node to get or create a UID for. Must not be nullptr. |
- Returns
- The UID string for this node.
- Exceptions
-
| std::invalid_argument | if node is nullptr. |
◆ GetUid()
| std::optional<std::string> mitk::NodeUidMapper::GetUid |
( |
const DataNode * |
node | ) |
const |
Get the UID for a node without creating one.
- Parameters
-
| [in] | node | The node to look up. |
- Returns
- The UID if it exists, or
std::nullopt if the node has no UID or node is nullptr.
◆ HasUid()
| bool mitk::NodeUidMapper::HasUid |
( |
const std::string & |
uid | ) |
const |
Check whether a UID exists in the mapping.
- Parameters
-
| [in] | uid | The UID string to check. |
- Returns
true if the UID is registered in the mapping.
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ RestoreUid()
| void mitk::NodeUidMapper::RestoreUid |
( |
const DataNode * |
node, |
|
|
const std::string & |
uid |
|
) |
| |
Restore a previously assigned UID mapping for a node.
Used to preserve UIDs across operations that temporarily remove and re-add nodes to the DataStorage (e.g., reparenting). The node's previous UID is re-registered in the cache and stored as a property.
- Parameters
-
| [in] | node | The node to restore the UID for. Must not be nullptr. |
| [in] | uid | The UID to restore. |
- Exceptions
-
| std::invalid_argument | if node is nullptr. |
◆ SetDataStorage()
| void mitk::NodeUidMapper::SetDataStorage |
( |
DataStorage * |
dataStorage | ) |
|
Connect to a DataStorage and start tracking nodes.
Subscribes to AddNodeEvent and RemoveNodeEvent. Clears all existing mappings and removes any stale "restapi.uid" properties from all nodes in the DataStorage (fresh start).
- Parameters
-
| [in] | dataStorage | The DataStorage to track, or nullptr to disconnect. |
◆ UID_PROPERTY_KEY
| constexpr const char* mitk::NodeUidMapper::UID_PROPERTY_KEY |
|
staticconstexpr |
Property key for storing the UID on nodes (for debugging visibility).
Definition at line 48 of file mitkNodeUidMapper.h.
The documentation for this class was generated from the following file: