TraceFileWriter

class TraceFileWriter

Abstract base class for writing trace files in various formats.

This class provides an interface for writing protobuf messages to trace files. Different implementations can support various file formats like .osi, .mcap or .txth.

Note

The WriteMessage() function is intentionally omitted from this base class since it is format-specific. Users should dynamically cast to the concrete implementation class to access the appropriate WriteMessage() function.

Note

Thread Safety: Instances are not thread-safe. Concurrent calls on the same writer must be externally synchronized.

Note

Error Strategy: Open returns false and logs to std::cerr on failure. WriteMessage returns false on write errors.

Subclassed by osi3::MCAPTraceFileWriter, osi3::SingleChannelBinaryTraceFileWriter, osi3::TXTHTraceFileWriter

Public Functions

virtual ~TraceFileWriter() = default

Virtual destructor.

TraceFileWriter() = default

Default constructor.

TraceFileWriter(const TraceFileWriter&) = delete

Deleted copy constructor.

TraceFileWriter &operator=(const TraceFileWriter&) = delete

Deleted copy assignment operator.

TraceFileWriter(TraceFileWriter&&) = delete

Deleted move constructor.

TraceFileWriter &operator=(TraceFileWriter&&) = delete

Deleted move assignment operator.

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

Opens a file for writing.

Parameters:

file_path – Path to the file to be created/opened

Returns:

true if successful, false otherwise

virtual void Close() = 0

Closes the trace file.