Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
core_switch.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_CORE_SWITCH_H_
20#define HEDGEHOG_CORE_SWITCH_H_
21
22#include "../../behavior/switch/multi_switch_rules.h"
23
24#include "../abstractions/base/node/node_abstraction.h"
25#include "../abstractions/node/task_outputs_management_abstraction.h"
26
28namespace hh {
30namespace core {
31
34template<class ...Inputs>
37
38 private:
39 behavior::MultiSwitchRules<Inputs...> *const
41
42 public:
46 template<class Switch>
47 requires std::is_base_of_v<behavior::MultiSwitchRules<Inputs...>, Switch>
48 explicit CoreSwitch(Switch *const multiSwitchRules)
49 : abstraction::NodeAbstraction("Switch"),
50 multiSwitchRules_(static_cast<behavior::MultiSwitchRules<Inputs...> *const>(multiSwitchRules)) {}
51
53 ~CoreSwitch() override = default;
54
60 template<tool::ContainsConcept<Inputs...> Input>
61 bool callSendToGraph(std::shared_ptr<Input> &data, size_t const &graphId) {
62 return static_cast<behavior::SwitchRule<Input> *>(multiSwitchRules_)->sendToGraph(data, graphId);
63 }
64
67 [[nodiscard]] std::vector<std::pair<std::string const, std::string const>> ids() const override {
68 return {{this->id(), this->id()}};
69 }
70
74 [[nodiscard]] behavior::Node *node() const override {
75 throw std::runtime_error("Try to get a node out of a core switch while there is none.");
76 }
77};
78}
79}
80#endif //HEDGEHOG_CORE_SWITCH_H_
Hedgehog main namespace.
Behavior abstraction for the base node.
Definition: node.h:32
Switch rules behavior abstraction for different types of input.
Switch rule behavior abstraction for a type of input.
Definition: switch_rule.h:32
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.
virtual size_t graphId() const
Get the graph identifier (got from belonging graph)
Switch core.
Definition: core_switch.h:36
CoreSwitch(Switch *const multiSwitchRules)
Construct a CoreSwitch with a user-defined abstraction with switch rules.
Definition: core_switch.h:48
~CoreSwitch() override=default
Default destructor.
std::vector< std::pair< std::string const, std::string const > > ids() const override
Node ids [nodeId, nodeGroupId] accessor.
Definition: core_switch.h:67
bool callSendToGraph(std::shared_ptr< Input > &data, size_t const &graphId)
Interface to user-defined switch rules.
Definition: core_switch.h:61
behavior::MultiSwitchRules< Inputs... > *const multiSwitchRules_
User-defined abstraction with switch rules.
Definition: core_switch.h:40
behavior::Node * node() const override
Getter to the node counterpart.
Definition: core_switch.h:74
Concept verifying that a type is in a variadic.
Definition: concepts.h:86