Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
concepts.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_CONCEPTS_H
22#define HEDGEHOG_CONCEPTS_H
23#pragma once
24
25#include <type_traits>
26
27#include "meta_functions.h"
28
30namespace hh {
31
32#ifndef DOXYGEN_SHOULD_SKIP_THIS
34namespace core {
35
37namespace abstraction {
39class SlotAbstraction;
41class NotifierAbstraction;
43class NodeAbstraction;
46template<class Input>
47class ReceiverAbstraction;
50template<class Output>
51class SenderAbstraction;
52}
53
55namespace implementor {
57class ImplementorSlot;
59class ImplementorNotifier;
62template<class Input>
63class ImplementorReceiver;
66template<class Input>
67class ImplementorExecute;
70template<class Output>
71class ImplementorSender;
72}
73}
74
76class ManagedMemory;
77#endif //DOXYGEN_SHOULD_SKIP_THIS
78
80namespace tool {
81
85template<class T, class ...Ts>
86concept ContainsConcept = isContainedIn_v<T, Ts...>; // The type T is not in Ts...
87
91template<class T, class Tuple>
92concept ContainsInTupleConcept = isContainedInTuple_v<T, Tuple>; // The type T is not in Ts...
93
97template<class I, class Is>
99ContainsInTupleConcept<I, Is>; // The input type (I) should be part of the list of input types (Is)
100
104template<class O, class ...Os>
106ContainsConcept<O, Os...>; // The output type (O) should be part of the list of output types (Os)
107
111template<class T, class ...Os>
113(std::is_base_of_v<core::abstraction::SenderAbstraction<Os>, T> && ...) &&
114 std::is_base_of_v<core::abstraction::NotifierAbstraction, T>;
115
118template<class T>
120std::is_base_of_v<ManagedMemory, T> // Derives from ManagedMemory
121 && std::is_default_constructible_v<T>; // default constructible
122
129template<class CoreNode, class TupleCoreInputs, class TupleGraphInputs>
131std::is_base_of_v<core::abstraction::NodeAbstraction, CoreNode> // The core given derives from NodeAbstraction
132 && std::tuple_size_v<Intersect_t<TupleCoreInputs, TupleGraphInputs>> != 0; // There is at least one common type
133
134
141template<class CoreNode, class InputType, class TupleCoreInputs, class TupleGraphInputs>
143std::is_base_of_v<core::abstraction::NodeAbstraction, CoreNode> // The core given derives from NodeAbstraction
144 && ContainsInTupleConcept<InputType, TupleGraphInputs> // The input type is part of the graph input types
145 && ContainsInTupleConcept<InputType, TupleCoreInputs>; // The input type is part of the core input types
146
152template<class CoreNode, class TupleCoreOutputs, class TupleGraphOutputs>
154std::is_base_of_v<core::abstraction::NodeAbstraction, CoreNode> // The core given derives from NodeAbstraction
155 && std::tuple_size_v<Intersect_t<TupleCoreOutputs,
156 TupleGraphOutputs>> != 0; // There is at least one common type
157
158
165template<class CoreNode, class OutputType, class TupleCoreOutputs, class TupleGraphOutputs>
167std::is_base_of_v<core::abstraction::NodeAbstraction, CoreNode> // The core given derives from NodeAbstraction
168 && ContainsInTupleConcept<OutputType, TupleGraphOutputs> // The output type is part of the graph output types
169 && ContainsInTupleConcept<OutputType, TupleCoreOutputs>; // The output type is part of the core output types
170
174template<class NodeType>
175concept SenderNode =
176std::is_base_of_v<behavior::Node, NodeType> // The node derives from Node
177 && requires(NodeType *node){
178 typename NodeType::outputs_t; // The node has its output types accessible
179 std::is_base_of_v<behavior::MultiSenders<typename NodeType::outputs_t>, NodeType
180 >; // The node derives from MultiSenders
181 };
182
185template<class NodeType>
187std::is_base_of_v<behavior::Node, NodeType> // The node derives from Node
188 && requires(NodeType *node){
189 typename NodeType::inputs_t; // The node has its input types accessible
190 std::is_base_of_v<behavior::MultiReceivers<typename NodeType::inputs_t>, NodeType
191 >; // The node derives from MultiReceivers
192 };
193
197template<class NodeType, class OutputType>
199SenderNode<NodeType> // The node is a sender node
200 && ContainsInTupleConcept<OutputType,
201 typename NodeType::outputs_t>; // The OutputType is part of the sender output types
202
206template<class NodeType, class InputType>
208ReceiverNode<NodeType> // The node is a receiver node
209 && ContainsInTupleConcept<InputType,
210 typename NodeType::inputs_t>; // The InputType is part of the sender input types
211
215template<class NodeType, class TupleGraphInputs>
217ReceiverNode<NodeType> // The node is a receiver node
218 && std::tuple_size_v<
219 Intersect_t<typename NodeType::inputs_t, TupleGraphInputs>
220 > != 0; // There is at least one common type between the task and graph input types
221
226template<class NodeType, class InputType, class TupleGraphInputs>
228ReceiverNodeForAType<NodeType, InputType> // The node is a receiver node
229 && ContainsInTupleConcept<InputType, TupleGraphInputs>; // The input type is part of the graph input types
230
234template<class NodeType, class TupleGraphOutputs>
236SenderNode<NodeType> // The node is a sender node
237 && std::tuple_size_v<
238 Intersect_t<typename NodeType::outputs_t, TupleGraphOutputs>
239 > != 0; // There is at least one common type between the task and graph output types
240
245template<class NodeType, class OutputType, class TupleGraphOutputs>
247SenderNodeForAType<NodeType, OutputType> // The node is a sender node
248 && ContainsInTupleConcept<OutputType, TupleGraphOutputs>; // The output type is part of the graph output types
249
252template<class NodeType>
253concept CopyableNode = requires(NodeType *n){
254 { n->copy() }; // Check if the copy method is available
255 std::is_same_v<decltype(n->copy()), std::shared_ptr<NodeType>>; // Check if copy() returns the right type
256};
257
262template<class MultiReceiver, class ...InputTypes>
264(std::is_base_of_v<core::implementor::ImplementorReceiver<InputTypes>, MultiReceiver>, ...);
265
270template<class MultiSender, class ...OutputTypes>
272(std::is_base_of_v<core::implementor::ImplementorSender<OutputTypes>, MultiSender>, ...);
273
278template<class MultiExecute, class ...InputTypes>
280(std::is_base_of_v<core::implementor::ImplementorExecute<InputTypes>, MultiExecute>, ...);
281
282}
283}
284#endif //HEDGEHOG_CONCEPTS_H
Hedgehog main namespace.
typename internals::Intersect< Tuple1, Tuple2 >::type Intersect_t
Helper getting the intersection of types between two type tuples.
constexpr bool isContainedIn_v
Helper testing if a type T is in variadic Ts.
Concept verifying that a type is in a variadic.
Definition: concepts.h:86
Concept verifying that a type is in a tuple.
Definition: concepts.h:92
Test if an input type is in the list of input types (tuple)
Definition: concepts.h:98
Test if an output type is in the list of output types (variadic)
Definition: concepts.h:105
Test if a type inherit from core::abstraction::SenderAbstraction for all Os and core::abstraction::No...
Definition: concepts.h:112
Test if a type T is manageable in a Memory manager (derives from ManagedMemory and is default constru...
Definition: concepts.h:119
Test if a core can be input of a graph (derives from core::abstraction::NodeAbstraction and shares at...
Definition: concepts.h:130
Test if a core can be input of a graph for a type (derives from core::abstraction::NodeAbstraction an...
Definition: concepts.h:142
Test if a core can be output of a graph (derives from core::abstraction::NodeAbstraction and shares a...
Definition: concepts.h:153
Test if a core can be output of a graph for a type (derives from core::abstraction::NodeAbstraction a...
Definition: concepts.h:166
Test if a node is a sender node.
Definition: concepts.h:175
Test if a node is a receiver node.
Definition: concepts.h:186
Test if a node is a sender for a type.
Definition: concepts.h:198
Test if a node is a receiver for a type.
Definition: concepts.h:207
Test if a node can be input of a graph.
Definition: concepts.h:216
Test if a node can be input of a graph for a type.
Definition: concepts.h:227
Test if a node can be output of a graph.
Definition: concepts.h:235
Test if a node can be output of a graph for a type.
Definition: concepts.h:246
Test if a node is copyable (copy method is callable and has a the right return type)
Definition: concepts.h:253
Test if a type is a valid concrete implementation of the core::implementor::ImplementorReceiver for t...
Definition: concepts.h:263
Test if a type is a valid concrete implementation of the core::implementor::ImplementorSender for the...
Definition: concepts.h:271
Test if a type is a valid concrete implementation of the core::implementor::ImplementorExecute for th...
Definition: concepts.h:279