dune-typetree  2.3.1
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 
9 #include <dune/common/exceptions.hh>
10 #include <dune/common/shared_ptr.hh>
11 #include <dune/common/array.hh>
12 #include <dune/common/tuples.hh>
13 
14 
15 namespace Dune {
16  namespace TypeTree {
17 
23  template<typename SourceNode, typename Transformation, typename TransformedNode>
25  {
26 
27  static const bool recursive = false;
28 
29  typedef TransformedNode transformed_type;
30  typedef shared_ptr<transformed_type> transformed_storage_type;
31 
32  static transformed_type transform(const SourceNode& s, const Transformation& t)
33  {
34  return transformed_type(s,t);
35  }
36 
37  static transformed_type transform(shared_ptr<const SourceNode> s, const Transformation& t)
38  {
39  return transformed_type(s,t);
40  }
41 
42  static transformed_storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t)
43  {
44  return make_shared<transformed_type>(s,t);
45  }
46 
47  };
48 
49 
50  template<typename SourceNode, typename Transformation, template<typename Child> class TransformedNodeTemplate>
52  {
53 
54  static const bool recursive = true;
55 
56  template<typename TC>
57  struct result
58  {
59  typedef typename TransformedNodeTemplate<TC>::type type;
60  typedef shared_ptr<type> storage_type;
61  };
62 
63  template<typename TC>
64  static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
65  {
66  return typename result<TC>::type(s,t,children);
67  }
68 
69  template<typename TC>
70  static typename result<TC>::type transform(shared_ptr<const SourceNode> s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
71  {
72  return typename result<TC>::type(s,t,children);
73  }
74 
75  template<typename TC>
76  static typename result<TC>::storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
77  {
78  return make_shared<typename result<TC>::type>(s,t,children);
79  }
80 
81  };
82 
83 
84  template<typename SourceNode, typename Transformation, template<typename,typename,std::size_t> class TransformedNode>
87  Transformation,
88  GenericPowerNodeTransformationTemplate<SourceNode,
89  Transformation,
90  TransformedNode>::template result
91  >
92  {};
93 
94 
95 #if HAVE_VARIADIC_TEMPLATES
96 
97  template<typename SourceNode, typename Transformation, template<typename...> class TransformedNodeTemplate>
98  struct TemplatizedGenericVariadicCompositeNodeTransformation
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 shared_ptr<type> storage_type;
108  };
109 
110  template<typename... TC>
111  static typename result<TC...>::type transform(const SourceNode& s, const Transformation& t, 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(shared_ptr<const SourceNode> s, const Transformation& t, 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(shared_ptr<const SourceNode> s, const Transformation& t, shared_ptr<TC>... children)
124  {
125  return 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>
132  struct GenericVariadicCompositeNodeTransformation
133  : public TemplatizedGenericVariadicCompositeNodeTransformation<SourceNode,
134  Transformation,
135  GenericVariadicCompositeNodeTransformationTemplate<SourceNode,
136  Transformation,
137  TransformedNode>::template result
138  >
139  {};
140 
141 #endif // HAVE_VARIADIC_TEMPLATES
142 
143 
144  template<typename SourceNode, typename Transformation, template<typename C0,
145  typename C1,
146  typename C2,
147  typename C3,
148  typename C4,
149  typename C5,
150  typename C6,
151  typename C7,
152  typename C8,
153  typename C9
154  > class TransformedNodeTemplate>
156  {
157 
158  static const bool recursive = true;
159 
160  template<typename TC0,
161  typename TC1,
162  typename TC2,
163  typename TC3,
164  typename TC4,
165  typename TC5,
166  typename TC6,
167  typename TC7,
168  typename TC8,
169  typename TC9>
170  struct result
171  {
172  typedef typename TransformedNodeTemplate<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::type type;
173  typedef shared_ptr<type> storage_type;
174  };
175 
176  template<typename TC0,
177  typename TC1,
178  typename TC2,
179  typename TC3,
180  typename TC4,
181  typename TC5,
182  typename TC6,
183  typename TC7,
184  typename TC8,
185  typename TC9>
187  transform(const SourceNode& s,
188  const Transformation& t,
189  shared_ptr<TC0> c0,
190  shared_ptr<TC1> c1,
191  shared_ptr<TC2> c2,
192  shared_ptr<TC3> c3,
193  shared_ptr<TC4> c4,
194  shared_ptr<TC5> c5,
195  shared_ptr<TC6> c6,
196  shared_ptr<TC7> c7,
197  shared_ptr<TC8> c8,
198  shared_ptr<TC9> c9)
199  {
200  return typename result<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::type(s,t,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9);
201  }
202 
203  template<typename TC0,
204  typename TC1,
205  typename TC2,
206  typename TC3,
207  typename TC4,
208  typename TC5,
209  typename TC6,
210  typename TC7,
211  typename TC8,
212  typename TC9>
213  static typename result<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::storage_type
214  transform_storage(shared_ptr<const SourceNode> s,
215  const Transformation& t,
216  shared_ptr<TC0> c0,
217  shared_ptr<TC1> c1,
218  shared_ptr<TC2> c2,
219  shared_ptr<TC3> c3,
220  shared_ptr<TC4> c4,
221  shared_ptr<TC5> c5,
222  shared_ptr<TC6> c6,
223  shared_ptr<TC7> c7,
224  shared_ptr<TC8> c8,
225  shared_ptr<TC9> c9)
226  {
227  return make_shared<typename result<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::type>(s,t,c0,c1,c2,c3,c4,c5,c6,c7,c8,c9);
228  }
229 
230  };
231 
232 
233  template<typename SourceNode, typename Transformation, template<typename Source,
234  typename C0,
235  typename C1,
236  typename C2,
237  typename C3,
238  typename C4,
239  typename C5,
240  typename C6,
241  typename C7,
242  typename C8,
243  typename C9> class TransformedNode>
246  Transformation,
247  GenericCompositeNodeTransformationTemplate<SourceNode,
248  Transformation,
249  TransformedNode>::template result
250  >
251  {};
252 
253 
255 
256  } // namespace TypeTree
257 } //namespace Dune
258 
259 #endif // DUNE_TYPETREE_GENERICTRANSFORMATIONDESCRIPTORS_HH
static result< TC >::type transform(shared_ptr< const SourceNode > s, const Transformation &t, const array< shared_ptr< TC >, result< TC >::type::CHILDREN > &children)
Definition: generictransformationdescriptors.hh:70
static const bool recursive
Definition: generictransformationdescriptors.hh:54
static result< TC0, TC1, TC2, TC3, TC4, TC5, TC6, TC7, TC8, TC9 >::type transform(const SourceNode &s, const Transformation &t, shared_ptr< TC0 > c0, shared_ptr< TC1 > c1, shared_ptr< TC2 > c2, shared_ptr< TC3 > c3, shared_ptr< TC4 > c4, shared_ptr< TC5 > c5, shared_ptr< TC6 > c6, shared_ptr< TC7 > c7, shared_ptr< TC8 > c8, shared_ptr< TC9 > c9)
Definition: generictransformationdescriptors.hh:187
static transformed_storage_type transform_storage(shared_ptr< const SourceNode > s, const Transformation &t)
Definition: generictransformationdescriptors.hh:42
Definition: generictransformationdescriptors.hh:85
TransformedNodeTemplate< TC >::type type
Definition: generictransformationdescriptors.hh:59
Definition: generictransformationdescriptors.hh:51
TransformedNode transformed_type
Definition: generictransformationdescriptors.hh:29
Definition: generictransformationdescriptors.hh:244
TransformedNodeTemplate< TC0, TC1, TC2, TC3, TC4, TC5, TC6, TC7, TC8, TC9 >::type type
Definition: generictransformationdescriptors.hh:172
static const bool recursive
Definition: generictransformationdescriptors.hh:27
static transformed_type transform(const SourceNode &s, const Transformation &t)
Definition: generictransformationdescriptors.hh:32
shared_ptr< type > storage_type
Definition: generictransformationdescriptors.hh:173
static const result_type result
Definition: accumulate_static.hh:108
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const array< shared_ptr< TC >, result< TC >::type::CHILDREN > &children)
Definition: generictransformationdescriptors.hh:64
Definition: generictransformationdescriptors.hh:24
shared_ptr< type > storage_type
Definition: generictransformationdescriptors.hh:60
Definition: generictransformationdescriptors.hh:155
static transformed_type transform(shared_ptr< const SourceNode > s, const Transformation &t)
Definition: generictransformationdescriptors.hh:37
static result< TC0, TC1, TC2, TC3, TC4, TC5, TC6, TC7, TC8, TC9 >::storage_type transform_storage(shared_ptr< const SourceNode > s, const Transformation &t, shared_ptr< TC0 > c0, shared_ptr< TC1 > c1, shared_ptr< TC2 > c2, shared_ptr< TC3 > c3, shared_ptr< TC4 > c4, shared_ptr< TC5 > c5, shared_ptr< TC6 > c6, shared_ptr< TC7 > c7, shared_ptr< TC8 > c8, shared_ptr< TC9 > c9)
Definition: generictransformationdescriptors.hh:214
shared_ptr< transformed_type > transformed_storage_type
Definition: generictransformationdescriptors.hh:30
Definition: generictransformationdescriptors.hh:57
static result< TC >::storage_type transform_storage(shared_ptr< const SourceNode > s, const Transformation &t, const array< shared_ptr< TC >, result< TC >::type::CHILDREN > &children)
Definition: generictransformationdescriptors.hh:76
Definition: generictransformationdescriptors.hh:170