| 847 | } |
| 848 | |
| 849 | DataStorageBridge::GetNodeDataResult DataStorageBridge::GetNodeData(const std::string& uid) const |
| 850 | { |
| 851 | std::lock_guard<std::mutex> lock(m_Mutex); |
| 852 | return this->DispatchTask<GetNodeDataResult>([this, uid]() |
| 853 | { |
| 854 | GetNodeDataResult result; |
| 855 | result.nodeFound = false; |
| 856 | result.data = nullptr; |
| 857 | |
| 858 | auto dataStorage = m_DataStorage.Lock(); |
| 859 | if (dataStorage.IsNull()) |
| 860 | { |
| 861 | return result; |
| 862 | } |
| 863 | |
| 864 | auto node = m_UidMapper->FindNodeByUid(uid); |
| 865 | if (node == nullptr) |
| 866 | { |
| 867 | return result; // nodeFound = false |
| 868 | } |
| 869 | |
| 870 | result.nodeFound = true; |
| 871 | |
| 872 | auto data = node->GetData(); |
| 873 | if (data == nullptr) |
| 874 | { |
| 875 | return result; // nodeFound = true, data = nullptr |
| 876 | } |
| 877 | |
| 878 | // Clone the data for thread-safe processing outside the lock |
| 879 | // This allows the caller to serialize/process the data without |
| 880 | // blocking other DataStorage operations |
| 881 | result.data = dynamic_cast<BaseData*>(data->Clone().GetPointer()); |
| 882 | return result; |
| 883 | }); |
| 884 | } |
| 885 | |
| 886 | DataNode::ConstPointer DataStorageBridge::FindDataNode(const std::string& uid) const |
| 887 | { |