NAME

OTC_Iterator - A smart pointer for iterators.

SYNOPSIS


#include <OTC/collctn/iterator.hh>

template<class T>
class OTC_Iterator
{
  public:
    static os_typespec* get_os_typespec();
    inline ~OTC_Iterator();
    inline OTC_Iterator();
    inline OTC_Iterator(OTC_Cursor<T>* anIter);
    inline OTC_Iterator(OTC_Iterator<T> const& anIter);
    inline OTC_Iterator<T>& operator=(OTC_Cursor<T>* anIter);
    inline OTC_Iterator<T>& operator=(OTC_Iterator<T> const& anIter);
    inline void next();
    inline void reset();
    inline T const& item() const;
    inline OTC_Boolean isValid() const;
    inline OTC_Iterator<T> clone() const;
    inline void apply(OTC_Visitor<T>& theApplicator);
  protected:
    inline T& _item() const;
    inline OTC_Cursor<T>* _clone() const;
    inline void _apply(OTC_Visitor<T>& theApplicator);
    inline void _apply(OTC_Worker<T>& theApplicator);
};

CLASS TYPE

Concrete

DESCRIPTION

This class exists so that the user of an iterator for a particular type of collection, does not have to worry about deleting the iterator when finished with it, nor need to know how to create an iterator for a specific type of collection. This class will ensure that the iterator is destroyed, when this class goes out of scope. In order for this to work correctly, an instance of this class should never be created using new.

EXAMPLE

INITIALISATION

inline OTC_Iterator();
inline OTC_Iterator(OTC_Cursor<T>* anIter);
inline OTC_Iterator(OTC_Iterator<T> const& anIter);
inline OTC_Iterator<T>& operator=(OTC_Cursor<T>* anIter);
inline OTC_Iterator<T>& operator=(OTC_Iterator<T> const& anIter);

MOVEMENT

inline void next();
inline void reset();

RETRIEVAL

inline T const& item() const;
inline OTC_Boolean isValid() const;

CLONING

inline OTC_Iterator<T> clone() const;

APPLICATOR

inline void apply(OTC_Visitor<T>& theApplicator);

LIBRARY

OTC

AUTHOR(S)

Graham Dumpleton

COPYRIGHT

Copyright 1991 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED