AnyMessageLogWriter Class Reference

Space-ng SDK: sol3::core::AnyMessageLogWriter Class Reference
Space-ng SDK
sol3::core::AnyMessageLogWriter Class Reference

#include <sol3/core/any_message_log_writer.h>

Inheritance diagram for sol3::core::AnyMessageLogWriter:
sol3::core::IStreamWriter

Public Member Functions

 AnyMessageLogWriter (msg::MessageLogConfigT const &cfg, MessageSchema const &schema, std::chrono::system_clock::time_point start_stamp)
 Construct a writer for the given config and initial epoch. More...
 
 ~AnyMessageLogWriter ()
 Flush and close any open log file. More...
 
void logMessage (flatbuffers::span< uint8_t const > header_span, flatbuffers::span< uint8_t const > payload_span)
 
void commit (size_t message_count)
 Commit N messages written via write(). More...
 
void rollback ()
 Roll back to the last committed position. More...
 
void write (char const *data, size_t size) override
 
cpp::fs::path closeLog (std::chrono::system_clock::time_point end_stamp)
 
cpp::fs::path rotateLog (std::chrono::system_clock::time_point stamp)
 
cpp::fs::path const & currentLogPath () const
 
- Public Member Functions inherited from sol3::core::IStreamWriter
virtual ~IStreamWriter ()=default
 

Detailed Description

Writes size-prefixed message headers and payloads to log files.

File layout (every entry is size-prefixed on disk): | u32 size | sol3.core.msg.MessageLogHeader schema bytes | padding (0..7) | | u32 size | sol3.core.msg.MessageHeader schema bytes | padding (0..7) | | u32 size | payload schema bytes | padding (0..7) | | u32 size | sol3.core.msg.MessageLogHeader bytes | padding (0..7) | | u32 size | sol3.core.msg.MessageHeader bytes | padding (0..7) | | u32 size | payload flatbuffer bytes | padding (0..7) | | u32 size | sol3.core.msg.MessageHeader bytes | padding (0..7) | | u32 size | payload flatbuffer bytes | padding (0..7) | ...

Notes:

  • Entries are 8-byte aligned and include zero padding bytes as needed.
  • Log header, message header, and payload entries are size-prefixed FlatBuffers, so callers should use GetSizePrefixedRoot() when parsing.
  • Each log file is self-describing and includes its own schema headers.

Constructor & Destructor Documentation

◆ AnyMessageLogWriter()

sol3::core::AnyMessageLogWriter::AnyMessageLogWriter ( msg::MessageLogConfigT const &  cfg,
MessageSchema const &  schema,
std::chrono::system_clock::time_point  start_stamp 
)
explicit

Construct a writer for the given config and initial epoch.

◆ ~AnyMessageLogWriter()

sol3::core::AnyMessageLogWriter::~AnyMessageLogWriter ( )

Flush and close any open log file.

Member Function Documentation

◆ closeLog()

cpp::fs::path sol3::core::AnyMessageLogWriter::closeLog ( std::chrono::system_clock::time_point  end_stamp)

Close the current log file and rename it with the elapsed time offset. After closeLog(), the writer is not open; call rotateLog() to continue writing to a new file.

◆ commit()

void sol3::core::AnyMessageLogWriter::commit ( size_t  message_count)

Commit N messages written via write().

◆ currentLogPath()

cpp::fs::path const& sol3::core::AnyMessageLogWriter::currentLogPath ( ) const
inline

◆ logMessage()

void sol3::core::AnyMessageLogWriter::logMessage ( flatbuffers::span< uint8_t const >  header_span,
flatbuffers::span< uint8_t const >  payload_span 
)

Log a message using the provided header and payload spans. Preconditions:

  • Writer is open.
  • Header and payload are size-prefixed FlatBuffers with matching types.

◆ rollback()

void sol3::core::AnyMessageLogWriter::rollback ( )

Roll back to the last committed position.

◆ rotateLog()

cpp::fs::path sol3::core::AnyMessageLogWriter::rotateLog ( std::chrono::system_clock::time_point  stamp)

Rotate the log file, starting a new file and re-logging the schema. Stamp is used for the end stamp of the closing file, and the start stamp of the next file.

◆ write()

void sol3::core::AnyMessageLogWriter::write ( char const *  data,
size_t  size 
)
overridevirtual

Write raw bytes to the current uncommitted position. Call commit() to finalize bytes; uncommitted data is discarded. It is valid to call write() multiple times before committing.

Implements sol3::core::IStreamWriter.


The documentation for this class was generated from the following file: