ROSE  0.9.11.145
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. More...
 
virtual ~Node ()
 Nodes are polymorphic. More...
 
 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. More...
 
Children children
 Vector of pointers to children. More...
 

Constructor & Destructor Documentation

Sawyer::Tree::Node::Node ( )
inline

Construct an empty node.

Definition at line 489 of file Tree.h.

virtual Sawyer::Tree::Node::~Node ( )
inlinevirtual

Nodes are polymorphic.

Definition at line 492 of file Tree.h.

Member Function Documentation

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.

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.

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.

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.

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.

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.

Member Data Documentation

ParentEdge Sawyer::Tree::Node::parent

Pointer to the parent node, if any.

Definition at line 484 of file Tree.h.

Children Sawyer::Tree::Node::children

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