3#include <StormByte/buffer/consumer.hxx>
13namespace StormByte::Buffer {
42 inline Producer(std::shared_ptr<SharedFIFO> buffer): m_buffer(buffer) {}
58 m_buffer = other.m_buffer;
67 m_buffer = std::move(other.m_buffer);
82 m_buffer = other.m_buffer;
92 m_buffer = std::move(other.m_buffer);
101 return m_buffer.get() == other.m_buffer.get();
109 return !(*
this == other);
123 return m_buffer->IsWritable();
133 m_buffer->SetError();
145 inline bool Write(
const std::size_t& count,
const DataType& data)
noexcept override {
146 return m_buffer->Write(count, data);
157 inline bool Write(
const DataType& data)
noexcept {
158 return Write(data.size(), data);
170 inline bool Write(
const std::size_t& count, DataType&& data)
noexcept override {
171 return m_buffer->Write(count, std::move(data));
182 inline bool Write(DataType&& data)
noexcept {
183 return Write(data.size(), std::move(data));
195 inline bool Write(
const std::size_t& count,
const ReadOnly& data)
noexcept override {
196 return m_buffer->Write(count, data);
208 inline bool Write(
const std::size_t& count,
ReadOnly&& data)
noexcept override {
209 return m_buffer->Write(count, std::move(data));
213 using WriteOnly::Write;
227 std::shared_ptr<SharedFIFO> m_buffer;
Read-only interface for consuming data from a shared FIFO buffer.
Definition consumer.hxx:46
Producer interface for writing data to a shared FIFO buffer.
Definition producer.hxx:27
void SetError() noexcept
Thread-safe error state setting.
Definition producer.hxx:132
Producer(Producer &&other) noexcept
Move constructor.
Definition producer.hxx:66
Producer(std::shared_ptr< SharedFIFO > buffer)
Construct a Producer with an existing SharedFIFO buffer.
Definition producer.hxx:42
bool Write(const std::size_t &count, ReadOnly &&data) noexcept override
Move bytes from a vector to the buffer.
Definition producer.hxx:208
Producer() noexcept
Construct a Producer with a new SharedFIFO buffer.
Definition producer.hxx:34
Producer(const Producer &other) noexcept
Copy constructor.
Definition producer.hxx:57
bool Write(const DataType &data) noexcept
Write all bytes from a vector to the buffer.
Definition producer.hxx:157
bool operator!=(const Producer &other) const noexcept
Inequality comparison.
Definition producer.hxx:108
~Producer() noexcept=default
Destructor.
bool operator==(const Producer &other) const noexcept
Equality comparison.
Definition producer.hxx:100
void Close() noexcept
Thread-safe close for further writes.
Definition producer.hxx:118
bool Write(const std::size_t &count, const ReadOnly &data) noexcept override
Write bytes from a vector to the buffer.
Definition producer.hxx:195
Producer & operator=(Producer &&other) noexcept
Move assignment operator.
Definition producer.hxx:90
Producer(const Consumer &consumer)
Construct a Producer from a Consumer's buffer.
Definition producer.hxx:49
bool IsWritable() const noexcept override
Check if the buffer is writable.
Definition producer.hxx:122
bool Write(DataType &&data) noexcept
Move all bytes from a vector to the buffer.
Definition producer.hxx:182
bool Write(const std::size_t &count, const DataType &data) noexcept override
Write bytes from a vector to the buffer.
Definition producer.hxx:145
bool Write(const std::size_t &count, DataType &&data) noexcept override
Move bytes from a vector to the buffer.
Definition producer.hxx:170
Generic class providing a buffer that can be read but not written to.
Definition generic.hxx:146
Thread-safe FIFO built on top of FIFO.
Definition shared_fifo.hxx:52
Generic class providing a buffer that can be written to but not read from.
Definition generic.hxx:408