Author: Jacob Levy

## The e4_ParentVisitor Class

The e4_ParentVisitor class enables a program to iterate over all parent nodes of a given node. The order in which nodes are visited is the same as the order in which they are returned by e4_Node::GetParent(). The class provides methods to return the current parent being visited and to advance to the next parent to be visited, and to determine whether there are more parent nodes to be visited. An e4_ParentVisitor can be initialized from a node.

The following code fragment shows a typical use of the e4_ParentVisitor class:

>     e4_Node n;
>     ...
>     e4_Node pn;
>     e4_ParentVisitor nv(n);
>     while (nv.CurrentNodeAndAdvance(pn)) {
>         if (!pn.IsValid()) {...}
>         ...
>     }

`The e4_ParentVisitor class provides the following methods:`
``

e4_ParentVisitor Methods and Constructors
e4_ParentVisitor() | Default constructor. Creates an instance of e4_ParentVisitor that is initially invalid, because it is not connected to a storage and has no currently visited parent
e4_ParentVisitor(const e4_ParentVisitor &referrer) | Copy constructor. Creates an instance of e4_ParentVisitor that will visit the same parent nodes as referrer and in the same order.
e4_ParentVisitor(const e4_Node &n) | Constructor that creates an instance of e4_ParentVisitor that will visit all the parent nodes of the node n. If the node n is detached, the visitor will visit be done right away and no parents will be visited.
~e4_ParentVisitor() | Destructor.
e4_ParentVisitor &operator=(const e4_ParentVisitor &referrer) | Assignment operator. Makes this instance visit the same parent nodes as referrer and in the same order.
bool operator==(const e4_ParentVisitor &comp) | Returns true if this and comp are equal e4_ParentVisitor instances. Instances are considered equal if they visit the same set of parent nodes and are at the same position in their itinerary. All invalid instances are equal.
bool operator!=(const e4_ParentVisitor &comp) | Returns true if this and comp are not equal. All invalid instances are equal.
bool IsDone() | Returns true if this instance of e4_ParentVisitor has no more parent nodes to visit or if the current node being visited is invalid.
bool IsValid() | Returns true if this instance of e4_ParentVisitor is valid. An instance is valid if it has a current valid node being visited.
bool CurrentParent(e4_Node &p) | Returns true if the parent node currently being visited is valid and is successfully retrieved in p.
bool NextParent(e4_Node &p) | Returns true if the visitor is successfully advanced to the next parent node to be visited and that node is valid and is successfully retrieved in p.
bool Advance() | Returns true if the visitor is successfully advanced to the next parent node to be visited and that node is valid.
bool CurrentParentAndAdvance(e4_Node &p) | Returns true if the parent node currently being visited is valid and is successfully retrieved in p. An attempt is made to advance the visitor to the next node to be visited; if this is unsuccessful then subsequent calls to IsDone() will return true.
bool SetNode(const e4_Node &n) | Returns true if the visitor is successfully reset to visit all parent nodes of n. If n is detached, the visitor will be done immediately and no parent nodes will be visited.

``