4 #ifndef DUNE_TYPETREE_TRAVERSAL_HH
5 #define DUNE_TYPETREE_TRAVERSAL_HH
7 #if HAVE_RVALUE_REFERENCES
25 #ifndef DOXYGEN // these are all internals and not public API. Only access is using applyToTree().
34 template<TreePathType::Type tpType,
bool doApply>
35 struct ApplyToTree<tpType,StartTag,doApply>
38 template<
typename Node,
typename Visitor>
39 static void apply(Node&& node, Visitor&& visitor)
41 ApplyToTree<tpType,typename remove_reference<Node>::type::NodeTag>::apply(std::forward<Node>(node),
42 std::forward<Visitor>(visitor),
43 TreePathFactory<tpType>::create(node).mutablePath());
50 template<TreePathType::Type tpType,
typename NodeTag>
51 struct ApplyToTree<tpType,NodeTag,false>
56 template<
typename Node,
typename Visitor,
typename TreePath>
57 static void apply(
const Node& node,
const Visitor& visitor, TreePath treePath)
69 template<TreePathType::Type tpType>
70 struct ApplyToTree<tpType,LeafNodeTag,true>
73 template<
typename N,
typename V,
typename TreePath>
74 static void apply(N&& n, V&& v, TreePath tp)
76 v.leaf(std::forward<N>(n),tp.view());
90 struct ApplyToTree<TreePathType::
fullyStatic,PowerNodeTag,true>
91 :
public ApplyToGenericCompositeNode
99 struct ApplyToTree<TreePathType::
dynamic,PowerNodeTag,true>
102 template<
typename N,
typename V,
typename TreePath>
103 static void apply(N&& n, V&& v, TreePath tp)
106 v.pre(std::forward<N>(n),tp.view());
109 typedef typename remove_reference<N>::type Node;
110 typedef typename remove_reference<V>::type Visitor;
118 const bool visit = Visitor::template VisitChild<Node,C,typename TreePath::ViewType>::value;
121 for (std::size_t k = 0; k < Node::CHILDREN; ++k)
124 v.beforeChild(std::forward<N>(n),n.child(k),tp.view(),k);
130 ApplyToTree<Visitor::treePathType,typename C::NodeTag,visit>::apply(n.child(k),std::forward<V>(v),tp);
136 v.afterChild(std::forward<N>(n),n.child(k),tp.view(),k);
139 if (k < Node::CHILDREN-1)
140 v.in(std::forward<N>(n),tp.view());
144 v.post(std::forward<N>(n),tp.view());
156 template<TreePathType::Type treePathType>
158 :
public ApplyToGenericCompositeNode
185 template<
typename Tree,
typename Visitor>
189 std::forward<Visitor>(visitor));
197 #endif // DUNE_TYPETREE_TRAVERSAL_HH
Definition: accumulate_static.hh:12
Definition: treepath.hh:26
Definition: treepath.hh:26
Type
Definition: treepath.hh:26
static const TreePathType::Type treePathType
Definition: traversalutilities.hh:30
void applyToTree(Tree &&tree, Visitor &&visitor)
Apply visitor to TypeTree.
Definition: traversal.hh:186