sipxportlib  Version 3.3
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
UtlIterator Class Referenceabstract

#include <UtlIterator.h>

Inheritance diagram for UtlIterator:
Inheritance graph
[legend]
Collaboration diagram for UtlIterator:
Collaboration graph
[legend]

Public Member Functions

 UtlIterator (const UtlContainer &container)
 
virtual ~UtlIterator ()=0
 
virtual UtlContainableoperator() ()=0
 Return the next element. More...
 
virtual void reset ()=0
 Reset the iterator cursor so that it will again return all elements in the container. More...
 

Protected Member Functions

void addToContainer (const UtlContainer *container)
 
virtual void invalidate ()
 

Protected Attributes

OsBSem mContainerRefLock
 
UtlContainermpMyContainer
 

Friends

class UtlContainer
 

Detailed Description

UltIterator defines an abstract Iterator for walking through the elements of UtlContainer derived class.

Example Code:

   // Create an iterator that walks through the elements of myContentSource.
   FooIterator itor(myContentSource);
   MyObject* pObj;
   // Fetch a pointer to each element of myContentSource into pObj.
   while ((pObj = itor()))
   {
      // Do something to *pObj.
   }
   // Reset itor to its initial state, so itor() starts walking through the
   // elements of myContentSource all over again.
   itor.reset();
   while ((pObj = itor()))
   {
      // Do something else to *pObj.
   }

(The extra parentheses in the while clauses are to mark that that operation is an assignment, not a comparison.)

Constructor & Destructor Documentation

UtlIterator ( const UtlContainer container)
~UtlIterator ( )
pure virtual

Destructor

Member Function Documentation

virtual UtlContainable* operator() ( )
pure virtual

Return the next element.

Implemented in UtlHashBagIterator, UtlHashMapIterator, and UtlListIterator.

virtual void reset ( )
pure virtual

Reset the iterator cursor so that it will again return all elements in the container.

Implemented in UtlHashBagIterator, UtlHashMapIterator, and UtlListIterator.

void addToContainer ( const UtlContainer container)
protected
void invalidate ( )
protectedvirtual

invalidate is called by the UtlContainer from its destructor. It disconnects the iterator from its container object (sets mpContainerRef to NULL). Any subsequent invocation of this iterator (other than its destructor) must return an error.

:NOTE: Both the sIiteratorListLock and the container lock must be held by the caller.

invalidate is called by the UtlContainer from its destructor. It disconnects the iterator from its container object (sets mpMyContainer to NULL).

Any subsequent invocation of this iterator (other than its destructor) must not attempt to access *mpMyContainer.

Friends And Related Function Documentation

friend class UtlContainer
friend

Member Data Documentation

OsBSem mContainerRefLock
protected

The mContainerRefLock must be held whenever the mpMyContainer value is being used or modified. If the mpIteratorListLock in the container is also held, then the mpIteratorListLock must be taken first.

UtlContainer* mpMyContainer
protected