The e4_MarkerVisitor Class

The e4_MarkerVisitor class enables a program to iterate over all markers defined in a storage. The order in which markers are visited is implementation dependent. The class provides methods to return the current marker and to continue to the next marker to be visited, and to determine if there are more markers to be visited. An e4_MarkerVisitor instance can be initialized from a storage, a marker, a node or a vertex; in all cases, the visitor iterates over all markers in the given storage or the storage that contains the marker, node or vertex given.

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

e4_Storage s("mystorage", E4_METAKIT);
e4_Marker m;
...
if (!s.GetMarker("mymarker", m)) {...}
...
e4_MarkerVisitor mv(m);
e4_Marker cm;
while (mv.CurrentMarkerAndAdvance(cm)) {
    if (!cm.IsValid()) {...}
    if (cm == m) {
        fprintf(stderr, "Found our marker, %s %s\n",
                cm.GetName(), m.GetName());
    }
}
The marker visitor mv is initialized to visit all markers in the storage that contains the marker m. We iterate over each marker in turn, and when we reach the marker m that was used to initialize the visitor mv, we print a message to stderr.

The following methods are provided by the e4_MarkerVisitor class:
 
e4_MarkerVisitor Methods and Constructors
   
e4_MarkerVisitor() Default constructor. Creates an instance of e4_MarkerVisitor that is initially invalid, because it is not connected to a storage and has no currently visited marker.
e4_MarkerVisitor(const e4_MarkerVisitor &referrer) Copy constructor. Creates an instance of e4_MarkerVisitor that will visit markers in the same storage as referrer and in the same order.
e4_MarkerVisitor(const e4_Storage &s) Constructor that creates an instance of e4_MarkerVisitor that will visit all markers defined in the storage s.
e4_MarkerVisitor(const e4_Marker &m) Constructor that creates an instance of e4_MarkerVisitor that will visit all markers in the storage containing the marker m.
e4_MarkerVisitor(const e4_Node &n) Constructor that creates an instance of e4_MarkerVisitor that will visit all markers in the storage containing the node n.
e4_MarkerVisitor(const e4_Vertex &v) Constructor that creates an instance of e4_MarkerVisitor that will visit all markers in the storage containing the vertex v.
~e4_MarkerVisitor() Destructor.
e4_MarkerVisitor &operator=(const e4_MarkerVisitor &referrer) Assignment operator. The current instance will visit markers in the same storage as referrer and in the same order.
bool operator==(const e4_MarkerVisitor &comp) Returns true if this instance and comp refer to the same instance of e4_MarkerVisitor.
bool operator!=(const e4_MarkerVisitor &comp) Returns true if this instance and comp do not refer to the same instance of e4_MarkerVisitor.
   
bool IsDone() Returns true if there are no more markers to visit.
bool IsValid() Returns true if this instance of e4_MarkerVisitor is valid. An instance is valid if it has a current marker being visited.
bool CurrentMarker(e4_Marker &m) Returns true if the current marker being visited is successfully retrieved in m.
bool NextMarker(e4_Marker &m) Returns true if the visitor is successfully advanced to the next marker to be visited and that marker is successfully retrieved in m.
bool CurrentMarkerAndAdvance(e4_Marker &m) Returns true if the current marker being visited is successfully retrieved in m and the visitor is successfully advanced to the next marker to be visited.
bool SetStorage(e4_Storage &s) Returns true if the visitor is successfully reset to visit all markers defined in the storage s.
bool SetMarker(e4_Marker &m) Returns true if the visitor is successfully reset to visit all markers defined in the storage containing the marker m.
bool SetNode(e4_Node &n) Returns true if the visitor is successfully reset to visit all markers defined in the storage containing the node n.
bool SetVertex(e4_Vertex &v) Returns true if the visitor is successfully reset to visit all markers defined in the storage containing the vertex v.