IIter Class Template Reference

Inheritance diagram for IIter:

IBase ISequence ISequence<T *, SeqId, IterId>


Public Methods

virtual bool next (T &objOut)=0
virtual void reset ()=0

Detailed Description

template<class T, const Guid * G>
class IIter< T, G >

This is a templated abstract class for iterating generic collections. The template parameter determines the type of object being served from the iterator. Typically, a typedef is used to define a specific expansion of the interface following a declaration of that expansion's interface id. The template does not have an id, since it does not define a specific expansion of the interface. but it requires the id of the expansion to be passed in so that the getId function can be implemented. For example:

       extern OA_PLUGIN_DLL_API const Guid IID_IBaseIter;
       typedef IIter IBaseIter;

   
This defines the specific expansion and interface id of an iterator for the IBase interface pointer. The implementor of an iterator, based on an expansion of IIter, can use any appropriate collection class as long as it can be accessed using an "iterator" or "enumerator" pattern. For example, if the following interfaces are defined:
   	class IFoo : public IBase {
   	    void		doStuff() = 0;
   	};
   	extern OA_PLUGIN_DLL_API const Guid IID_IFoo;
   
   	extern OA_PLUGIN_DLL_API const Guid IID_IFooIter;
        typedef IIter IFooIter;

   
Then an example of client code using this interface would be:
   	IFooIter	*it = someContainer->getItems();
   	IFoo		*obj;
   	while (it->next(obj)) {
   	    obj->doStuff();
   	    obj->release();
   	}
   


Member Function Documentation

template<class T, const Guid * G>
bool IIter< T, G >::next T &    objOut [pure virtual]
 

This function is used to get the next element in the iteration. The iterator advances its internal state to point to the next element, and passes it back out via the objOut parameter. If there are no more objects in the collection this function returns false. Note that it returns true for the last element, and that a false return value indicates that nothing was assigned to objOut.

Parameters:
objOut The value of the next element found will be assigned to this parameter, unless there are no more elements.

template<class T, const Guid * G>
void IIter< T, G >::reset   [pure virtual]
 

This function resets the iterators internal state to point to the beginning of the set of elements.


The documentation for this class was generated from the following files:

Return to top of page