dune-typetree 2.9
Loading...
Searching...
No Matches
generictransformationdescriptors.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3
4#ifndef DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
5#define DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
6
7#include <array>
8#include <memory>
9
13#include <dune/common/exceptions.hh>
14
15
16namespace Dune {
17 namespace TypeTree {
18
24 template<typename SourceNode, typename Transformation, typename TransformedNode>
26 {
27
28 static const bool recursive = false;
29
30 typedef TransformedNode transformed_type;
31 typedef std::shared_ptr<transformed_type> transformed_storage_type;
32
33 static transformed_type transform(const SourceNode& s, const Transformation& t)
34 {
35 return transformed_type(s,t);
36 }
37
38 static transformed_type transform(std::shared_ptr<const SourceNode> s, const Transformation& t)
39 {
40 return transformed_type(s,t);
41 }
42
43 static transformed_storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t)
44 {
45 return std::make_shared<transformed_type>(s,t);
46 }
47
48 };
49
50
51 template<typename SourceNode, typename Transformation, template<typename Child> class TransformedNodeTemplate>
53 {
54
55 static const bool recursive = true;
56
57 template<typename TC>
58 struct result
59 {
60 typedef typename TransformedNodeTemplate<TC>::type type;
61 typedef std::shared_ptr<type> storage_type;
62 static const std::size_t degree = StaticDegree<type>::value;
63 };
64
65 template<typename TC>
66 static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::degree>& children)
67 {
68 return typename result<TC>::type(s,t,children);
69 }
70
71 template<typename TC>
72 static typename result<TC>::type transform(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::degree>& children)
73 {
74 return typename result<TC>::type(s,t,children);
75 }
76
77 template<typename TC>
78 static typename result<TC>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::array<std::shared_ptr<TC>,result<TC>::degree>& children)
79 {
80 return std::make_shared<typename result<TC>::type>(s,t,children);
81 }
82
83 };
84
85
86 template<typename SourceNode, typename Transformation, template<typename,typename,std::size_t> class TransformedNode>
89 Transformation,
90 GenericPowerNodeTransformationTemplate<SourceNode,
91 Transformation,
92 TransformedNode>::template result
93 >
94 {};
95
96
97 template<typename SourceNode, typename Transformation, template<typename Child> class TransformedNodeTemplate>
99 {
100
101 static const bool recursive = true;
102
103 template<typename TC>
104 struct result
105 {
106 typedef typename TransformedNodeTemplate<TC>::type type;
107 typedef std::shared_ptr<type> storage_type;
108 };
109
110 template<typename TC>
111 static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const std::vector<std::shared_ptr<TC>>& children)
112 {
113 return typename result<TC>::type(s,t,children);
114 }
115
116 template<typename TC>
117 static typename result<TC>::type transform(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::vector<std::shared_ptr<TC>>& children)
118 {
119 return typename result<TC>::type(s,t,children);
120 }
121
122 template<typename TC>
123 static typename result<TC>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, const std::vector<std::shared_ptr<TC>>& children)
124 {
125 return std::make_shared<typename result<TC>::type>(s,t,children);
126 }
127
128 };
129
130
131 template<typename SourceNode, typename Transformation, template<typename,typename> class TransformedNode>
134 Transformation,
135 GenericDynamicPowerNodeTransformationTemplate<SourceNode,
136 Transformation,
137 TransformedNode>::template result
138 >
139 {};
140
141
142 template<typename SourceNode, typename Transformation, template<typename...> class TransformedNodeTemplate>
144 {
145
146 static const bool recursive = true;
147
148 template<typename... TC>
149 struct result
150 {
151 typedef typename TransformedNodeTemplate<TC...>::type type;
152 typedef std::shared_ptr<type> storage_type;
153 };
154
155 template<typename... TC>
156 static typename result<TC...>::type transform(const SourceNode& s, const Transformation& t, std::shared_ptr<TC>... children)
157 {
158 return typename result<TC...>::type(s,t,children...);
159 }
160
161 template<typename... TC>
162 static typename result<TC...>::type transform(std::shared_ptr<const SourceNode> s, const Transformation& t, std::shared_ptr<TC>... children)
163 {
164 return typename result<TC...>::type(s,t,children...);
165 }
166
167 template<typename... TC>
168 static typename result<TC...>::storage_type transform_storage(std::shared_ptr<const SourceNode> s, const Transformation& t, std::shared_ptr<TC>... children)
169 {
170 return std::make_shared<typename result<TC...>::type>(s,t,children...);
171 }
172
173 };
174
175
176 template<typename SourceNode, typename Transformation, template<typename,typename...> class TransformedNode>
179 Transformation,
180 GenericCompositeNodeTransformationTemplate<SourceNode,
181 Transformation,
182 TransformedNode>::template result
183 >
184 {};
185
187
188 } // namespace TypeTree
189} //namespace Dune
190
191#endif // DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
decltype(Node::degree()) StaticDegree
Returns the statically known degree of the given Node type as a std::integral_constant.
Definition nodeinterface.hh:113
Definition accumulate_static.hh:13
Definition generictransformationdescriptors.hh:26
TransformedNode transformed_type
Definition generictransformationdescriptors.hh:30
std::shared_ptr< transformed_type > transformed_storage_type
Definition generictransformationdescriptors.hh:31
static transformed_type transform(std::shared_ptr< const SourceNode > s, const Transformation &t)
Definition generictransformationdescriptors.hh:38
static const bool recursive
Definition generictransformationdescriptors.hh:28
static transformed_storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t)
Definition generictransformationdescriptors.hh:43
static transformed_type transform(const SourceNode &s, const Transformation &t)
Definition generictransformationdescriptors.hh:33
Definition generictransformationdescriptors.hh:53
static result< TC >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition generictransformationdescriptors.hh:78
static const bool recursive
Definition generictransformationdescriptors.hh:55
static result< TC >::type transform(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition generictransformationdescriptors.hh:72
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::array< std::shared_ptr< TC >, result< TC >::degree > &children)
Definition generictransformationdescriptors.hh:66
Definition generictransformationdescriptors.hh:59
TransformedNodeTemplate< TC >::type type
Definition generictransformationdescriptors.hh:60
static const std::size_t degree
Definition generictransformationdescriptors.hh:62
std::shared_ptr< type > storage_type
Definition generictransformationdescriptors.hh:61
Definition generictransformationdescriptors.hh:94
Definition generictransformationdescriptors.hh:99
static result< TC >::type transform(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition generictransformationdescriptors.hh:117
static const bool recursive
Definition generictransformationdescriptors.hh:101
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition generictransformationdescriptors.hh:111
static result< TC >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, const std::vector< std::shared_ptr< TC > > &children)
Definition generictransformationdescriptors.hh:123
Definition generictransformationdescriptors.hh:105
TransformedNodeTemplate< TC >::type type
Definition generictransformationdescriptors.hh:106
std::shared_ptr< type > storage_type
Definition generictransformationdescriptors.hh:107
Definition generictransformationdescriptors.hh:139
Definition generictransformationdescriptors.hh:144
static result< TC... >::type transform(const SourceNode &s, const Transformation &t, std::shared_ptr< TC >... children)
Definition generictransformationdescriptors.hh:156
static result< TC... >::storage_type transform_storage(std::shared_ptr< const SourceNode > s, const Transformation &t, std::shared_ptr< TC >... children)
Definition generictransformationdescriptors.hh:168
static result< TC... >::type transform(std::shared_ptr< const SourceNode > s, const Transformation &t, std::shared_ptr< TC >... children)
Definition generictransformationdescriptors.hh:162
static const bool recursive
Definition generictransformationdescriptors.hh:146
Definition generictransformationdescriptors.hh:150
TransformedNodeTemplate< TC... >::type type
Definition generictransformationdescriptors.hh:151
std::shared_ptr< type > storage_type
Definition generictransformationdescriptors.hh:152
Definition generictransformationdescriptors.hh:184