Dune TypeTree (2.8)
transformation.hh
70 typedef decltype(registerNodeTransformation(declptr<S>(),declptr<T>(),declptr<Tag>())) lookup_type;
76 static_assert((!std::is_same<type,void>::value), "Unable to find valid transformation descriptor");
92 template<typename SourceTree, typename Transformation, typename Tag = StartTag, bool recursive = true>
98 typedef typename LookupNodeTransformation<SourceTree,Transformation,typename SourceTree::ImplementationTag>::type NodeTransformation;
101 typedef typename TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transformed_type transformed_type;
104 typedef typename TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transformed_storage_type transformed_storage_type;
114 static transformed_type transform(const SourceTree& s, const Transformation& t = Transformation())
116 return TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transform(s,t);
122 return TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transform(s,t);
126 static transformed_type transform(std::shared_ptr<const SourceTree> sp, const Transformation& t = Transformation())
128 return TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transform(sp,t);
134 return TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transform(sp,t);
139 static transformed_storage_type transform_storage(std::shared_ptr<const SourceTree> sp, const Transformation& t = Transformation())
141 return TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transform_storage(sp,t);
146 static transformed_storage_type transform_storage(std::shared_ptr<const SourceTree> sp, Transformation& t)
148 return TransformTree<SourceTree,Transformation,NodeTag<SourceTree>,NodeTransformation::recursive>::transform_storage(sp,t);
279 // The problem is that the transformed power node must be parameterized on the transformed child
281 // template of the node transformation struct called result (see example of such a specification
283 using NodeTransformation = typename LookupNodeTransformation<Source,Transformation,ImplementationTag<Source>>::type;
284 using ChildNodeTransformation = typename LookupNodeTransformation<ChildType,Transformation,ImplementationTag<ChildType>>::type;
295 using transformed_child_storage_type = typename ChildTreeTransformation::transformed_storage_type;
298 using transformed_type = typename NodeTransformation::template result<transformed_child_type>::type;
299 using transformed_storage_type = typename NodeTransformation::template result<transformed_child_type>::storage_type;
304 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source.degree());
306 children_storage[k] = ChildTreeTransformation::transform_storage(source.childStorage(k),transformation);
314 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source.degree());
316 children_storage[k] = ChildTreeTransformation::transform_storage(source.childStorage(k),transformation);
322 static transformed_type transform(std::shared_ptr<const Source> source_ptr, Transformation& transformation)
324 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source_ptr->degree());
326 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
332 static transformed_type transform(std::shared_ptr<const Source> source_ptr, const Transformation& transformation)
334 auto children_storage = node_storage_provider<std::shared_ptr<transformed_child_type>>(source_ptr->degree());
336 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
342 static transformed_storage_type transform_storage(std::shared_ptr<const Source> source_ptr, Transformation& transformation)
344 auto children_storage = node_storage_provider<transformed_child_storage_type>(source_ptr->degree());
346 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
352 static transformed_storage_type transform_storage(std::shared_ptr<const Source> source_ptr, const Transformation& transformation)
354 auto children_storage = node_storage_provider<transformed_child_storage_type>(source_ptr->degree());
356 children_storage[k] = ChildTreeTransformation::transform_storage(source_ptr->childStorage(k),transformation);
388 // helper struct that does the actual transformation for a composite node. We need this additional struct
389 // to extract the template argument list with the types of all children from the node, which we cannot do
390 // directly in the transformation<> template, as the type passed to transformation<> will usually be a
391 // derived type and will normally have more template arguments than just the children. This declaration
392 // just introduces the type of the helper struct, we always instantiate the specialization defined below;
396 // specialized version of the helper struct which extracts the template argument list with the children from
397 // its second template parameter, which has to be CompositeNode::ChildTypes. Apart from that, the struct is
398 // similar to the one for a PowerNode, but it obviously delegates transformation of the children to the TMP.
446 Dune::Hybrid::Impl::evaluateFoldExpression<int>({(setElement<i>(storage, ChildTransformation<i>::transform_storage(s.template childStorage<i>(), std::forward<Trafo>(t))),0)...});
451 static transformed_storage_type transform_storage(std::shared_ptr<const S> sp, Trafo&& t, std::index_sequence<i...> indices)
454 Dune::Hybrid::Impl::evaluateFoldExpression<int>({(setElement<i>(storage, ChildTransformation<i>::transform_storage(sp->template childStorage<i>(), std::forward<Trafo>(t))),0)...});
455 return NodeTransformation::transform_storage(sp, std::forward<Trafo>(t), std::get<i>(storage)...);
478 typedef typename transform_composite_node<S,ChildTypes,T>::transformed_storage_type transformed_storage_type;
std::size_t degree(const Node &node)
Returns the degree of node as run time information.
Definition: nodeinterface.hh:76
void registerNodeTransformation(SourceNode *, Transformation *, Tag *)
Register transformation descriptor to transform SourceNode with Transformation.
static transformed_type transform(std::shared_ptr< const SourceTree > sp, Transformation &t)
Apply transformation to an existing tree s.
Definition: transformation.hh:132
static transformed_type transform(std::shared_ptr< const SourceTree > sp, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition: transformation.hh:126
static transformed_type transform(const SourceTree &s, Transformation &t)
Apply transformation to an existing tree s.
Definition: transformation.hh:120
transformed_type type
The type of the transformed tree.
Definition: transformation.hh:109
static transformed_type transform(const SourceTree &s, const Transformation &t=Transformation())
Apply transformation to an existing tree s.
Definition: transformation.hh:114
static transformed_storage_type transform_storage(std::shared_ptr< const SourceTree > sp, const Transformation &t=Transformation())
Definition: transformation.hh:139
static transformed_storage_type transform_storage(std::shared_ptr< const SourceTree > sp, Transformation &t)
Definition: transformation.hh:146
Meta function that evaluates its argument iff it inherits from meta_function.
Definition: typetraits.hh:148
