#include <AlIterator.h>
class AlIterator
virtual int func( AlObject* ) = 0;
class AlIteratorWithParent
virtual int func( AlObject* , AlDagNode* ) = 0;
To use this class the method "func" should be overloaded. On success, func() should return zero which will cause the iteration to continue with the next element in the list. A non-zero return value will cause the iteration to stop. The returned value will be returned through the second reference argument in the applyIterator() method. In general the applyIterator() methods return sSuccess even when func() returns non-zero. A return other than sSuccess indicates that the applyIterator() method failed to function properly.
Two types of iterators are defined. The first passes in an AlObject* to the func(). The second iterator AlIteratorWithParent passes in the AlObject* and the AlDagNode* parent of the object. Note that if an AlIteratorWithParent is used and the AlObject is a shader then the AlDagNode pointer will be null.
Iterators should be used to examine or set data in the visited objects, but should not be used to delete the objects.
For example:
class countIterator : public AlIterator {
public:
countIterator() : count( 0 );
~countIterator() {};
virtual int func( AlObject* ) { count++; };
int result() { return count; };
private:
int count;
};
code which creates a complete polyset ...
countIterator* iter = new countIterator;
status = pset->applyIteratorToVertices( iter, returnCode );
numVertices = iter->result();