BALL::BaseIterator< Container, DataType, Position, Traits > Class Template Reference
[Iterators]

Generic Iterator Class. More...

#include <baseIterator.h>

Inheritance diagram for BALL::BaseIterator< Container, DataType, Position, Traits >:
Inheritance graph
[legend]

List of all members.


Public Types

Typedefs.
The names of these typedefs deviate from the usual BALL class names due to restrictions imposed by STL compliance.

typedef DataType value_type
typedef Position difference_type
typedef const DataType * pointer
typedef const DataType & reference
typedef std::input_iterator_tag iterator_category

Public Member Functions

Constructors and Destructors
BaseIterator ()
Default constructor.
BaseIterator (const BaseIterator &iterator)
Copy constructor.
~BaseIterator ()
Destructor.
Assignment
BaseIterator & operator= (const BaseIterator &iterator)
Assignment operator.
void swap (BaseIterator &iterator)
Swap two iterators.
Accessors
void invalidate ()
Invalidate the iterator.
void setTraits (const Traits &traits)
Set the traits.
const Traits & getTraits () const
Get a constant reference to the traits of this iterator.
Traits & getTraits ()
Get a constant reference to the traits of this iterator.
const Container * getContainer () const
Get a constant pointer to the container of this iterator.
Converters
operator const Position & () const
Convert an iterator to Position.
reference operator* () const
Convert an iterator to its Datatype by returning a reference to the current data.
pointer operator-> () const
Return a pointer to the current data.
Predicates
bool operator== (const BaseIterator &iterator) const
Equality operator.
bool operator!= (const BaseIterator &iterator) const
Inequality operator.
bool isSingular () const
Singularity predicate.
bool isValid () const
Validity predicate.
bool operator+ () const
Validity predicate.
bool operator- () const
Invalidity perdicate.

Protected Member Functions

BaseIterator (const Container &container)
Constructor.

Detailed Description

template<typename Container, typename DataType, typename Position, typename Traits>
class BALL::BaseIterator< Container, DataType, Position, Traits >

Generic Iterator Class.

This template class implements the basic behaviour of an iterator. Iterators are basically STL-like iterators. They provide the full STL iterator interface, but also offer additional features.

BaseIterator itself is a base class to the other iterator classes only and should not be used by itself.
An important difference exists for the iterators of the kernel objects. For most kernel objects, multiple iterators exist. Therefore, we could not simply use begin() and end() like in STL, but we introduced specialized methods like AtomContainer::beginAtom and AtomContainer::endAtom . For similar reasons, the iterators for kernel classes are not implemented as nested classes of the respective kernel classes, but as independent classes to avoid code replication. An exception is Atom::BondIterator , which is relevant to Atom alone.
Each BALL iterator can be bound to a container, so once the iteration has started, it "knows" about the end() of the container. Therefore, BALL iterators additionally implement the unary plus operator to check for the validity of the iterator. this allows the convenient implementation of for loops, e.g. as follows:
        AtomIterator atom_it = system.beginAtom();
        for (; +atom_it; ++atom_it)
        {
          ....
        }

Constructor & Destructor Documentation

template<typename Container, typename DataType, typename Position, typename Traits>
BALL::BaseIterator< Container, DataType, Position, Traits >::BaseIterator ( const Container & container ) [protected]

Constructor.

Protected to allow instantiation and use in derived classes only.


Member Function Documentation

template<typename Container, typename DataType, typename Position, typename Traits>
bool BALL::BaseIterator< Container, DataType, Position, Traits >::isSingular ( ) const

Singularity predicate.

This method returns true if the iterator is singular, i.e., not associated with a container.

template<typename Container, typename DataType, typename Position, typename Traits>
bool BALL::BaseIterator< Container, DataType, Position, Traits >::isValid ( ) const

Validity predicate.

Returns:
true if the iterator is valid (pointing at an element in a container)

Referenced by BALL::Composite::getNext().

template<typename Container, typename DataType, typename Position, typename Traits>
BALL::BaseIterator< Container, DataType, Position, Traits >::operator const Position & ( ) const

Convert an iterator to Position.

This method returns the position of the iterator. Note that Position is a template within this context and not the BALL datatype.

template<typename Container, typename DataType, typename Position, typename Traits>
BaseIterator& BALL::BaseIterator< Container, DataType, Position, Traits >::operator= ( const BaseIterator< Container, DataType, Position, Traits > & iterator )

Assignment operator.

Assigns the contents of an iterator to another iterator.

Parameters:
iterator the iterator to be copied

Generated on Thu Aug 6 18:30:25 2009 for BALL by doxygen 1.5.8