3#include <StormByte/buffer/external.hxx>
4#include <StormByte/buffer/fifo.hxx>
14namespace StormByte::Buffer {
52 class STORMBYTE_BUFFER_PUBLIC
Bridge {
63 m_read_handler(in.Clone()),
64 m_write_handler(out.Clone()),
65 m_chunk_size(chunk_size) {}
75 m_read_handler(in.Move()),
76 m_write_handler(out.Move()),
77 m_chunk_size(chunk_size) {}
131 bool Passthrough(std::
size_t bytes) const noexcept;
143 bool Passthrough(std::
size_t bytes) noexcept;
149 inline std::
size_t PendingBytes() const noexcept {
150 return m_buffer.Size();
155 ExternalReader::PointerType m_read_handler;
156 ExternalWriter::PointerType m_write_handler;
157 std::size_t m_chunk_size;
164 bool PassthroughWrite(Buffer::DataType&& data)
const noexcept;
Pass-through adapter that forwards bytes from an ExternalReader to an ExternalWriter in chunks.
Definition bridge.hxx:52
bool Flush() const noexcept
Flushes any pending bytes in the internal buffer to the write handler.
Bridge & operator=(Bridge &&other) noexcept=default
Move assignment (defaulted).
Bridge(const Bridge &other)=delete
Copy constructor (deleted) — Bridge is non-copyable.
Bridge(ExternalReader &&in, ExternalWriter &&out, std::size_t chunk_size=4096) noexcept
Construct a Bridge with both read and write handlers (moving handlers).
Definition bridge.hxx:73
std::size_t ChunkSize() const noexcept
Gets the configured chunk size for passthrough operations.
Definition bridge.hxx:109
~Bridge() noexcept
Destructor — attempts to flush pending bytes.
Definition bridge.hxx:93
Bridge(const ExternalReader &in, const ExternalWriter &out, std::size_t chunk_size=4096) noexcept
Construct a Bridge with both read and write handlers (copying handlers).
Definition bridge.hxx:61
Bridge(Bridge &&other) noexcept=default
Move constructor (defaulted) — transfers handlers.
Bridge & operator=(const Bridge &other)=delete
Copy assignment (deleted).
Interface for reading data from an external source.
Definition external.hxx:26
Interface for writing data to an external source.
Definition external.hxx:174
Byte-oriented FIFO buffer with grow-on-demand.
Definition fifo.hxx:40