[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.
This commit is contained in:
DeltaDizzy
2025-08-08 10:09:54 -05:00
committed by GitHub
parent 6eba91bc04
commit 94399dd7e0

View File

@@ -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; }