CoreLinuxIterator.hpp
#if !defined(__CORELINUXITERATOR_HPP)
#define __CORELINUXITERATOR_HPP
/*
CoreLinux++
Copyright (C) 2000 CoreLinux Consortium
The CoreLinux++ Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The CoreLinux++ Library Library is distributed in the hope that it will
be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#if !defined(__COMMON_HPP)
#include <Common.hpp>
#endif
#if !defined(__ITERATOR_HPP)
#include <Iterator.hpp>
#endif
#if !defined(__INVALIDITERATOREXCEPTION_HPP)
#include <InvalidIteratorException.hpp>
#endif
#if !defined(__ITERATORBOUNDSEXCEPTION_HPP)
#include <IteratorBoundsException.hpp>
#endif
namespace corelinux
{
template< class TraverseType, class ElementType >
class CoreLinuxIterator : public Iterator<ElementType>
{
public:
//
// Constructors and destructor
//
CoreLinuxIterator( void )
throw(InvalidIteratorException)
:
Iterator<ElementType>()
{
throw InvalidIteratorException(LOCATION);
}
CoreLinuxIterator( TraverseType aBegin,
TraverseType aEnd )
:
Iterator<ElementType>(),
theBegin( aBegin ),
theEnd( aEnd ),
theCurrent( theBegin )
{
; // do nothing
}
CoreLinuxIterator( const CoreLinuxIterator &aRef )
:
Iterator<ElementType>( aRef ),
theBegin( aRef.theBegin ),
theEnd( aRef.theEnd ),
theCurrent( aRef.theBegin )
{
; // do nothing
}
virtual ~CoreLinuxIterator( void )
{
theBegin = theEnd;
theCurrent = theEnd;
}
//
// Operator overloads
//
CoreLinuxIterator & operator=
( const CoreLinuxIterator & aRef )
{
theBegin = aRef.theBegin;
theEnd = aRef.theEnd;
theCurrent = theBegin;
return (*this);
}
bool operator==( const CoreLinuxIterator & aRef ) const
{
return (theBegin == aRef.theBegin &&
theEnd == aRef.theEnd);
}
//
// Accessors
//
virtual bool isValid( void ) const
{
return !(theCurrent == theEnd);
}
virtual ElementType getElement( void )
const throw(IteratorBoundsException)
{
if( this->isValid() == false )
{
throw IteratorBoundsException(LOCATION);
}
else
{
; // do nothing
}
return (*theCurrent);
}
//
// Mutators
//
virtual void setFirst( void )
{
theCurrent = theBegin;
}
virtual void setNext( void )
throw(IteratorBoundsException)
{
if( theCurrent != theEnd )
{
++theCurrent;
}
else
{
throw IteratorBoundsException(LOCATION);
}
}
virtual void setPrevious( void )
throw(IteratorBoundsException)
{
if( theCurrent != theBegin &&
theBegin != theEnd )
{
--theCurrent;
}
else
{
throw IteratorBoundsException(LOCATION);
}
}
virtual void setLast( void )
throw(IteratorBoundsException)
{
theCurrent = theEnd;
setPrevious();
}
//
// Protected methods
//
protected:
//
// Protected members
//
protected:
TraverseType theBegin;
TraverseType theEnd;
TraverseType theCurrent;
};
}
#endif // if !defined(__CORELINUXITERATOR_HPP)
/*
Common rcs information do not modify
$Author: prudhomm $
$Revision: 1.1 $
$Date: 2000/04/23 20:43:13 $
$Locker: $
*/
corelinux::InvalidIteratorException
InvalidIteratorException is an exception that indicates a Iterator could not be properly formed for s...
Definition: InvalidIteratorException.hpp:43
corelinux::CoreLinuxIterator::CoreLinuxIterator
CoreLinuxIterator(const CoreLinuxIterator &aRef)
Copy constructor.
Definition: CoreLinuxIterator.hpp:94
corelinux::IteratorBoundsException
IteratorBoundsException is thrown when a Iterator has position before the begining or past the end po...
Definition: IteratorBoundsException.hpp:44
corelinux::CoreLinuxIterator::~CoreLinuxIterator
virtual ~CoreLinuxIterator(void)
Destructor.
Definition: CoreLinuxIterator.hpp:106
corelinux::CoreLinuxIterator::setFirst
virtual void setFirst(void)
Set iterator to first element.
Definition: CoreLinuxIterator.hpp:188
corelinux::CoreLinuxIterator::throw
throw(InvalidIteratorException)
Default constructor - the CoreLinuxIterator requires being constructed with a valid collection...
Definition: CoreLinuxIterator.hpp:66
corelinux::CoreLinuxIterator::setLast
virtual void setLast(void)
Set iterator to last element.
Definition: CoreLinuxIterator.hpp:234
corelinux::CoreLinuxIterator::theEnd
TraverseType theEnd
The last position.
Definition: CoreLinuxIterator.hpp:259
corelinux::CoreLinuxIterator::setPrevious
virtual void setPrevious(void)
Set iterator to previous element if attempt to position before begining of elements.
Definition: CoreLinuxIterator.hpp:218
corelinux::CoreLinuxIterator::isValid
virtual bool isValid(void) const
isValid implementation for determining if the current position points to a valid EntityType instance ...
Definition: CoreLinuxIterator.hpp:155
corelinux::CoreLinuxIterator
The CoreLinuxIterator provides a way to access the elements of any of the non-associative STL collect...
Definition: CoreLinuxIterator.hpp:50
corelinux::CoreLinuxIterator::CoreLinuxIterator
CoreLinuxIterator(TraverseType aBegin, TraverseType aEnd)
Initializing constructor.
Definition: CoreLinuxIterator.hpp:79
corelinux::CoreLinuxIterator::operator==
bool operator==(const CoreLinuxIterator &aRef) const
Equality operator.
Definition: CoreLinuxIterator.hpp:138
corelinux::CoreLinuxIterator::theBegin
TraverseType theBegin
The first position.
Definition: CoreLinuxIterator.hpp:255
corelinux::Iterator
The Iterator provides a way to access the elements of an collection type sequentially without exposin...
Definition: Iterator.hpp:44
corelinux::CoreLinuxIterator::theCurrent
TraverseType theCurrent
The current position.
Definition: CoreLinuxIterator.hpp:263
corelinux::CoreLinuxIterator::setNext
virtual void setNext(void)
Set iterator to next element if attempt to position past end of elements.
Definition: CoreLinuxIterator.hpp:199
corelinux::CoreLinuxIterator::getElement
virtual ElementType getElement(void) const
getElement returns the ElementType instance that is currently managed by the CoreLinuxIterator ...
Definition: CoreLinuxIterator.hpp:168

This is the CoreLinux++ reference manual
Provided by The CoreLinux Consortium