Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
default_sender.h
Go to the documentation of this file.
1// NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the
2// software in any medium, provided that you keep intact this entire notice. You may improve, modify and create
3// derivative works of the software or any portion of the software, and you may copy and distribute such modifications
4// or works. Modified works should carry a notice stating that you changed the software and should note the date and
5// nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the
6// source of the software. NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND,
7// EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
8// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR
9// WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE
10// CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS
11// THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. You
12// are solely responsible for determining the appropriateness of using and distributing the software and you assume
13// all risks associated with its use, including but not limited to the risks and costs of program errors, compliance
14// with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of
15// operation. This software is not intended to be used in any situation where a failure could cause risk of injury or
16// damage to property. The software developed by NIST employees is not subject to copyright protection within the
17// United States.
18
19
20
21#ifndef HEDGEHOG_DEFAULT_SENDER_H
22#define HEDGEHOG_DEFAULT_SENDER_H
23
24#include "../implementor/implementor_sender.h"
25#include "../implementor/implementor_receiver.h"
27namespace hh {
29namespace core {
31namespace implementor {
32
35template<class Output>
36class DefaultSender : public ImplementorSender<Output> {
37 private:
38 std::unique_ptr<std::set<abstraction::ReceiverAbstraction<Output> *>> const
40
41 public:
43 explicit DefaultSender()
44 : receivers_(std::make_unique<std::set<abstraction::ReceiverAbstraction<Output> *>>()) {}
45
47 virtual ~DefaultSender() = default;
48
51 [[nodiscard]] std::set<abstraction::ReceiverAbstraction<Output> *> const &connectedReceivers() const override {
52 return *receivers_;
53 }
54
57 void addReceiver(abstraction::ReceiverAbstraction<Output> *receiver) override { receivers_->insert(receiver); }
58
61 void removeReceiver(abstraction::ReceiverAbstraction<Output> *receiver) override { receivers_->erase(receiver); }
62
65 void send(std::shared_ptr<Output> data) override {
66 for (auto const &receiver : *receivers_) { receiver->receive(data); }
67 }
68};
69}
70}
71}
72#endif //HEDGEHOG_DEFAULT_SENDER_H
Hedgehog main namespace.
Core's abstraction to receive a piece of data.
Default concrete implementation of sender abstraction.
DefaultSender()
Default constructor.
virtual ~DefaultSender()=default
Default destructor.
void send(std::shared_ptr< Output > data) override
Send a piece of data to all connected receivers.
std::unique_ptr< std::set< abstraction::ReceiverAbstraction< Output > * > > const receivers_
List of receivers.
void addReceiver(abstraction::ReceiverAbstraction< Output > *receiver) override
Add a receiver to the list.
void removeReceiver(abstraction::ReceiverAbstraction< Output > *receiver) override
Remove a receiver to the list.
std::set< abstraction::ReceiverAbstraction< Output > * > const & connectedReceivers() const override
Accessor to the connected receivers.
Implementor for the SenderAbstraction.