unilink  0.4.3
A simple C++ library for unified async communication
unilink::framer::IFramer Class Referenceabstract

Abstract base class for message framing strategies. More...

#include <iframer.hpp>

Inheritance diagram for unilink::framer::IFramer:
unilink::framer::LineFramer unilink::framer::PacketFramer

Public Types

using MessageCallback = std::function< void(memory::ConstByteSpan)>
 Register a callback to be invoked when a complete message is extracted. More...
 

Public Member Functions

virtual ~IFramer ()=default
 
virtual void push_bytes (memory::ConstByteSpan data)=0
 Push raw bytes into the framer's internal buffer. More...
 
virtual void set_on_message (MessageCallback cb)=0
 
virtual void reset ()=0
 Reset internal state/buffer. More...
 

Detailed Description

Abstract base class for message framing strategies.

Handles stream-based data segmentation (e.g., separating TCP/Serial streams into distinct messages by delimiters or packet patterns).

Definition at line 35 of file iframer.hpp.

Member Typedef Documentation

◆ MessageCallback

Register a callback to be invoked when a complete message is extracted.

Parameters
cbThe callback function taking a span of the message bytes.

Definition at line 54 of file iframer.hpp.

Constructor & Destructor Documentation

◆ ~IFramer()

virtual unilink::framer::IFramer::~IFramer ( )
virtualdefault

Member Function Documentation

◆ push_bytes()

virtual void unilink::framer::IFramer::push_bytes ( memory::ConstByteSpan  data)
pure virtual

Push raw bytes into the framer's internal buffer.

The framer will buffer the data and invoke the message callback whenever a complete message is extracted.

Parameters
dataThe raw data chunk to process.

Implemented in unilink::framer::PacketFramer, and unilink::framer::LineFramer.

◆ reset()

virtual void unilink::framer::IFramer::reset ( )
pure virtual

Reset internal state/buffer.

Should be called on connection loss or when resynchronization is needed.

Implemented in unilink::framer::PacketFramer, and unilink::framer::LineFramer.

◆ set_on_message()

virtual void unilink::framer::IFramer::set_on_message ( MessageCallback  cb)
pure virtual

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