| 91 | } |
| 92 | |
| 93 | std::string NodeUidMapper::GetOrCreateUid(DataNode* node) |
| 94 | { |
| 95 | if (node == nullptr) |
| 96 | { |
| 97 | throw std::invalid_argument("Node cannot be null"); |
| 98 | } |
| 99 | |
| 100 | std::lock_guard<std::mutex> lock(m_Mutex); |
| 101 | |
| 102 | // Check cache first |
| 103 | auto it = m_NodeToUid.find(node); |
| 104 | if (it != m_NodeToUid.end()) |
| 105 | { |
| 106 | return it->second; |
| 107 | } |
| 108 | |
| 109 | // Generate new UID |
| 110 | std::string uid = this->GenerateUid(); |
| 111 | |
| 112 | // Store in cache |
| 113 | m_UidToNode[uid] = node; |
| 114 | m_NodeToUid[node] = uid; |
| 115 | |
| 116 | // Store as property for debugging visibility |
| 117 | node->SetStringProperty(UID_PROPERTY_KEY, uid.c_str()); |
| 118 | |
| 119 | return uid; |
| 120 | } |
| 121 | |
| 122 | DataNode::Pointer NodeUidMapper::FindNodeByUid(const std::string& uid) const |
| 123 | { |