Dune Core Modules (2.8.0)

Dune::TypeTree::DefaultVisitor Struct Reference

Visitor interface and base class for TypeTree visitors. More...

#include <dune/typetree/visitor.hh>

Public Member Functions

template<typename T , typename TreePath >
void pre (T &&t, TreePath treePath) const
 Method for prefix tree traversal. More...
 
template<typename T , typename TreePath >
void in (T &&t, TreePath treePath) const
 Method for infix tree traversal. More...
 
template<typename T , typename TreePath >
void post (T &&t, TreePath treePath) const
 Method for postfix tree traversal. More...
 
template<typename T , typename TreePath >
void leaf (T &&t, TreePath treePath) const
 Method for leaf traversal. More...
 
template<typename T , typename Child , typename TreePath , typename ChildIndex >
void beforeChild (T &&t, Child &&child, TreePath treePath, ChildIndex childIndex) const
 Method for parent-child traversal. More...
 
template<typename T , typename Child , typename TreePath , typename ChildIndex >
void afterChild (T &&t, Child &&child, TreePath treePath, ChildIndex childIndex) const
 Method for child-parent traversal. More...
 

Detailed Description

Visitor interface and base class for TypeTree visitors.

DefaultVisitor defines the interface for visitors that can be applied to a TypeTree using applyToTree(). Each method of the visitor is passed a node of the tree (either as a mutable or a const reference, depending on the constness of the tree applyToTree() was called with). The second argument is of type TreePath and denotes the exact position of the node within the TypeTree, encoded as child indices starting at the root node.

In order to create a functioning visitor, an implementation will - in addition to providing the methods of this class - also have to contain the following template struct, which is used to determine whether to visit a given node:

template<typename Node, typename Child, typename TreePath>
struct VisitChild
{
static const bool value = ...; // decide whether to visit Child
};

For the two most common scenarios - visiting only direct children and visiting the whole tree - there are mixin classes VisitDirectChildren and VisitTree and combined base classes TreeVisitor and DirectChildrenVisitor. The latter two inherit from both DefaultVisitor and one of the two mixin classes and can thus be used as convenient base classes.

Note
This class can also be used as a convenient base class if the implemented visitor only needs to act on some of the possible callback sites, avoiding a lot of boilerplate code.

Member Function Documentation

◆ afterChild()

template<typename T , typename Child , typename TreePath , typename ChildIndex >
void Dune::TypeTree::DefaultVisitor::afterChild ( T &&  t,
Child &&  child,
TreePath  treePath,
ChildIndex  childIndex 
) const
inline

Method for child-parent traversal.

This method gets called after visiting a child node.

Note
This method gets called even if the child node was not visited because the visitor chose not to do so.
Parameters
tThe parent node.
childThe child node that was visited last (if the visitor did not reject it).
treePathThe position of the parent node within the TypeTree.
childIndexThe index of the child node in relation to the parent node.

◆ beforeChild()

template<typename T , typename Child , typename TreePath , typename ChildIndex >
void Dune::TypeTree::DefaultVisitor::beforeChild ( T &&  t,
Child &&  child,
TreePath  treePath,
ChildIndex  childIndex 
) const
inline

Method for parent-child traversal.

This method gets called before visiting a child node.

Note
This method gets called even if the visitor decides not to visit the child in question.
Parameters
tThe parent node.
childThe child node that will (potentially) be visited next.
treePathThe position of the parent node within the TypeTree.
childIndexThe index of the child node in relation to the parent node.

◆ in()

template<typename T , typename TreePath >
void Dune::TypeTree::DefaultVisitor::in ( T &&  t,
TreePath  treePath 
) const
inline

Method for infix tree traversal.

This method gets called BETWEEN visits of children of a non-leaf node. That definition implies that this method will only be called for nodes with at least two children.

Parameters
tThe node to visit.
treePathThe position of the node within the TypeTree.

◆ leaf()

template<typename T , typename TreePath >
void Dune::TypeTree::DefaultVisitor::leaf ( T &&  t,
TreePath  treePath 
) const
inline

Method for leaf traversal.

This method gets called when encountering a leaf node within the TypeTree.

Parameters
tThe node to visit.
treePathThe position of the node within the TypeTree.

◆ post()

template<typename T , typename TreePath >
void Dune::TypeTree::DefaultVisitor::post ( T &&  t,
TreePath  treePath 
) const
inline

Method for postfix tree traversal.

This method gets called after all children of a non-leaf node have been visited.

Parameters
tThe node to visit.
treePathThe position of the node within the TypeTree.

◆ pre()

template<typename T , typename TreePath >
void Dune::TypeTree::DefaultVisitor::pre ( T &&  t,
TreePath  treePath 
) const
inline

Method for prefix tree traversal.

This method gets called when first encountering a non-leaf node and before visiting any of its children.

Parameters
tThe node to visit.
treePathThe position of the node within the TypeTree.

The documentation for this struct was generated from the following file:
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Nov 21, 23:30, 2024)