Hedgehog  0.0.0
A library to generate hybrid pipeline workflow systems
core_graph_source.h
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 #ifndef HEDGEHOG_CORE_GRAPH_SOURCE_H
21 #define HEDGEHOG_CORE_GRAPH_SOURCE_H
22 
23 #include "../../queue/sender/core_queue_sender.h"
24 #include "../../../../behavior/node.h"
25 
27 namespace hh::core {
28 
31 template<class ...GraphInputs>
32 class CoreGraphSource : public CoreQueueSender<GraphInputs> ... {
33  public:
36  CoreNode("Source", NodeType::Source, 1),
37  CoreNotifier("Source", NodeType::Source, 1),
38  CoreQueueNotifier("Source", NodeType::Source, 1),
39  CoreQueueSender<GraphInputs>("Source", NodeType::Source, 1)... {
40  HLOG_SELF(0, "Creating CoreGraphSource")
41  }
42 
44  ~CoreGraphSource() override {HLOG_SELF(0, "Destructing CoreGraphSource")}
45 
48  void visit(AbstractPrinter *printer) override {
49  HLOG_SELF(1, "Visit")
50  if (printer->hasNotBeenVisited(this)) {
51  printer->printNodeInformation(this);
53  }
54  }
55 
58  void addSlot(CoreSlot *slot) final {
59  HLOG_SELF(0, "Add slot: " << slot->name() << "(" << slot->id() << ")")
61  }
62 
66  std::set<CoreSlot *> getSlots() override { return {}; }
67 
69  void notifyAllTerminated() final {
70  HLOG_SELF(2, "Notify all terminated")
72  }
73 
77  [[noreturn]] std::shared_ptr<CoreNode> clone() override {
78  std::ostringstream oss;
79  oss
80  << "Internal error, should not be called, graph's source can't be clone, as an outer graph can't be cloned : "
81  << __FUNCTION__;
82  HLOG_SELF(0, oss.str())
83  throw (std::runtime_error(oss.str()));
84  }
85 
89  [[noreturn]] behavior::Node *node() override {
90  std::ostringstream oss;
91  oss << "Internal error, should not be called, source does not have a node: " << __FUNCTION__;
92  HLOG_SELF(0, oss.str())
93  throw (std::runtime_error(oss.str()));
94  }
95 
100  [[noreturn]] void duplicateEdge(
101  [[maybe_unused]] CoreNode *duplicateNode,
102  [[maybe_unused]] std::map<CoreNode *, std::shared_ptr<CoreNode>> &correspondenceMap) override {
103  std::ostringstream oss;
104  oss << "Internal error, should not be called, source does not have edges to connect in an execution pipeline: "
105  << __FUNCTION__;
106  HLOG_SELF(0, oss.str())
107  throw (std::runtime_error(oss.str()));
108  }
109 };
110 
111 }
112 #endif //HEDGEHOG_CORE_GRAPH_SOURCE_H
CoreGraphSource()
CoreGraphSource default constructor.
behavior::Node * node() override
Get a node from the graph&#39;s source, that does not exist, throw an error in every case.
std::shared_ptr< CoreNode > clone() override
Get a clone of the graph&#39;s source, that does not exist, throw an error in every case.
Core Notifier interface, emit notification to CoreSlot.
Definition: core_notifier.h:34
Part of the outer graph that sends data from the outside to the input nodes.
void visit(AbstractPrinter *printer) override
Special visit method for a CoreQueueSender, printing an edge.
~CoreGraphSource() override
CoreGraphSource default destructor.
void duplicateEdge([[maybe_unused]] CoreNode *duplicateNode, [[maybe_unused]] std::map< CoreNode *, std::shared_ptr< CoreNode >> &correspondenceMap) override
Duplicate edge for a source, throw an error in every case.
Sender for nodes possessing a queue of data.
void notifyAllTerminated() override
Notify all slots that the node is terminated.
Printer interface.
Node Behavior definition.
Definition: node.h:39
Slot interface, receive notification from CoreNotifier.
Definition: core_slot.h:34
bool hasNotBeenVisited(core::CoreNode const *node)
Accessor to check if a node has been visited by the printer.
std::set< CoreSlot * > getSlots() override
Get the graph&#39;s source slot.
void notifyAllTerminated() final
Notify all input nodes possessing a CoreQueueSender of termination.
NodeType
Hedgehog node&#39;s type.
Definition: core_node.h:40
Main Hedgehog core abstraction.
Definition: core_node.h:48
Notifier of CoreQueueSlot.
Hedgehog core namespace.
Definition: core_execute.h:25
void visit(AbstractPrinter *printer) override
Special visit method for graph&#39;s source.
virtual void printNodeInformation(core::CoreNode *node)=0
Print node information.
void addSlot(CoreSlot *slot) final
Add slot to all inputs node possessing a CoreQueueSender.