Loading...
Searching...
No Matches
Dune::TypeTree::Experimental::DefaultHybridVisitor Struct Reference

Hybrid visitor interface and base class for TypeTree hybrid visitors. More...

`#include <dune/typetree/visitor.hh>`

Inheritance diagram for Dune::TypeTree::Experimental::DefaultHybridVisitor:

## Public Member Functions

template<typename T, typename TreePath, typename U>
auto | pre (T &&, TreePath, const U &u) const
| Method for prefix tree traversal.
template<typename T, typename TreePath, typename U>
auto | in (T &&, TreePath, const U &u) const
| Method for infix tree traversal.
template<typename T, typename TreePath, typename U>
auto | post (T &&, TreePath, const U &u) const
| Method for postfix tree traversal.
template<typename T, typename TreePath, typename U>
auto | leaf (T &&, TreePath, const U &u) const
| Method for leaf traversal.
template<typename T, typename Child, typename TreePath, typename ChildIndex, typename U>
auto | beforeChild (T &&, Child &&, TreePath, ChildIndex, const U &u) const
| Method for parent-child traversal.
template<typename T, typename Child, typename TreePath, typename ChildIndex, typename U>
auto | afterChild (T &&, Child &&, TreePath, ChildIndex, const U &u) const
| Method for child-parent traversal.

## Detailed Description

Hybrid visitor interface and base class for TypeTree hybrid visitors.

DefaultHybridVisitor defines the interface for visitors that can be applied to a TypeTree using hybridApplyToTree(). 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 hybridApplyToTree() 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.

An hybrid visitor is different from a plain visitor because each method receives a carried value (last argument) on the node visit and is required to return a transformed value from it. Transformations of the carried value type are allowed as long as they are expected on the next visited 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
};

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, typename U>

auto Dune::TypeTree::Experimental::DefaultHybridVisitor::afterChild | ( | T && | ,
|  | Child && | ,
|  | TreePath | ,
|  | ChildIndex | ,
|  | const U & | u ) 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

  t | The parent node.
  child | The child node that was visited last (if the visitor did not reject it).
  treePath | The position of the parent node within the TypeTree.
  childIndex | The index of the child node in relation to the parent node.
  u | The carry value from previous visit.

Returns
  The result of applying this visitor to u.

## beforeChild()

template<typename T, typename Child, typename TreePath, typename ChildIndex, typename U>

auto Dune::TypeTree::Experimental::DefaultHybridVisitor::beforeChild | ( | T && | ,
|  | Child && | ,
|  | TreePath | ,
|  | ChildIndex | ,
|  | const U & | u ) 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

  t | The parent node.
  child | The child node that will (potentially) be visited next.
  treePath | The position of the parent node within the TypeTree.
  childIndex | The index of the child node in relation to the parent node.
  u | The carry value from previous visit.

Returns
  The result of applying this visitor to u.

## in()

template<typename T, typename TreePath, typename U>

auto Dune::TypeTree::Experimental::DefaultHybridVisitor::in | ( | T && | ,
|  | TreePath | ,
|  | const U & | u ) 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

  t | The node to visit.
  treePath | The position of the node within the TypeTree.
  u | The carry value from previous visit.

Returns
  The result of applying this visitor to u.

## leaf()

template<typename T, typename TreePath, typename U>

auto Dune::TypeTree::Experimental::DefaultHybridVisitor::leaf | ( | T && | ,
|  | TreePath | ,
|  | const U & | u ) const

inline

Method for leaf traversal.

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

Parameters

  t | The node to visit.
  treePath | The position of the node within the TypeTree.
  u | The carry value from previous visit.

Returns
  The result of applying this visitor to u.

## post()

template<typename T, typename TreePath, typename U>

auto Dune::TypeTree::Experimental::DefaultHybridVisitor::post | ( | T && | ,
|  | TreePath | ,
|  | const U & | u ) const

inline

Method for postfix tree traversal.

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

Parameters

  t | The node to visit.
  treePath | The position of the node within the TypeTree.
  u | The carry value from previous visit.

Returns
  The result of applying this visitor to u.

## pre()

template<typename T, typename TreePath, typename U>

auto Dune::TypeTree::Experimental::DefaultHybridVisitor::pre | ( | T && | ,
|  | TreePath | ,
|  | const U & | u ) 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

  t | The node to visit.
  treePath | The position of the node within the TypeTree.
  u | The carry value from previous visit.

Returns
  The result of applying this visitor to u.

The documentation for this struct was generated from the following file:

- visitor.hh