4#ifndef DUNE_TYPETREE_APPLYTOCHILDRENSINGLETREE_HH
5#define DUNE_TYPETREE_APPLYTOCHILDRENSINGLETREE_HH
7#include <dune/common/typetraits.hh>
25 template<TreePathType::Type tpType,
typename tag = StartTag,
bool doApply = true>
45 template<std::
size_t inverse_k, std::
size_t count>
46 struct apply_to_children_fully_static
49 template<
typename N,
typename V,
typename TreePath>
50 static void apply(N&& n, V&& v, TreePath tp)
53 typedef typename std::remove_reference<N>::type Node;
54 typedef typename std::remove_reference<V>::type Visitor;
57 typedef typename Node::template
Child<count-inverse_k>::Type C;
60 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
63 const bool visit = Visitor::template VisitChild<Node,C,ChildTreePath>::value;
66 v.beforeChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp,std::integral_constant<std::size_t,count-inverse_k>());
69 ApplyToTree<Visitor::treePathType,NodeTag<C>,visit>::apply(n.template child<count-inverse_k>(),
74 v.afterChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp,std::integral_constant<std::size_t,count-inverse_k>());
77 v.in(std::forward<N>(n),tp);
80 apply_to_children_fully_static<inverse_k-1,count>::apply(std::forward<N>(n),
89 template<std::
size_t count>
90 struct apply_to_children_fully_static<1,count>
93 template<
typename N,
typename V,
typename TreePath>
94 static void apply(N&& n, V&& v, TreePath tp)
96 typedef typename std::remove_reference<N>::type Node;
97 typedef typename std::remove_reference<V>::type Visitor;
98 typedef typename Node::template
Child<count-1>::Type C;
99 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
100 const bool visit = Visitor::template VisitChild<Node,C,ChildTreePath>::value;
101 v.beforeChild(std::forward<N>(n),n.template child<count-1>(),tp,std::integral_constant<std::size_t,count-1>());
102 ApplyToTree<Visitor::treePathType,NodeTag<C>,visit>::apply(n.template child<count-1>(),
105 v.afterChild(std::forward<N>(n),n.template child<count-1>(),tp,std::integral_constant<std::size_t,count-1>());
112 struct apply_to_children_fully_static<0,0>
115 template<
typename N,
typename V,
typename TreePath>
116 static void apply(N&& n, V&& v, TreePath tp) {}
127 template<std::
size_t inverse_k, std::
size_t count>
128 struct apply_to_children_dynamic
131 template<
typename N,
typename V,
typename TreePath>
132 static void apply(N&& n, V&& v, TreePath tp)
134 typedef typename std::remove_reference<N>::type Node;
135 typedef typename std::remove_reference<V>::type Visitor;
136 typedef typename Node::template
Child<count-inverse_k>::Type C;
137 const bool visit = Visitor::template VisitChild<Node,C,typename TreePath::ViewType>::value;
138 v.beforeChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp.view(),count-inverse_k);
139 tp.push_back(count-inverse_k);
140 ApplyToTree<Visitor::treePathType,NodeTag<C>,visit>::apply(n.template child<count-inverse_k>(),
144 v.afterChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp.view(),count-inverse_k);
145 v.in(std::forward<N>(n),tp.view());
146 apply_to_children_dynamic<inverse_k-1,count>::apply(std::forward<N>(n),
155 template<std::
size_t count>
156 struct apply_to_children_dynamic<1,count>
159 template<
typename N,
typename V,
typename TreePath>
160 static void apply(N&& n, V&& v, TreePath tp)
162 typedef typename std::remove_reference<N>::type Node;
163 typedef typename std::remove_reference<V>::type Visitor;
164 typedef typename Node::template
Child<count-1>::Type C;
165 const bool visit = Visitor::template VisitChild<Node,C,typename TreePath::ViewType>::value;
166 v.beforeChild(std::forward<N>(n),n.template child<count-1>(),tp.view(),count-1);
167 tp.push_back(count-1);
168 ApplyToTree<Visitor::treePathType,NodeTag<C>,visit>::apply(n.template child<count-1>(),
172 v.afterChild(std::forward<N>(n),n.template child<count-1>(),tp.view(),count-1);
179 struct apply_to_children_dynamic<0,0>
182 template<
typename N,
typename V,
typename TreePath>
183 static void apply(N&& n, V&& v, TreePath tp) {}
190 template<TreePathType::Type treePathType, std::
size_t CHILDREN>
191 struct apply_to_children;
193 template<std::
size_t CHILDREN>
194 struct apply_to_children<TreePathType::
fullyStatic,CHILDREN>
195 :
public apply_to_children_fully_static<CHILDREN,CHILDREN>
198 template<std::
size_t CHILDREN>
199 struct apply_to_children<TreePathType::
dynamic,CHILDREN>
200 :
public apply_to_children_dynamic<CHILDREN,CHILDREN>
214 struct ApplyToGenericCompositeNode
217 template<
typename N,
typename V,
typename TreePath>
218 static void apply(N&& n, V&& v, TreePath tp)
220 v.pre(std::forward<N>(n),tp);
221 typedef typename std::remove_reference<N>::type Node;
222 typedef typename std::remove_reference<V>::type Visitor;
223 apply_to_children<Visitor::treePathType,StaticDegree<Node>::value>::apply(std::forward<N>(n),
226 v.post(std::forward<N>(n),tp);
typename impl::_Child< Node, indices... >::type Child
Template alias for the type of a child node given by a list of child indices.
Definition childextraction.hh:307
Definition accumulate_static.hh:13
@ fullyStatic
Definition treepath.hh:26
@ dynamic
Definition treepath.hh:26