SatCat5
satcat5::io::WriteableBroadcast Class Reference

Detailed Description

Forwards incoming writes to multiple downstream Writeables.

Constructor takes an array of io::Writeable pointers. These may or may not be NULL, and can be (re-)set at runtime via port_set() or the array-index operator (i.e., my_object[n]).

When written to via the io::Writeable API, writes are copied to all non-NULL destinations in the array. Finalize is called on each array element and returns true only if every non-null Writeable's finalize call was successful.

Definition at line 35 of file io_broadcast.h.

#include <io_broadcast.h>

Inheritance diagram for satcat5::io::WriteableBroadcast:
[legend]
Collaboration diagram for satcat5::io::WriteableBroadcast:
[legend]

Public Member Functions

unsigned get_write_space () const override
 Get the min available write space of downstream Writeables.
 
void write_abort () override
 Abort writes for all downstream Writeables.
 
void write_bytes (unsigned nbytes, const void *src) override
 Write a byte sequence to all downstream Writeables.
 
bool write_finalize () override
 Finalize the in-progress write for all downstream Writeables. More...
 
Writeable *& operator[] (unsigned idx)
 Access or assign the Nth downstream Writeable object.
 
void port_set (unsigned idx, Writeable *dst)
 Designate the Nth downstream Writeable object.
 
unsigned len () const
 Length of the output array.
 
void write_u8 (u8 data)
 One of many functions for writing integer/floating point values, see details. More...
 
void write_str (const char *str)
 Write the contents of a null-terminated string. More...
 
template<class T >
void write_obj (const T &obj)
 Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr) const;
 

Protected Member Functions

constexpr WriteableBroadcast (unsigned n_dsts, satcat5::io::Writeable **dsts)
 Constructor takes a pointer to an array of io::Writeable pointers along with the length of the given array.
 
void write_next (u8 data) override
 Write the next byte to the underlying buffer or device. More...
 
void write_overflow () override
 Optional error handling for write overflow. More...
 

Protected Attributes

const unsigned m_size
 Size of m_dsts.
 
satcat5::io::Writeable **const m_dsts
 Array of Writeables.
 
friend LimitedWrite
 
friend WriteableBroadcast
 
friend WriteableRedirect
 

Member Function Documentation

◆ write_finalize()

bool WriteableBroadcast::write_finalize ( )
overridevirtual

Finalize the in-progress write for all downstream Writeables.

Returns
True if all downstream write_finalize() calls succeed.

Reimplemented from satcat5::io::Writeable.

Reimplemented in satcat5::io::WriteableBroadcastAny.

Definition at line 43 of file io_broadcast.cc.

◆ write_next()

void WriteableBroadcast::write_next ( u8  data)
overrideprotectedvirtual

Write the next byte to the underlying buffer or device.

Child objects of io::Writeable MUST override this method.

Implements satcat5::io::Writeable.

Definition at line 52 of file io_broadcast.cc.

◆ write_overflow()

void WriteableBroadcast::write_overflow ( )
overrideprotectedvirtual

Optional error handling for write overflow.

Child objects of io::Writeable MAY override this method for error handling.

Reimplemented from satcat5::io::Writeable.

Definition at line 59 of file io_broadcast.cc.

◆ write_str()

void Writeable::write_str ( const char *  str)
inherited

Write the contents of a null-terminated string.

Note: Null-termination is not copied to the output.

Definition at line 180 of file io_writeable.cc.

◆ write_u8()

void Writeable::write_u8 ( u8  data)
inherited

One of many functions for writing integer/floating point values, see details.

Several functions are provided for reading and writing scalar types to/from io::Readable and io::Writeable instances. Since there are many of these that are frequently inherited, they are hidden from documentation. These functions follow a shared template:

  • read_ or write_ prefix.
  • u for unsigned, s for signed, f for floating-point.
  • Data-type width in bits.
    • Available widths for ints: 8/16/24/32/48/64.
    • Available widths for floats: 32/64.
  • l suffix if little-endian, no suffix if big-endian.

Example: write_s48l is "Write 48 bits (6 bytes) to this io::Writeable as a signed value in little-endian order".

Definition at line 20 of file io_writeable.cc.


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