Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
graph_source.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_GRAPH_SOURCE_H
22#define HEDGEHOG_GRAPH_SOURCE_H
23
24#include <ostream>
25
26#include "../abstractions/base/input_output/sender_abstraction.h"
27
28#include "../abstractions/base/input_output/notifier_abstraction.h"
29#include "../abstractions/base/node/node_abstraction.h"
30#include "../implementors/concrete_implementor/default_sender.h"
31
32#include "../implementors/concrete_implementor/default_notifier.h"
33
35namespace hh {
37namespace core {
38
41template<class ...Inputs>
45 public abstraction::SenderAbstraction<Inputs> ... {
46
47 public:
48
51 NodeAbstraction("Source"),
52 NotifierAbstraction(std::make_shared<implementor::DefaultNotifier>()),
53 abstraction::SenderAbstraction<Inputs>(std::make_shared<implementor::DefaultSender < Inputs>>())... {}
54
56 ~GraphSource() override = default;
57
58
62 template<class Input>
63 void sendAndNotifyAllInputs(std::shared_ptr<Input> &data) {
64 static_cast<abstraction::SenderAbstraction<Input> *>(this)->send(data);
65 static_cast<NotifierAbstraction *>(this)->notify();
66 }
67
70 void print(Printer *printer) {
71 printer->printSource(this);
72 }
73
76 [[nodiscard]] std::vector<std::pair<std::string const, std::string const>> ids() const override {
77 return {{this->id(), this->id()}};
78 }
79
83 [[nodiscard]] behavior::Node *node() const override {
84 throw std::runtime_error("Try to get a node out of a core switch while there is none.");
85 }
86
87};
88}
89}
90#endif //HEDGEHOG_GRAPH_SOURCE_H
Hedgehog main namespace.
Printer abstraction to get a snapshot of the metrics of the Hedgehog graph.
Definition: printer.h:52
virtual void printSource(core::abstraction::NodeAbstraction const *source)=0
Print outer graph source.
Behavior abstraction for the base node.
Definition: node.h:32
Core abstraction to notify slots.
void notify()
Notify a slot to wake up.
NotifierAbstraction(std::shared_ptr< implementor::ImplementorNotifier > notifier)
Constructor utilising a concrete implementation.
Core abstraction to send data.
SenderAbstraction(std::shared_ptr< implementor::ImplementorSender< Inputs > > concreteSender)
Constructor using the concrete implementation.
void send(std::shared_ptr< Inputs > data)
Send a data as output of the node.
virtual std::string id() const
Core's id ('x' + address of abstraction) as string.
NodeAbstraction(std::string name)
Core node constructor using the core's name.
Source of the graph, only used in an outer graph.
Definition: graph_source.h:45
~GraphSource() override=default
Default destructor.
GraphSource()
Default constructor.
Definition: graph_source.h:50
void print(Printer *printer)
Gather source information.
Definition: graph_source.h:70
behavior::Node * node() const override
Getter to the node counterpart.
Definition: graph_source.h:83
void sendAndNotifyAllInputs(std::shared_ptr< Input > &data)
Send a piece of data to all input nodes and notify them.
Definition: graph_source.h:63
std::vector< std::pair< std::string const, std::string const > > ids() const override
Node ids [nodeId, nodeGroupId] accessor.
Definition: graph_source.h:76