CCF
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
ringbuffer::AbstractWriter Class Referenceabstract

#include <ring_buffer_types.h>

Inherited by oversized::Writer, ringbuffer::NonBlockingWriter, ringbuffer::NotifyingWriter, and ringbuffer::Writer.

Public Types

using WriteMarker = std::optional< size_t >
 

Public Member Functions

virtual ~AbstractWriter ()=default
 
template<typename Serializer , typename... Ts>
void write_with (Message m, Ts &&... ts)
 
template<typename Serializer , typename... Ts>
bool try_write_with (Message m, Ts &&... ts)
 
template<typename... Ts>
void write (Message m, Ts &&... ts)
 
template<typename... Ts>
bool try_write (Message m, Ts &&... ts)
 
virtual WriteMarker prepare (Message m, size_t size, bool wait=true, size_t *identifier=nullptr)=0
 
virtual void finish (const WriteMarker &marker)=0
 
virtual WriteMarker write_bytes (const WriteMarker &marker, const uint8_t *bytes, size_t size)=0
 
virtual size_t get_max_message_size ()=0
 

Member Typedef Documentation

◆ WriteMarker

using ringbuffer::AbstractWriter::WriteMarker = std::optional<size_t>

Constructor & Destructor Documentation

◆ ~AbstractWriter()

virtual ringbuffer::AbstractWriter::~AbstractWriter ( )
virtualdefault

Member Function Documentation

◆ finish()

virtual void ringbuffer::AbstractWriter::finish ( const WriteMarker marker)
pure virtual

◆ get_max_message_size()

virtual size_t ringbuffer::AbstractWriter::get_max_message_size ( )
pure virtual

◆ prepare()

virtual WriteMarker ringbuffer::AbstractWriter::prepare ( Message  m,
size_t  size,
bool  wait = true,
size_t *  identifier = nullptr 
)
pure virtual

Implementation requires 3 methods - prepare, finish, and write_bytes. For each message, prepare will be called with the total message size. It should return a WriteMarker for this reservation. That WriteMarker will be passed to write_bytes, which may be called repeatedly for each part of the message. write_bytes returns an opaque WriteMarker which will be passed to the next invocation of write_bytes, to track progress. Finally, finish will be called with the WriteMarker initially returned from prepare.

Implemented in ringbuffer::NotifyingWriter, ringbuffer::Writer, oversized::Writer, and ringbuffer::NonBlockingWriter.

◆ try_write()

template<typename... Ts>
bool ringbuffer::AbstractWriter::try_write ( Message  m,
Ts &&...  ts 
)
inline

◆ try_write_with()

template<typename Serializer , typename... Ts>
bool ringbuffer::AbstractWriter::try_write_with ( Message  m,
Ts &&...  ts 
)
inline

Try to write a message, but fail (and write nothing) if there is not currently sufficient space to write completely.

◆ write()

template<typename... Ts>
void ringbuffer::AbstractWriter::write ( Message  m,
Ts &&...  ts 
)
inline

◆ write_bytes()

virtual WriteMarker ringbuffer::AbstractWriter::write_bytes ( const WriteMarker marker,
const uint8_t *  bytes,
size_t  size 
)
pure virtual

◆ write_with()

template<typename Serializer , typename... Ts>
void ringbuffer::AbstractWriter::write_with ( Message  m,
Ts &&...  ts 
)
inline

Write a message of the given type, containing serialized representation of each of the args, in order. Blocks until the entire message is written.


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