13 #ifndef mitkNodeUidMapper_h
14 #define mitkNodeUidMapper_h
19 #include <unordered_map>
48 static constexpr
const char* UID_PROPERTY_KEY =
"restapi.uid";
119 bool HasUid(
const std::string& uid)
const;
135 void OnNodeAdded(
const DataNode* node);
136 void OnNodeRemoved(
const DataNode* node);
137 std::string GenerateUid();
138 void ClearRESTUIDProperty();
143 mutable std::mutex m_Mutex;
144 std::unordered_map<std::string, mitk::WeakPointer<DataNode>> m_UidToNode;
145 std::unordered_map<const DataNode*, std::string> m_NodeToUid;
148 std::atomic<uint64_t> m_UidCounter{0};
151 bool m_Connected =
false;
#define MITKRESTAPI_EXPORT
Central node class of the MITK data tree, associating a data object with properties and mappers.
Abstract data management class that organizes DataNode objects in a directed acyclic graph.
Maintains transient UID-to-DataNode mappings for the REST API.
void SetDataStorage(DataStorage *dataStorage)
Connect to a DataStorage and start tracking nodes.
NodeUidMapper & operator=(NodeUidMapper &&)=delete
DataNode::Pointer FindNodeByUid(const std::string &uid) const
Find a node by its UID.
NodeUidMapper()
Default constructor.
NodeUidMapper(NodeUidMapper &&)=delete
NodeUidMapper(const NodeUidMapper &)=delete
bool HasUid(const std::string &uid) const
Check whether a UID exists in the mapping.
std::optional< std::string > GetUid(const DataNode *node) const
Get the UID for a node without creating one.
std::string GetOrCreateUid(DataNode *node)
Get or create a UID for the given node.
void RestoreUid(const DataNode *node, const std::string &uid)
Restore a previously assigned UID mapping for a node.
void ClearDataStorage()
Disconnect from the current DataStorage.
NodeUidMapper & operator=(const NodeUidMapper &)=delete
~NodeUidMapper()
Destructor. Disconnects from the DataStorage if connected.
A weak pointer that observes an itk::Object without preventing its deletion.
Find image slices visible on a given plane.