Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
graph_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#ifndef HEDGEHOG_GRAPH_SENDER_H
20#define HEDGEHOG_GRAPH_SENDER_H
21
23namespace hh {
25namespace core {
27namespace implementor {
28
31template<class Output>
32class GraphSender : public ImplementorSender<Output> {
33 public:
34
36 explicit GraphSender() = default;
37
39 virtual ~GraphSender() = default;
40
43 void initialize([[maybe_unused]]abstraction::SenderAbstraction<Output> *senderAbstraction) override {}
44
48 [[nodiscard]] std::set<abstraction::ReceiverAbstraction < Output> *> const &connectedReceivers() const override {
49 throw std::runtime_error("A graph has no connected ReceiverAbstraction by itself.");
50 }
51
55 for (auto sender : *this->abstractSenders_) { sender->addReceiver(receiver); }
56 }
57
61 for (auto sender : *this->abstractSenders_) { sender->removeReceiver(receiver); }
62 }
63
67 void send([[maybe_unused]]std::shared_ptr<Output> data) override {
68 throw std::runtime_error("A graph has no connected ReceiverAbstraction by itself");
69 }
70};
71}
72}
73}
74#endif //HEDGEHOG_GRAPH_SENDER_H
Hedgehog main namespace.
Core's abstraction to receive a piece of data.
Core abstraction to send data.
Default concrete implementation of the sender abstraction for the graph core.
Definition: graph_sender.h:32
virtual ~GraphSender()=default
Default destructor.
GraphSender()=default
Default constructor.
void send(std::shared_ptr< Output > data) override
Do nothing, throw an error, a graph is not really connected to other nodes.
Definition: graph_sender.h:67
void initialize(abstraction::SenderAbstraction< Output > *senderAbstraction) override
Redefine the implementor to do nothing, the graph do nothing by itself.
Definition: graph_sender.h:43
void addReceiver(abstraction::ReceiverAbstraction< Output > *receiver) override
Add receiver node to graph's output node.
Definition: graph_sender.h:54
std::set< abstraction::ReceiverAbstraction< Output > * > const & connectedReceivers() const override
Do nothing, throw an error, a graph is not really connected to other nodes.
Definition: graph_sender.h:48
void removeReceiver(abstraction::ReceiverAbstraction< Output > *receiver) override
Remove receiver node to graph's output node.
Definition: graph_sender.h:60
Implementor for the SenderAbstraction.
std::unique_ptr< std::set< abstraction::SenderAbstraction< Output > * > > abstractSenders_
Linked SenderAbstraction.