Class McapWriter

Class Documentation

class McapWriter

An MCAP writer, used to log messages to an MCAP file.

Public Functions

template<typename Iterator>
FoxgloveError writeMetadata(std::string_view name, Iterator begin, Iterator end)

Write metadata to the MCAP file.

Metadata consists of key-value string pairs associated with a name. If the range is empty, this method does nothing.

Template Parameters:

Iterator – An iterator type that dereferences to std::pair<std::string, std::string>

Parameters:
  • name – Name identifier for this metadata record

  • begin – Iterator to the beginning of the key-value pairs

  • end – Iterator to the end of the key-value pairs

Returns:

FoxgloveError::Ok on success, or an error code on failure

FoxgloveError close()

Stops logging events and flushes buffered data.

McapWriter(McapWriter&&) = default

Default move constructor.

McapWriter &operator=(McapWriter&&) = default

Default move assignment.

~McapWriter() = default
McapWriter(const McapWriter&) = delete
McapWriter &operator=(const McapWriter&) = delete
template<typename Iter>
FoxgloveError writeMetadata(std::string_view name, Iter begin, Iter end)

Write metadata to the MCAP file.

Metadata consists of key-value string pairs associated with a name. If the range is empty, this method does nothing.

Template Parameters:

Iterator – An iterator type that dereferences to std::pair<std::string, std::string>

Parameters:
  • name – Name identifier for this metadata record

  • begin – Iterator to the beginning of the key-value pairs

  • end – Iterator to the end of the key-value pairs

Returns:

FoxgloveError::Ok on success, or an error code on failure

Public Static Functions

static FoxgloveResult<McapWriter> create(const McapWriterOptions &options)

Create a new MCAP writer.

Note

Calls to create from multiple threads are safe, unless the same file path is given. Writing to an MCAP writer happens through channel logging, which is thread-safe.

Parameters:

options – The options for the MCAP writer.

Returns:

A new MCAP writer.