21#ifndef HEDGEHOG_QUEUE_RECEIVER_H
22#define HEDGEHOG_QUEUE_RECEIVER_H
31#include "../../abstractions/base/input_output/receiver_abstraction.h"
32#include "../implementor/implementor_receiver.h"
40namespace abstraction {
42class SenderAbstraction;
46namespace implementor {
53 std::unique_ptr<std::queue<std::shared_ptr<Input>>>
const
56 std::unique_ptr<std::set<abstraction::SenderAbstraction<Input> *>>
const
65 :
queue_(std::make_unique<std::queue<std::shared_ptr<Input>>>()),
66 senders_(std::make_unique<std::set<abstraction::SenderAbstraction<Input> *>>()) {}
73 void receive(std::shared_ptr<Input>
const data)
final {
83 auto front =
queue_->front();
98 [[nodiscard]]
bool empty()
const override {
return queue_->empty(); }
102 [[nodiscard]] std::set<abstraction::SenderAbstraction<Input> *>
const &
connectedSenders()
const override {
Core abstraction to send data.
Concrete implementation of the receiver core abstraction for a type using a std::queue.
void removeSender(abstraction::SenderAbstraction< Input > *const sender) override
Remove a sender to the set of connected senders.
bool empty() const override
Test if the queue is empty.
std::shared_ptr< Input > getInputData() override
Get a data from the queue.
size_t maxSize_
Maximum size attained by the queue.
void addSender(abstraction::SenderAbstraction< Input > *const sender) override
Add a sender to the set of connected senders.
std::unique_ptr< std::set< abstraction::SenderAbstraction< Input > * > > const senders_
List of senders attached to this receiver.
QueueReceiver()
Default constructor.
std::unique_ptr< std::queue< std::shared_ptr< Input > > > const queue_
Queue storing to be processed data.
size_t numberElementsReceived() const override
Accessor to the current size of the queue.
void receive(std::shared_ptr< Input > const data) final
Receive a data and store it in the queue.
std::set< abstraction::SenderAbstraction< Input > * > const & connectedSenders() const override
Accessor to the set of connected senders.
size_t maxNumberElementsReceived() const override
Accessor to the maximum queue size.
virtual ~QueueReceiver()=default
Default destructor.
Implementor for the ReceiverAbstraction.