TraceFileReader¶
-
class TraceFileReader¶
Abstract base class for reading trace files in various formats.
Note
Thread Safety: Instances are not thread-safe. Concurrent calls on the same reader must be externally synchronized.
Note
Error Strategy:
Openreturnsfalseand logs tostd::cerron failure.ReadMessagereturnsstd::nulloptwhen no messages remain, and throwsstd::runtime_erroron deserialization or format errors.Subclassed by osi3::MCAPTraceFileReader, osi3::SingleChannelBinaryTraceFileReader, osi3::TXTHTraceFileReader
Public Functions
-
TraceFileReader() = default¶
Default constructor.
-
virtual ~TraceFileReader() = default¶
Virtual destructor.
-
TraceFileReader(const TraceFileReader&) = delete¶
Deleted copy constructor.
-
TraceFileReader &operator=(const TraceFileReader&) = delete¶
Deleted copy assignment operator.
-
TraceFileReader(TraceFileReader&&) = delete¶
Deleted move constructor.
-
TraceFileReader &operator=(TraceFileReader&&) = delete¶
Deleted move assignment operator.
-
virtual bool Open(const std::filesystem::path &file_path) = 0¶
Opens a trace file for reading.
- Parameters:
file_path – Path to the file to be opened
- Returns:
true if successful, false otherwise
-
virtual std::optional<ReadResult> ReadMessage() = 0¶
Reads the next message from the trace file.
- Returns:
Optional ReadResult containing the message if available
-
virtual void Close() = 0¶
Closes the trace file.
-
virtual bool HasNext() = 0¶
Indicates availability of additional messages.
Returns whether more messages can be read from the trace file. Always call this method before ReadMessage() to verify message availability. For MCAP format files specifically, this may return true even when only non-OSI messages remain in the file.
- Returns:
true if there are more messages to read, false otherwise
-
TraceFileReader() = default¶
-
class TraceFileReaderFactory¶
Factory class for creating trace file readers based on file extensions.
Public Static Functions
-
static std::unique_ptr<TraceFileReader> createReader(const std::filesystem::path &file_path)¶
Creates a reader instance based on the file extension.
Supported formats:
.osi: Single channel binary format (SingleChannelBinaryTraceFileReader)
.txth: Single channel human-readable format (TXTHTraceFileReader)
.mcap: Multi channel binary format (MCAPTraceFileReader)
Note
It is still required to call Open(path) on the returned reader instance
- Parameters:
file_path – Path to the trace file
- Throws:
std::invalid_argument – if the file extension is not supported
- Returns:
Unique pointer to a TraceFileReader instance
-
static std::unique_ptr<TraceFileReader> createReader(const std::filesystem::path &file_path)¶