56 {
return (idx < m_size) ? (m_ports + idx) : 0; }
58 {
return (idx < m_size) ? (m_ports + idx) : 0; }
78 const
unsigned m_size;
80 satcat5::io::
MuxPort* const m_ports;
105 : m_size(size), m_index(-1), m_src(src), m_dst(dst) {}
106 ~
MuxUp() SATCAT5_OPTIONAL_DTOR;
114 const
unsigned m_size;
116 satcat5::io::
Readable** const m_src;
122 template <
unsigned SIZE>
126 :
MuxDown(SIZE, m_port_array, src, dst) {}
133 template <
unsigned SIZE>
137 :
MuxUp(SIZE, m_src_array, m_dst_array), m_src_array{0}, m_dst_array{0} {}
Event-handler interface for newly received data.
Multiplexer connecting a port to one of several controllers.
void data_rcvd(satcat5::io::Readable *src) override
The data_rcvd() callback is polled whenever data is available.
satcat5::io::Writeable * port_wr(unsigned idx)
Fetch the interface pointer for attaching the Nth controller.
satcat5::io::Readable * port_rd(unsigned idx)
Fetch the interface pointer for attaching the Nth controller.
void data_unlink(satcat5::io::Readable *src) override
Unlink this EventListener from the designated source, because the designated Readable object is being...
void select(unsigned idx)
Select the active controller index, or UINT_MAX for none.
~MuxDown() SATCAT5_OPTIONAL_DTOR
Constructor and destructor should only be called by children.
MuxDown(unsigned size, satcat5::io::MuxPort *ports, satcat5::io::Readable *src, satcat5::io::Writeable *dst)
Constructor and destructor should only be called by children.
Static allocator for io::MuxDown.
Helper object used inside io::MuxDown.
void attach(Readable *src, Writeable *dst)
Update the redirect configuration to attach or detach this port.
constexpr MuxPort()
Create an unattached port object.
void set_callback(satcat5::io::EventListener *callback) override
Override set_callback() to set the internal variable only.
Multiplexer connecting a controller to one of several ports.
constexpr MuxUp(unsigned size, satcat5::io::Readable **src, satcat5::io::Writeable **dst)
Constructor and destructor should only be called by children.
Static allocator for io::MuxUp.
Abstract API for reading byte-streams and packets.
virtual void set_callback(satcat5::io::EventListener *callback)
Update registered callback for data_rcvd() events.
Wrapper class for forwarding reads to another object.
void read_src(satcat5::io::Readable *src)
Children may reset the source object as needed.
Abstract API for writing byte-streams and packets.
Wrapper class for forwarding writes to another object.
"Readable" I/O interface core definitions
"Writeable" I/O interface core definitions
satcat5::io::NullWrite null_write
Global instance of the basic NullWrite object.