SingleChannelBinaryTraceFileWriter

class SingleChannelBinaryTraceFileWriter : public osi3::TraceFileWriter

Implementation of TraceFileWriter for binary format files containing OSI messages.

This class provides functionality to write OSI messages in the single binary channel format. It stores messages in their serialized protobuf binary representation in a single channel. Messages are separated by a length specification before each message. The length is represented by a four-byte, little-endian, unsigned integer.

Note

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

Public Functions

~SingleChannelBinaryTraceFileWriter() override

Destructor, closes the file if still open.

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

Opens a file for binary trace output.

Parameters:

file_path – Path to the file to be created/opened

Returns:

true if successful, false otherwise

virtual void Close() override

Closes the trace file.

virtual bool WriteMessage(const google::protobuf::Message &message, const std::string &topic = "") override

Writes a protobuf message to the file (type-erased, virtual)

The topic parameter is ignored for this single-channel format.

Parameters:
  • message – The protobuf message to write

  • topic – Ignored (single-channel format)

Returns:

true if successful, false otherwise

template<typename T>
bool WriteMessage(const T &top_level_message)

Writes a protobuf message to the file (compile-time typed)

Template Parameters:

T – Type of the protobuf message

Parameters:

top_level_message – The message to write

Returns:

true if successful, false otherwise