NAME
OTC_Modifier -
Smart pointer for iterators. Allows modification of items.
SYNOPSIS
#include <OTC/collctn/modifier.hh>
template<class T>
class OTC_Modifier : public OTC_Iterator<T>
{
public:
static os_typespec* get_os_typespec();
inline OTC_Modifier();
inline OTC_Modifier(OTC_Cursor<T>* anIter);
inline OTC_Modifier(OTC_Modifier<T> const& anIter);
inline OTC_Modifier<T>& operator=(OTC_Cursor<T>* anIter);
inline OTC_Modifier<T>& operator=(OTC_Modifier<T> const& anIter);
inline T& item() const;
inline OTC_Modifier<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. 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
void inc(OTC_List<int>& aList)
{
OTC_Modifier<int> anIter = 0;
anIter = aList.items();
for (anIter.reset(); anIter.isValid(); anIter.next())
anIter.item()++;
}
INITIALISATION
inline OTC_Modifier();
inline OTC_Modifier(OTC_Cursor<T>* anIter);
Constructor used when an iterator
for a particular type of collection is
first created. If anIter is 0 a
null iterator is constructed.
inline OTC_Modifier(OTC_Modifier<T> const& anIter);
Copy constructor for when an iterator is
used as return type.
inline OTC_Modifier<T>& operator=(OTC_Cursor<T>* anIter);
Sets this iterator to anIter.
If anIter is 0, the iterator
is turned into a null iterator and
all associations with the previous
collection are lost.
inline OTC_Modifier<T>& operator=(OTC_Modifier<T> const& anIter);
Sets this iterator to anIter.
RETRIEVAL
inline T& item() const;
Returns the item under the current
location of the iterator. If no such item
exists, or this is a null iterator, an
exception is raised.
CLONING
inline OTC_Modifier<T> clone() const;
Returns an iterator which is
a clone of this iterator. The new
iterator will initially be located
over the same item as this iterator,
however, subsequent operations will be
independent of this iterator.
APPLICATOR
inline void apply(OTC_Visitor<T>& theApplicator);
Applies theApplicator to each item
accessible by this iterator.
inline void apply(OTC_Worker<T>& theApplicator);
Applies theApplicator to each item
accessible by this iterator.
SEE ALSO
OTC_Iterator
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1991 1992 1993 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED