dune-typetree  2.3.1
simpletransformationdescriptors.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_SIMPLETRANSFORMATIONDESCRIPTORS_HH
5 #define DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
6 
8 #include <dune/common/exceptions.hh>
9 #include <dune/common/shared_ptr.hh>
10 #include <dune/common/array.hh>
11 #include <dune/common/tuples.hh>
12 
13 
14 namespace Dune {
15  namespace TypeTree {
16 
22  template<typename SourceNode, typename Transformation, typename TransformedNode>
24  {
25 
26  static const bool recursive = false;
27 
28  typedef TransformedNode transformed_type;
29  typedef shared_ptr<transformed_type> transformed_storage_type;
30 
31  static transformed_type transform(const SourceNode& s, const Transformation& t)
32  {
33  return transformed_type();
34  }
35 
36  static transformed_storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t)
37  {
38  return make_shared<transformed_type>();
39  }
40 
41  };
42 
43 
44  template<typename SourceNode, typename Transformation, template<typename Child, std::size_t> class TransformedNode>
46  {
47 
48  static const bool recursive = true;
49 
50  template<typename TC>
51  struct result
52  {
53  typedef TransformedNode<TC, SourceNode::CHILDREN> type;
54  typedef shared_ptr<type> storage_type;
55  };
56 
57  template<typename TC>
58  static typename result<TC>::type transform(const SourceNode& s, const Transformation& t, const array<shared_ptr<TC>,result<TC>::type::CHILDREN>& children)
59  {
60  return typename result<TC>::type(children);
61  }
62 
63  template<typename TC>
64  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)
65  {
66  return make_shared<typename result<TC>::type>(children);
67  }
68 
69  };
70 
71 
72 #if HAVE_VARIADIC_TEMPLATES
73 
74  template<typename SourceNode, typename Transformation, template<typename...> class TransformedNode>
75  struct SimpleVariadicCompositeNodeTransformation
76  {
77 
78  static const bool recursive = true;
79 
80  template<typename... TC>
81  struct result
82  {
83  typedef TransformedNode<TC...> type;
84  typedef shared_ptr<type> storage_type;
85  };
86 
87  template<typename... TC>
88  static typename result<TC...>::type transform(const SourceNode& s, const Transformation& t, shared_ptr<TC>... children)
89  {
90  return typename result<TC...>::type(children...);
91  }
92 
93  template<typename... TC>
94  static typename result<TC...>::storage_type transform_storage(shared_ptr<const SourceNode> s, const Transformation& t, shared_ptr<TC>... children)
95  {
96  return make_shared<typename result<TC...>::type>(children...);
97  }
98 
99  };
100 
101 #endif // HAVE_VARIADIC_TEMPLATES
102 
103 
104  template<typename SourceNode, typename Transformation, template<typename C0,
105  typename C1,
106  typename C2,
107  typename C3,
108  typename C4,
109  typename C5,
110  typename C6,
111  typename C7,
112  typename C8,
113  typename C9
114  > class TransformedNode>
116  {
117 
118  static const bool recursive = true;
119 
120  template<typename TC0,
121  typename TC1,
122  typename TC2,
123  typename TC3,
124  typename TC4,
125  typename TC5,
126  typename TC6,
127  typename TC7,
128  typename TC8,
129  typename TC9>
130  struct result
131  {
132  typedef TransformedNode<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9> type;
133  typedef shared_ptr<type> storage_type;
134  };
135 
136  template<typename TC0,
137  typename TC1,
138  typename TC2,
139  typename TC3,
140  typename TC4,
141  typename TC5,
142  typename TC6,
143  typename TC7,
144  typename TC8,
145  typename TC9>
147  transform(const SourceNode& s,
148  const Transformation& t,
149  shared_ptr<TC0> c0,
150  shared_ptr<TC1> c1,
151  shared_ptr<TC2> c2,
152  shared_ptr<TC3> c3,
153  shared_ptr<TC4> c4,
154  shared_ptr<TC5> c5,
155  shared_ptr<TC6> c6,
156  shared_ptr<TC7> c7,
157  shared_ptr<TC8> c8,
158  shared_ptr<TC9> c9)
159  {
160  return typename result<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::type(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9);
161  }
162 
163  template<typename TC0,
164  typename TC1,
165  typename TC2,
166  typename TC3,
167  typename TC4,
168  typename TC5,
169  typename TC6,
170  typename TC7,
171  typename TC8,
172  typename TC9>
173  static typename result<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::storage_type
174  transform_storage(shared_ptr<const SourceNode> s,
175  const Transformation& t,
176  shared_ptr<TC0> c0,
177  shared_ptr<TC1> c1,
178  shared_ptr<TC2> c2,
179  shared_ptr<TC3> c3,
180  shared_ptr<TC4> c4,
181  shared_ptr<TC5> c5,
182  shared_ptr<TC6> c6,
183  shared_ptr<TC7> c7,
184  shared_ptr<TC8> c8,
185  shared_ptr<TC9> c9)
186  {
187  return make_shared<typename result<TC0,TC1,TC2,TC3,TC4,TC5,TC6,TC7,TC8,TC9>::type>(c0,c1,c2,c3,c4,c5,c6,c7,c8,c9);
188  }
189 
190  };
191 
193 
194  } // namespace TypeTree
195 } //namespace Dune
196 
197 #endif // DUNE_TYPETREE_SIMPLETRANSFORMATIONDESCRIPTORS_HH
TransformedNode< TC0, TC1, TC2, TC3, TC4, TC5, TC6, TC7, TC8, TC9 > type
Definition: simpletransformationdescriptors.hh:132
Definition: simpletransformationdescriptors.hh:51
Definition: simpletransformationdescriptors.hh:115
static result< TC >::type transform(const SourceNode &s, const Transformation &t, const array< shared_ptr< TC >, result< TC >::type::CHILDREN > &children)
Definition: simpletransformationdescriptors.hh:58
Definition: simpletransformationdescriptors.hh:23
static const bool recursive
Definition: simpletransformationdescriptors.hh:26
shared_ptr< type > storage_type
Definition: simpletransformationdescriptors.hh:133
TransformedNode transformed_type
Definition: simpletransformationdescriptors.hh:28
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: simpletransformationdescriptors.hh:64
Definition: simpletransformationdescriptors.hh:45
static const result_type result
Definition: accumulate_static.hh:108
static transformed_type transform(const SourceNode &s, const Transformation &t)
Definition: simpletransformationdescriptors.hh:31
Definition: simpletransformationdescriptors.hh:130
shared_ptr< type > storage_type
Definition: simpletransformationdescriptors.hh:54
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: simpletransformationdescriptors.hh:174
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: simpletransformationdescriptors.hh:147
shared_ptr< transformed_type > transformed_storage_type
Definition: simpletransformationdescriptors.hh:29
static const bool recursive
Definition: simpletransformationdescriptors.hh:48
static transformed_storage_type transform_storage(shared_ptr< const SourceNode > s, const Transformation &t)
Definition: simpletransformationdescriptors.hh:36
TransformedNode< TC, SourceNode::CHILDREN > type
Definition: simpletransformationdescriptors.hh:53