Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
task_multi_senders.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_TASK_MULTI_SENDERS_H
22#define HEDGEHOG_TASK_MULTI_SENDERS_H
23
24#include "multi_senders.h"
25#include "../../tools/concepts.h"
26#include "../../core/abstractions/node/task_outputs_management_abstraction.h"
28namespace hh {
30namespace behavior {
31
34template<class ...Outputs>
35class TaskMultiSenders : public MultiSenders<Outputs...> {
36 private:
38 tom_ = nullptr;
39
40 public:
45 template<tool::MultiSendersAndNotifierAbstractionConcept MultiSendersAndNotifier>
46 explicit TaskMultiSenders(std::shared_ptr<MultiSendersAndNotifier> abstraction){
47 if (abstraction == nullptr) {
48 throw std::runtime_error("A sender needs to have the abstraction initialized before used.");
49 } else {
50 tom_ = abstraction;
51 }
52 }
53
55 virtual ~TaskMultiSenders() = default;
56
57 protected:
62 template<tool::MatchOutputTypeConcept<Outputs...> DataType>
63 void addResult(std::shared_ptr<DataType> data) {
64 if (tom_ == nullptr) {
65 throw std::runtime_error("A sender needs to have the abstraction initialized before used.");
66 } else {
67 tom_->sendAndNotify(data);
68 }
69 }
70};
71}
72}
73
74#endif //HEDGEHOG_TASK_MULTI_SENDERS_H
Hedgehog main namespace.
Behavior abstraction for nodes that send multiple types of data.
Definition: multi_senders.h:32
Behavior abstraction for tasks that send multiple types of data.
void addResult(std::shared_ptr< DataType > data)
Add result and send it to the task successors.
virtual ~TaskMultiSenders()=default
Default destructor.
std::shared_ptr< core::abstraction::TaskOutputsManagementAbstraction< Outputs... > > tom_
Link to the task's core TaskOutputsManagementAbstraction.
TaskMultiSenders(std::shared_ptr< MultiSendersAndNotifier > abstraction)
Default constructor.
Test if an output type is in the list of output types (variadic)
Definition: concepts.h:105