TXTHTraceFileReader

class TXTHTraceFileReader : public osi3::TraceFileReader

Implementation of TraceFileReader for text format files containing OSI messages.

This class provides functionality to read and parse OSI messages from text format files. It supports various OSI message types and handles their parsing using Google’s protobuf TextFormat.

Note

Thread Safety: Not thread-safe. External synchronization required for concurrent access.

Public Functions

~TXTHTraceFileReader() override

Destructor, closes the file if still open.

virtual bool Open(const std::filesystem::path &file_path) override

Opens a trace file for reading and infers message type from filename.

Parameters:

file_path – Path to the trace file

Returns:

true if successful, false otherwise

bool Open(const std::filesystem::path &file_path, ReaderTopLevelMessage message_type)

Opens a trace file with specified message type.

Parameters:
  • file_path – Path to the trace file

  • message_type – Expected message type in the file

Returns:

true if successful, false otherwise

virtual void Close() override

Closes the trace file.

virtual bool HasNext() override

Checks whether more messages are available.

Returns:

true if there are more messages to read, false otherwise

virtual std::optional<ReadResult> ReadMessage() override

Reads the next message from the trace file.

Returns:

Optional ReadResult containing the message if available