IlsOwnsList::Iterator
 
IlsOwnsList::Iterator
Category 
Nested class
Description 
Iterator is a class nested in the template IlsOwnsList. This nested class is used to sequentially read and update a list of ownership relations.
Related Pattern 
Iterator
Library 
<server>
Header File 
#include <ilserver/model.h>
Synopsis 
class Iterator
{
public:
Iterator(IlsOwnsList&);
Iterator(Iterator&);
Iterator& operator<<(OwnedTypeP);
Iterator& operator>>(OwnedTypeP&);
Iterator& operator++();
Iterator& operator++(int);
Iterator& operator--();
Iterator& operator--(int);
Iterator& operator=(const Position&);
Iterator& operator=(const Iterator&);
OwnedTypeP operator*() const;
IlsBoolean operator==(const Iterator&);
IlsBoolean operator!=(const Iterator&);
Position operator+(unsigned int);
Position operator-(unsigned int);
Iterator& operator+=(unsigned int i);
Iterator& operator-=(unsigned int i);
IlsBoolean eol()const;
OwnedTypeP operator[](unsigned int i);
operator IlsBoolean();
Iterator& shrink();
Iterator& shrinkBefore();
Position tellp();
Iterator& seekp(const Position& position);
Iterator& reset();
Iterator& gotoEnd();
OwnedTypeP getNextQuietly();
};
Constructors 
Iterator(IlsOwnsList&);
This constructor creates an iterator for the list that is supplied as its argument.
Iterator(Iterator&);
This copy constructor creates an iterator with the same characteristics as the one supplied as its argument. This iterator points to the same item in the list as the iterator supplied as its argument.
Member Functions 
Iterator& shrink();
This member function removes the item following the last element read from the list, or, if the list has not yet been read, it removes the first item in the list.
If several iterators or positions have been declared for the same list, be careful when you use the shrink function with one of these iterators or positions. Let us suppose we have an iterator iw, which performs write operations, and an iterator ir, which performs read operations. If ir and iw point to the same item in the list, and if iw executes the function shrink, ir may behave in an unexpected way. Also, if iw points to a given item in the list and ir points to the next item, ir may behave in an unexpected way if iw executes the function shrink.
This function throws the following exceptions:
*IlsUpdateForbidden if the member function isUpdateAllowed returns IlsFalse for the type where the relation is declared.
*IlsMinCardViolated if the minimal cardinality has been reached.
*IlsEndOfList if the iterator points to the last item of the list.
Iterator& shrinkBefore();
This member function removes the last item read from the list. Restrictions of the same kind as those mentioned for shrink apply to shrinkBefore.
This function throws the following exceptions:
*IlsMinCardViolated if the minimal cardinality has been reached.
*IlsBeginningOfList if the iterator points to the first item of the list.
Position tellp();
This member function returns the position of the iterator.
Iterator& seekp(const Position& position);
This member function moves the iterator to the specified position.
Iterator& reset();
This member function resets the iterator so that it points again to the first item of the list.
Iterator& gotoEnd();
This member function moves the iterator to the end of the list.
OwnedTypeP getNextQuietly();
This member function provides quick access to the next element of the list accessible through this iterator. It should not be used to evaluate a derived data member or to retrieve a value when using Rogue Wave Server transactions.

This method returns a null pointer when the end of the list is reached.
Example:
IlsSmartPointer<Domain> d;
IlsOwnsList<Network, Domain>::Iterator iter
(network->domains);
while (iter) {
d = iter.getNextQuietly();
if (d) {
// ...
}
}
Operators 
Iterator& operator<<(OwnedTypeP);
This operator adds an item to the list and puts it after the last item read by the iterator or at the beginning of the list if the iterator has not yet been used. If several iterators have been declared for the same list, be careful when you use one of these iterators to add an item to the list. Let us suppose we have an iterator iw, which performs write operations, and an iterator ir, which performs read operations. If ir and iw point to the same item in the list, and if iw is used to add an item to this list, ir may behave in an unexpected way.
This operator throws the following exceptions:
*IlsMaxCardViolated if the maximal cardinality has been reached.
*IlsOwnershipCycle if a cycle has been detected among ownership relations.
Iterator& operator>>(OwnedTypeP&);
This operator sequentially reads the items in the list. When the iterator is used for the first time, the item read is the one at the beginning of the list. If the iterator has reached the last item in the list, and if the list is not empty, no value is assigned to the argument of the operator during the next read operation. The conversion operator to IlsBoolean returns IlsFalse. (See operator IlsBoolean.) If an iterator is built for an empty list, the conversion operator of the iterator returns IlsFalse.
Iterator& operator++();
This increment operator moves the iterator to the next item in the list. If the iterator is moved past the last list item, the exception IlsEndOfList is thrown.
Iterator& operator++(int);
This operator is identical to the previous one except that it uses a prefix notation.
Iterator& operator--();
This operator moves the iterator to the previous item in the list. If the iterator is moved past the first list item, the exception IlsBeginningOfList is thrown.
Iterator& operator--(int);
This operator is identical to the previous one except that it uses a prefix notation.
Iterator& operator=(const Position&);
This operator moves the iterator to the specified position.
Iterator& operator=(const Iterator&);
This operator moves the iterator to the same position as the one supplied as its argument.
OwnedTypeP operator*() const;
This operator returns the next item to be read. The iterator remains at the same position.
IlsBoolean operator==(const Iterator&);
This operator indicates whether the iterator occupies the same position as the one supplied as its argument.
IlsBoolean operator!=(const Iterator&);
This operator indicates whether the iterator is not at the same position as the one supplied as its argument.
Position operator+(unsigned int);
This operator moves the iterator forward in the list according to the value supplied as its argument. If the iterator is moved past the last list item, the exception IlsEndOfList is thrown.
Position operator-(unsigned int);
This operator moves the iterator backward in the list according to the value supplied as its argument. If the iterator is moved past the first list item, the exception IlsBeginningOfList is thrown.
Iterator& operator+=(unsigned int i);
This operator moves the iterator forward according to the value supplied as its argument. If the value provided moves the iterator past the last list item, the exception IlsEndOfList is thrown.
Iterator& operator-=(unsigned int i);
This operator moves the iterator backward in the list according to the value supplied as its argument. If the value provided moves the iterator past the first list item, the exception IlsBeginningOfList is thrown.
IlsBoolean eol()const;
This operator returns IlsTrue if the end of the list has been reached.
OwnedTypeP operator[](unsigned int i);
This operator returns the i-th list item.
operator IlsBoolean();
This conversion operator indicates whether the iterator has reached the end of the list.
It returns IlsFalse if the list is empty or if at least one unsuccessful extraction has been performed.
See Also 
Exceptions, IlsOwnsList, IlsOwnsList::ConstIterator, IlsOwnsList::Position

Version 5.8
Copyright © 2014, Rogue Wave Software, Inc. All Rights Reserved.