Hedgehog  0.0.0
A library to generate hybrid pipeline workflow systems
core_sender.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_SENDER_H
21 #define HEDGEHOG_CORE_SENDER_H
22 
23 #include <set>
24 
25 #include "core_notifier.h"
26 #include "../../../node/core_node.h"
27 #include "../receiver/core_receiver.h"
28 
30 namespace hh::core {
31 
34 template<class Output>
35 class CoreSender : public virtual CoreNotifier {
36  public:
37 
42  CoreSender(std::string_view const &name, NodeType const type, size_t const numberThreads) :
43  CoreNode(name, type, numberThreads) {
44  HLOG_SELF(0, "Creating CoreSender with type: " << (int) type << " and name: " << name)
45  }
46 
48  ~CoreSender() override {HLOG_SELF(0, "Destructing CoreSender")}
49 
52  virtual void addReceiver(CoreReceiver <Output> *receiver) = 0;
53 
56  virtual void removeReceiver(CoreReceiver <Output> *receiver) = 0;
57 
60  virtual void sendAndNotify(std::shared_ptr<Output> data) = 0;
61 
64  virtual std::set<CoreSender<Output> *> getSenders() = 0;
65 
69  void duplicateEdge(CoreNode *duplicateNode,
70  std::map<CoreNode *, std::shared_ptr<CoreNode>> &correspondenceMap) override {
71  for (auto sender : this->getSenders()) {
72  sender->duplicateEdge(duplicateNode, correspondenceMap);
73  }
74  }
75 };
76 
77 }
78 #endif //HEDGEHOG_CORE_SENDER_H
NodeType type() const
Node type accessor.
Definition: core_node.h:132
Receiver Interface, receive one data type from CoreSender.
Definition: core_receiver.h:44
virtual void sendAndNotify(std::shared_ptr< Output > data)=0
Interface to send and notify a data to all connected CoreReceiver.
Core Notifier interface, emit notification to CoreSlot.
Definition: core_notifier.h:34
virtual void addReceiver(CoreReceiver< Output > *receiver)=0
Interface to add a CoreReceiver to this CoreSender.
~CoreSender() override
CoreSender destructor.
Definition: core_sender.h:48
virtual void removeReceiver(CoreReceiver< Output > *receiver)=0
Interface to remove a CoreReceiver from this CoreSender.
NodeType
Hedgehog node&#39;s type.
Definition: core_node.h:40
Sender interface, send data to CoreReceiver.
Definition: core_sender.h:35
CoreSender(std::string_view const &name, NodeType const type, size_t const numberThreads)
CoreSender constructor.
Definition: core_sender.h:42
Main Hedgehog core abstraction.
Definition: core_node.h:48
void duplicateEdge(CoreNode *duplicateNode, std::map< CoreNode *, std::shared_ptr< CoreNode >> &correspondenceMap) override
Duplicate all the edges from this to it&#39;s copy duplicateNode.
Definition: core_sender.h:69
Hedgehog core namespace.
Definition: core_execute.h:25
virtual std::set< CoreSender< Output > * > getSenders()=0
Get inner CoreSender represented by this one in the case of outer graph for example.
std::string_view const & name() const
Node name accessor.
Definition: core_node.h:128
size_t numberThreads() const
Number of threads associated accessor.
Definition: core_node.h:152