4 #ifndef DUNE_TYPETREE_APPLYTOCHILDRENSINGLETREE_HH
5 #define DUNE_TYPETREE_APPLYTOCHILDRENSINGLETREE_HH
7 #include <dune/common/typetraits.hh>
21 #ifndef DOXYGEN // these are all internals and not public API.
24 template<TreePathType::Type tpType,
typename tag = StartTag,
bool doApply = true>
44 template<std::
size_t inverse_k, std::
size_t count>
45 struct apply_to_children_fully_static
48 template<
typename N,
typename V,
typename TreePath>
49 static void apply(N&& n, V&& v, TreePath tp)
52 typedef typename remove_reference<N>::type Node;
53 typedef typename remove_reference<V>::type Visitor;
56 typedef typename Node::template Child<count-inverse_k>
::Type C;
59 typedef typename TreePathPushBack<TreePath,count-inverse_k>::type ChildTreePath;
62 const bool visit = Visitor::template VisitChild<Node,C,ChildTreePath>::value;
65 v.beforeChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp,integral_constant<std::size_t,count-inverse_k>());
68 ApplyToTree<Visitor::treePathType,typename C::NodeTag,visit>::apply(n.template child<count-inverse_k>(),
73 v.afterChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp,integral_constant<std::size_t,count-inverse_k>());
76 v.in(std::forward<N>(n),tp);
79 apply_to_children_fully_static<inverse_k-1,count>::apply(std::forward<N>(n),
88 template<std::
size_t count>
89 struct apply_to_children_fully_static<1,count>
92 template<
typename N,
typename V,
typename TreePath>
93 static void apply(N&& n, V&& v, TreePath tp)
95 typedef typename remove_reference<N>::type Node;
96 typedef typename remove_reference<V>::type Visitor;
97 typedef typename Node::template Child<count-1>
::Type C;
98 typedef typename TreePathPushBack<TreePath,count-1>::type ChildTreePath;
99 const bool visit = Visitor::template VisitChild<Node,C,ChildTreePath>::value;
100 v.beforeChild(std::forward<N>(n),n.template child<count-1>(),tp,integral_constant<std::size_t,count-1>());
101 ApplyToTree<Visitor::treePathType,typename C::NodeTag,visit>::apply(n.template child<count-1>(),
104 v.afterChild(std::forward<N>(n),n.template child<count-1>(),tp,integral_constant<std::size_t,count-1>());
111 struct apply_to_children_fully_static<0,0>
114 template<
typename N,
typename V,
typename TreePath>
115 static void apply(N&& n, V&& v, TreePath tp) {}
126 template<std::
size_t inverse_k, std::
size_t count>
127 struct apply_to_children_dynamic
130 template<
typename N,
typename V,
typename TreePath>
131 static void apply(N&& n, V&& v, TreePath tp)
133 typedef typename remove_reference<N>::type Node;
134 typedef typename remove_reference<V>::type Visitor;
135 typedef typename Node::template Child<count-inverse_k>
::Type C;
136 const bool visit = Visitor::template VisitChild<Node,C,typename TreePath::ViewType>::value;
137 v.beforeChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp.view(),count-inverse_k);
138 tp.push_back(count-inverse_k);
139 ApplyToTree<Visitor::treePathType,typename C::NodeTag,visit>::apply(n.template child<count-inverse_k>(),
143 v.afterChild(std::forward<N>(n),n.template child<count-inverse_k>(),tp.view(),count-inverse_k);
144 v.in(std::forward<N>(n),tp.view());
145 apply_to_children_dynamic<inverse_k-1,count>::apply(std::forward<N>(n),
154 template<std::
size_t count>
155 struct apply_to_children_dynamic<1,count>
158 template<
typename N,
typename V,
typename TreePath>
159 static void apply(N&& n, V&& v, TreePath tp)
161 typedef typename remove_reference<N>::type Node;
162 typedef typename remove_reference<V>::type Visitor;
163 typedef typename Node::template Child<count-1>
::Type C;
164 const bool visit = Visitor::template VisitChild<Node,C,typename TreePath::ViewType>::value;
165 v.beforeChild(std::forward<N>(n),n.template child<count-1>(),tp.view(),count-1);
166 tp.push_back(count-1);
167 ApplyToTree<Visitor::treePathType,typename C::NodeTag,visit>::apply(n.template child<count-1>(),
171 v.afterChild(std::forward<N>(n),n.template child<count-1>(),tp.view(),count-1);
178 struct apply_to_children_dynamic<0,0>
181 template<
typename N,
typename V,
typename TreePath>
182 static void apply(N&& n, V&& v, TreePath tp) {}
189 template<TreePathType::Type treePathType, std::
size_t CHILDREN>
190 struct apply_to_children;
192 template<std::
size_t CHILDREN>
193 struct apply_to_children<TreePathType::
fullyStatic,CHILDREN>
194 :
public apply_to_children_fully_static<CHILDREN,CHILDREN>
197 template<std::
size_t CHILDREN>
198 struct apply_to_children<TreePathType::
dynamic,CHILDREN>
199 :
public apply_to_children_dynamic<CHILDREN,CHILDREN>
213 struct ApplyToGenericCompositeNode
216 template<
typename N,
typename V,
typename TreePath>
217 static void apply(N&& n, V&& v, TreePath tp)
219 v.pre(std::forward<N>(n),tp);
220 typedef typename remove_reference<N>::type Node;
221 typedef typename remove_reference<V>::type Visitor;
222 apply_to_children<Visitor::treePathType,Node::CHILDREN>::apply(std::forward<N>(n),
225 v.post(std::forward<N>(n),tp);
237 #endif // DUNE_TYPETREE_APPLYTOCHILDRENSINGLETREE_HH
Definition: treepath.hh:25
Definition: accumulate_static.hh:12
Type
Definition: treepath.hh:25
Definition: treepath.hh:25