Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
meta_functions.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_CX_METAFUNCTIONS_H_
20#define HEDGEHOG_CX_METAFUNCTIONS_H_
21
22#ifdef HH_ENABLE_HH_CX
23
24#include <tuple>
25
26#include "../../src/api/task/abstract_task.h"
27#include "../../src/api/state_manager/state_manager.h"
28#include "../../src/api/graph/graph.h"
29
30
32namespace hh_cx {
33
35namespace tool {
36
38namespace internals {
39
42template<size_t Separator, class AllTypes>
43struct HelperAbstractTaskType;
44
47template<size_t Separator, class ...AllTypes>
48struct HelperAbstractTaskType<Separator, std::tuple<AllTypes...>> {
49 using type = hh::AbstractTask<Separator, AllTypes...>;
50};
51
54template<size_t Separator, class AllTypes>
55struct HelperStateManagerType;
56
59template<size_t Separator, class ...AllTypes>
60struct HelperStateManagerType<Separator, std::tuple<AllTypes...>> {
61 using type = hh::StateManager<Separator, AllTypes...>;
62};
63
67template<size_t Separator, class AllTypes>
68struct GraphTypeDeducer;
69
73template<size_t Separator, class ...AllTypes>
74struct GraphTypeDeducer<Separator, std::tuple<AllTypes...>> {
76 using type = hh::Graph<Separator, AllTypes...>;
77};
78
80template<class, class>
81struct CatTuples;
82
86template<class... First, class... Second>
87struct CatTuples<std::tuple<First...>, std::tuple<Second...>> {
89 using type = std::tuple<First..., Second...>;
90};
91
94template<class Tuple>
95class UniqueVariantFromTuple;
96
99template<class ...AllTypes>
100class UniqueVariantFromTuple<std::tuple<AllTypes...>> {
102 class MakeUnique {
103 private:
108 template<class Current, class ... Others>
109 static auto makeUniqueTuple() {
110 if constexpr (sizeof...(Others) == 0) {
111 return std::tuple<Current *>{};
112 } else {
113 if constexpr (std::disjunction_v<std::is_same<Current, Others>...>) {
114 return makeUniqueTuple<Others...>();
115 } else {
116 return std::tuple_cat(std::tuple<Current *>{}, makeUniqueTuple<Others...>());
117 }
118 }
119 }
120
124 template<class ... TupleType>
125 static auto makeVariant(std::tuple<TupleType...>) {
126 return (std::variant<std::remove_pointer_t<TupleType>...>());
127 }
128
129 public:
131 using type = decltype(makeUniqueTuple<AllTypes...>());
133 using variant_type = decltype(makeVariant(std::declval<type>()));
134 };
135
136 public:
138 using type = typename MakeUnique::variant_type;
139};
140} // internals
141
143template<class Tuple>
144using UniqueVariantFromTuple_t = typename internals::UniqueVariantFromTuple<Tuple>::type;
145
147template<size_t Separator, class AllTypes>
148using StateManager_t = typename tool::internals::HelperStateManagerType<Separator, AllTypes>::type;
149
151template<size_t Separator, class AllTypes>
152using AbstractTask_t = typename tool::internals::HelperAbstractTaskType<Separator, AllTypes>::type;
153
155template<size_t Separator, class AllTypes>
156using Graph_t = typename tool::internals::GraphTypeDeducer<Separator, AllTypes>::type;
157
159template<class First, class Second>
160using CatTuples_t = typename tool::internals::CatTuples<First, Second>::type;
161} // tool
162
163} // hh_cx
164#endif //HH_ENABLE_HH_CX
165#endif //HEDGEHOG_CX_METAFUNCTIONS_H_
Hedgehog graph abstraction.
Definition: graph.h:137
AbstractState manager.
Definition: state_manager.h:66
Base node for computation.