ROSE  0.11.96.11
Public Member Functions | Public Attributes | List of all members
Sawyer::Tree::Node Class Reference

Description

Base class for Tree nodes.

All nodes of a tree inherit from this type. The main features that this class provides are:

Definition at line 479 of file Tree.h.

#include <Tree.h>

Inheritance diagram for Sawyer::Tree::Node:
Inheritance graph
[legend]
Collaboration diagram for Sawyer::Tree::Node:
Collaboration graph
[legend]

Public Member Functions

 Node ()
 Construct an empty node.
 
virtual ~Node ()
 Nodes are polymorphic.
 
 Node (const Node &)=delete
 
Nodeoperator= (const Node &)=delete
 
template<class Functor >
TraversalAction traverse (Functor functor)
 Traverse the tree starting at this node and following child pointers. More...
 
template<class Functor >
TraversalAction traverse (Functor functor) const
 Traverse the tree starting at this node and following child pointers. More...
 
template<class T , class Functor >
TraversalAction traverseType (Functor functor)
 Traverse the tree restricted by type. More...
 
template<class T , class Functor >
TraversalAction traverseType (Functor functor) const
 Traverse the tree restricted by type. More...
 
template<class Functor >
TraversalAction traverseParents (Functor functor)
 Traverse the tree by following parent pointers. More...
 
template<class Functor >
TraversalAction traverseParents (Functor functor) const
 Traverse the tree by following parent pointers. More...
 
template<class Predicate >
NodePtr find (Predicate predicate)
 Traverse an tree to find the first node satisfying the predicate.
 
template<class Predicate >
NodePtr find (Predicate predicate) const
 Traverse an tree to find the first node satisfying the predicate.
 
template<class T >
std::shared_ptr< T > findType ()
 Find first child that's the specified type.
 
template<class T >
std::shared_ptr< T > findType () const
 Find first child that's the specified type.
 
template<class T , class Predicate >
std::shared_ptr< T > findType (Predicate predicate)
 Find first child of specified type satisfying the predicate.
 
template<class T , class Predicate >
std::shared_ptr< T > findType (Predicate predicate) const
 Find first child of specified type satisfying the predicate.
 
template<class Predicate >
NodePtr findParent (Predicate predicate)
 Find closest ancestor that satifies the predicate.
 
template<class Predicate >
NodePtr findParent (Predicate predicate) const
 Find closest ancestor that satifies the predicate.
 
template<class T >
std::shared_ptr< T > findParentType ()
 Find closest ancestor of specified type.
 
template<class T >
std::shared_ptr< T > findParentType () const
 Find closest ancestor of specified type.
 
template<class T , class Predicate >
std::shared_ptr< T > findParentType (Predicate predicate)
 Find closest ancestor of specified type that satisfies the predicate.
 
template<class T , class Predicate >
std::shared_ptr< T > findParentType (Predicate predicate) const
 Find closest ancestor of specified type that satisfies the predicate.
 

Public Attributes

ParentEdge parent
 Pointer to the parent node, if any.
 
Children children
 Vector of pointers to children.
 

Member Function Documentation

◆ traverse() [1/2]

template<class Functor >
TraversalAction Sawyer::Tree::Node::traverse ( Functor  functor)
inline

Traverse the tree starting at this node and following child pointers.

The functor takes two arguments: the tree node under consideration, and a TraversalEvent that indicates whether the traversal is entering or leaving the node. The functor must return a TraversalAction to describe what should happen next.

If the functor called by the node enter event returns SKIP_CHILDREN, then none of the children are traversed and the next call to the functor is for leaving that same node.

If any call to the functor returns ABORT, then the traversal is immediately aborted.

If any functor returns ABORT, then the traverse function also returns ABORT. Otherwise the traverse function returns CONTINUE.

Definition at line 516 of file Tree.h.

◆ traverse() [2/2]

template<class Functor >
TraversalAction Sawyer::Tree::Node::traverse ( Functor  functor) const
inline

Traverse the tree starting at this node and following child pointers.

The functor takes two arguments: the tree node under consideration, and a TraversalEvent that indicates whether the traversal is entering or leaving the node. The functor must return a TraversalAction to describe what should happen next.

If the functor called by the node enter event returns SKIP_CHILDREN, then none of the children are traversed and the next call to the functor is for leaving that same node.

If any call to the functor returns ABORT, then the traversal is immediately aborted.

If any functor returns ABORT, then the traverse function also returns ABORT. Otherwise the traverse function returns CONTINUE.

Definition at line 520 of file Tree.h.

◆ traverseType() [1/2]

template<class T , class Functor >
TraversalAction Sawyer::Tree::Node::traverseType ( Functor  functor)

Traverse the tree restricted by type.

Traverses the entire tree, but calls the functor only for nodes of the specified type (or subtype).

Definition at line 1107 of file Tree.h.

◆ traverseType() [2/2]

template<class T , class Functor >
TraversalAction Sawyer::Tree::Node::traverseType ( Functor  functor) const

Traverse the tree restricted by type.

Traverses the entire tree, but calls the functor only for nodes of the specified type (or subtype).

Definition at line 1113 of file Tree.h.

◆ traverseParents() [1/2]

template<class Functor >
TraversalAction Sawyer::Tree::Node::traverseParents ( Functor  functor)
inline

Traverse the tree by following parent pointers.

Other than following pointers from children to parents, this traversal is identical to the downward traverse method.

Definition at line 543 of file Tree.h.

◆ traverseParents() [2/2]

template<class Functor >
TraversalAction Sawyer::Tree::Node::traverseParents ( Functor  functor) const
inline

Traverse the tree by following parent pointers.

Other than following pointers from children to parents, this traversal is identical to the downward traverse method.

Definition at line 547 of file Tree.h.


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