Should be subclassed and the visit() method redefined according to your needs.
An example: the cRecursiveObjectFinderVisitor class (internal) has been created to find an object of the given name. The constructor accepts the name of the object to search for, and visit() has been redefined to perform recursive traversal, and to throw EndTraversalException if it finds the given object. The class can be used like this:
cRecursiveObjectFinderVisitor v(objectName); v.process(root); cObject *result = v.getResult();
The above code will find the root object as well, if its name matches. The second version (below) starts the traversal at the children, so the root object is ignored.
cRecursiveObjectFinderVisitor v(objectName); v.processChildrenOf(root); cObject *result = v.getResult();
Public Member Functions
|virtual bool||process (cObject *obj)|
|virtual bool||processChildrenOf (cObject *obj)|
|virtual void||visit (cObject *obj)=0|
|Can be thrown to get out in the middle of the traversal process. More...|
|virtual bool cVisitor::process||(||cObject *||obj||)||
|virtual bool cVisitor::processChildrenOf||(||cObject *||obj||)||
|virtual void cVisitor::visit||(||cObject *||obj||)||
Method called from the forEachChild() methods of every class derived from cObject, for each contained object.
visit() should be redefined by user to encapsulate the operation to be performed on the object. If you want recursively traversal, call obj->forEachChild(this) from here.