From 94399dd7e03a0ada2874d5556f1e2c55ae792250 Mon Sep 17 00:00:00 2001 From: DeltaDizzy Date: Fri, 8 Aug 2025 10:09:54 -0500 Subject: [PATCH] [datalog] Overload DataLogReaderThread::GetEntry to accept an entry id (#8152) It is useful when programmatically interacting with DataLogs to be able to retrieve an record's associated metadata (entry name, type, and metadata string), but the only reference to an entry that a record contains is the id. DataLogReaderThread already builds a map of id->DataLogReaderEntry, but it was unexposed until now. --- .../native/include/wpi/datalog/DataLogReaderThread.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/datalog/src/main/native/include/wpi/datalog/DataLogReaderThread.h b/datalog/src/main/native/include/wpi/datalog/DataLogReaderThread.h index 349b7001ae..e94e4187f2 100644 --- a/datalog/src/main/native/include/wpi/datalog/DataLogReaderThread.h +++ b/datalog/src/main/native/include/wpi/datalog/DataLogReaderThread.h @@ -78,6 +78,15 @@ class DataLogReaderThread { return &it->second; } + const DataLogReaderEntry* GetEntry(int entry) const { + std::scoped_lock lock{m_mutex}; + auto it = m_entriesById.find(entry); + if (it == m_entriesById.end()) { + return nullptr; + } + return it->second; + } + wpi::StructDescriptorDatabase& GetStructDatabase() { return m_structDb; } #ifndef NO_PROTOBUF wpi::ProtobufMessageDatabase& GetProtobufDatabase() { return m_protoDb; }