iterator::DoubleListIterator< Item > Class Template Reference

#include <iterator.h>

Inheritance diagram for iterator::DoubleListIterator< Item >:
pdfobjects::AcceptingPdfOperatorIterator< _NAME_COUNT, T > pdfobjects::ChangePdfOperatorIterator pdfobjects::RejectingPdfOperatorIterator< _NAME_COUNT, T >

List of all members.

Public Types

typedef
IteratorInvalidObjectException 
Exception
typedef boost::weak_ptr< Item > ListItem

Public Member Functions

 DoubleListIterator (ListItem oper)
 DoubleListIterator ()
virtual ~DoubleListIterator ()
DoubleListIterator< Item > & next ()
DoubleListIterator< Item > & prev ()
bool operator== (const DoubleListIterator< Item > &it) const
boost::shared_ptr< Item > getCurrent () const
bool valid () const
bool isBegin () const
bool isEnd () const

Protected Member Functions

bool _invalidItem (ListItem it)
virtual bool validItem () const

Protected Attributes

ListItem _cur
Position _curpos

Private Types

enum  Position { _end, _begin, _valid, _invalid }

Static Private Attributes

static const Position pend = _end
static const Position pbegin = _begin
static const Position pvalid = _valid
static const Position pinvalid = _invalid

Detailed Description

template<typename Item>
class iterator::DoubleListIterator< Item >

Iterator implementation. Interface is similar to the Iterator design pattern (Gof book). It is not supposed to be like stl iterators, because we do NOT need all the functionality stl provides.

It is a generic iterator over items that form a doubly linked list. The item type over which to iterate has to implement 2 methods:

The main difference between stl iterators and this iterator is where information about previous and next items is stored. In this iterator it is in the item itself while in stl it is in a special container.

This list is intended to be used with smart pointers. Which means we can not build the linked list using smart pointers because we would get a dependency cycle and the objects would be never freed. So instead smart pointers we use a weak pointers from which you can can get the smart pointer. We can not simply use raw pointers because we are using smart pointers all over the code so we have to be able to get smart pointer from an iterator.

This class has two design pattern template methods. It can be easily extended to specific iterators overloading isValidItem() method. This is a very powerful feature which gives us enormous flexibilty over a list queue. We can easily iterate only over specific items.


Member Typedef Documentation

template<typename Item>
typedef IteratorInvalidObjectException iterator::DoubleListIterator< Item >::Exception

ListItem type.

template<typename Item>
typedef boost::weak_ptr<Item> iterator::DoubleListIterator< Item >::ListItem

Member Enumeration Documentation

template<typename Item>
enum iterator::DoubleListIterator::Position [private]
Enumerator:
_end 
_begin 
_valid 
_invalid 

Constructor & Destructor Documentation

template<typename Item>
iterator::DoubleListIterator< Item >::DoubleListIterator ( ListItem  oper  )  [inline]
template<typename Item>
iterator::DoubleListIterator< Item >::DoubleListIterator (  )  [inline]

Created iterator is not in valid state and can not be used to iterate.

template<typename Item>
virtual iterator::DoubleListIterator< Item >::~DoubleListIterator (  )  [inline, virtual]

Dtor.


Member Function Documentation

template<typename Item>
bool iterator::DoubleListIterator< Item >::_invalidItem ( ListItem  it  )  [inline, protected]
template<typename Item>
boost::shared_ptr<Item> iterator::DoubleListIterator< Item >::getCurrent (  )  const [inline]
template<typename Item>
bool iterator::DoubleListIterator< Item >::isBegin (  )  const [inline]
template<typename Item>
bool iterator::DoubleListIterator< Item >::isEnd (  )  const [inline]
template<typename Item>
DoubleListIterator<Item>& iterator::DoubleListIterator< Item >::next (  )  [inline]
template<typename Item>
bool iterator::DoubleListIterator< Item >::operator== ( const DoubleListIterator< Item > &  it  )  const [inline]
template<typename Item>
DoubleListIterator<Item>& iterator::DoubleListIterator< Item >::prev (  )  [inline]
template<typename Item>
bool iterator::DoubleListIterator< Item >::valid (  )  const [inline]
template<typename Item>
virtual bool iterator::DoubleListIterator< Item >::validItem (  )  const [inline, protected, virtual]

In the base iterator, loop through all objects. We can overload this function to be able to iterate only over specific items.

Returns:
True if the item is supported by this type of iterator, false otherwise.

Reimplemented in pdfobjects::AcceptingPdfOperatorIterator< _NAME_COUNT, T >, pdfobjects::RejectingPdfOperatorIterator< _NAME_COUNT, T >, and pdfobjects::ChangePdfOperatorIterator.

Referenced by iterator::DoubleListIterator< Item >::next(), and iterator::DoubleListIterator< Item >::prev().


Member Data Documentation

template<typename Item>
ListItem iterator::DoubleListIterator< Item >::_cur [protected]
template<typename Item>
Position iterator::DoubleListIterator< Item >::_curpos [protected]
template<typename Item>
const Position iterator::DoubleListIterator< Item >::pbegin = _begin [static, private]
template<typename Item>
const Position iterator::DoubleListIterator< Item >::pend = _end [static, private]
template<typename Item>
const Position iterator::DoubleListIterator< Item >::pinvalid = _invalid [static, private]
template<typename Item>
const Position iterator::DoubleListIterator< Item >::pvalid = _valid [static, private]

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