The e4_VertexVisitor Class

The e4_VertexVisitor class enables a program to iterate over a collection of vertices selected from a storage. The class provides methods to retrieve the currently visited vertex and to advance to the next vertex to be visited, and to determine whether there are more vertices to be visited. The e4_VertexVisitor class provides a variety of flexible methods to select and filter the vertices to visit, according to user defined criteria. The order in which vertices that match the selection criteria are visited is implementation dependent.

The following code snippet demonstrates a typical use of the e4_VertexVisitor class:

e4_Storage s("mystorage", E4_METAKIT);
e4_Marker m;
e4_Node n;
e4_Vertex v;
...
if (!s.GetMarker("mymarker", m)) {...}
if (!m.GetMarkedNode(n)) {...}
if (!n.GetVertexRef("foo", 1, v)) {...}
...
e4_Vertex cv;
e4_VertexVisitor vv(v);
while (vv.CurrentVertexAndAdvance(cv)) {
    if (!cv.IsValid()) {...}
    if (cv == v) {
        fprintf(stderr, "Found our vertex, %s %s\n",
                v.GetName(), cv.GetName());
    }
}
The vertex visitor vv is initialized to visit all the vertices in the node containing the vertex v. We iterate over all the vertices in turn, and when we reach the vertex v that was used to initialize vv, we print a message to stderr.

Each instance of e4_VertexVisitor has a specific visit method, defined here, that determines its behavior. The value currently in effect is returned by the method VisitMethod().

The e4_VertexVisitor class provides the following methods:
 
e4_VertexVisitor Methods and Constructors
   
e4_VertexVisitor() Default constructor. Creates an instance of e4_VertexVisitor that is initially invalid, because it is not associated with any storage and does not have a current vertex being visited.
e4_VertexVisitor(const e4_VertexVisitor &referrer) Copying constructor. Creates an instance of e4_VertexVisitor that will visit the same vertices as referrer, and in the same order.
e4_VertexVisitor(const e4_Storage &s) Constructor that creates an instance of e4_VertexVisitor that will visit all vertices in the storage s. The visit method is E4_VMSTORAGE.
e4_VertexVisitor(const e4_Storage &s, const char *nm, e4_VertexType vt) Constructor that creates an instance of e4_VertexVisitor that will visit all vertices in the storage s that have the name nm and vertex type vt. If nm is NULL then vertices with any name are visited, and if vt is E4_VTUNKNOWN then vertices with a value of any type are visited. Either way, the visit method is E4_VMSTORAGE.
e4_VertexVisitor(const e4_Node &n) Constructor that creates an instance of e4_VertexVisitor that will visit all vertices in the node n in increasing rank order. The visit method is E4_VMNODE.
e4_VertexVisitor(const e4_Node &n, const char *nm, e4_VertexType vt) Constructor that creates an instance of e4_VertexVisitor that will visit all vertices in the node n that have the name nm and vertex type vt in increasing rank order. If nm is NULL the vertices with any name are visited, and if vt is E4_VTUNKNOWN then vertices with a value of any type are visited. Either way, the visit method is E4_VMNODE.
e4_VertexVisitor(const e4_Vertex &v) Constructor that creates an instance of e4_VertexVisitor that will visit vertices starting with v in the node containing v, in increasing rank order. The visit method is E4_VMNODE.
e4_VertexVisitor(const e4_Vertex &v, const char *nm, e4_VertexType vt) Constructor that creates an instance of e4_VertexVisitor that will visit vertices starting with v in the node containing v that have the name nm and vertex type vt in increasing rank order. If nm is NULL then vertices with any name are visited, and if vt is E4_VTUNKNOWN then vertices with a value of any type are visited. Either way, the visit method is E4_VMNODE.
e4_VertexVisitor(const e4_Vertex &v, const char *nm, e4_VertexType vt, e4_VisitMethod vm) Constructor that creates an instance of e4_VertexVisitor that will visit vertices starting with v that have the name nm and vertex type vt, according to the visit method vm. If vm is E4_VMUNKNOWN or E4_VMSTORAGE, v and all vertices that are contained within the storage containing v that occur after v in the implementation dependent visit order are visited. If vm is VM_NODE, v and vertices with rank higher than v are visited. If vm is VM_NODERANDOM, v and vertices occurring after v in the implementation dependent visit order are visited. If nm is NULL, vertices with any name are visited, and if vt is E4_VTUNKNOWN then vertices with a value of any type are visited. Practically, E4_VMNODE is probably the most useful visit method.