CoreLinux++  0.4.32
Iterator.hpp
1 #if !defined(__ITERATOR_HPP)
2 #define __ITERATOR_HPP
3 
4 /*
5  CoreLinux++
6  Copyright (C) 2000 CoreLinux Consortium
7 
8  The CoreLinux++ Library is free software; you can redistribute it and/or
9  modify it under the terms of the GNU Library General Public License as
10  published by the Free Software Foundation; either version 2 of the
11  License, or (at your option) any later version.
12 
13  The CoreLinux++ Library Library is distributed in the hope that it will
14  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  Library General Public License for more details.
17 
18  You should have received a copy of the GNU Library General Public
19  License along with the GNU C Library; see the file COPYING.LIB. If not,
20  write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
21  Boston, MA 02111-1307, USA.
22 */
23 
24 #if !defined(__COMMON_HPP)
25 #include <Common.hpp>
26 #endif
27 
28 #include <IteratorBoundsException.hpp>
29 
30 namespace corelinux
31 {
32 
33  DECLARE_CLASS( IteratorBoundsException );
34  DECLARE_CLASS( InvalidIteratorException );
35 
43  template< class ElementType >
44  class Iterator : public CoreLinuxObject
45  {
46  public:
47 
48  //
49  // Constructors and destructor
50  //
51 
53 
54  Iterator( void )
55  :
57  {
58  ; // do nothing
59  }
60 
66  Iterator( const Iterator &aRef )
67  :
68  CoreLinuxObject( aRef )
69  {
70  ; // do nothing
71  }
72 
74 
75  virtual ~Iterator( void )
76  {
77  ; // do nothing
78  }
79 
80  //
81  // Operator overloads
82  //
83 
91  {
92  return (*this);
93  }
94 
101  bool operator==( const Iterator & aRef ) const
102  {
103  return (this == &aRef);
104  }
105 
106 
107  //
108  // Accessors
109  //
117  virtual bool isValid( void ) const = 0;
118 
127  virtual ElementType getElement( void )
128  const throw(IteratorBoundsException) = 0;
129 
130  //
131  // Mutators
132  //
133 
135 
136  virtual void setFirst( void ) = 0;
137 
144  virtual void setNext( void )
145  throw(IteratorBoundsException) = 0;
146 
153  virtual void setPrevious( void )
154  throw(IteratorBoundsException) = 0;
155 
162  virtual void setLast( void )
163  throw(IteratorBoundsException) = 0;
164 
165 
166  };
167 }
168 
169 #endif // if !defined(__ITERATOR_HPP)
170 
171 /*
172  Common rcs information do not modify
173  $Author: prudhomm $
174  $Revision: 1.2 $
175  $Date: 2000/08/31 22:52:20 $
176  $Locker: $
177 */
178 
IteratorBoundsException is thrown when a Iterator has position before the begining or past the end po...
Definition: IteratorBoundsException.hpp:44
Iterator(void)
Default constructor.
Definition: Iterator.hpp:54
virtual void setFirst(void)=0
Set iterator to first element.
virtual void setLast(void)=0
Set iterator to last element if it is the iterator is over an empty collection.
Iterator(const Iterator &aRef)
Copy constructor.
Definition: Iterator.hpp:66
virtual ~Iterator(void)
Destructor.
Definition: Iterator.hpp:75
The Iterator provides a way to access the elements of an collection type sequentially without exposin...
Definition: Iterator.hpp:44
An CoreLinuxObject is a base class for the library.
Definition: CoreLinuxObject.hpp:39
bool operator==(const Iterator &aRef) const
Equality operator.
Definition: Iterator.hpp:101
virtual bool isValid(void) const =0
isValid abstract interface for implementation to determine if the current position points to a valid ...
virtual ElementType getElement(void) const =0
getElement returns the ElementType instance that is currently pointed to by the Iterator ...
virtual void setNext(void)=0
Set iterator to next element if attempt to position past end of elements.
Iterator & operator=(const Iterator &)
Assignment operator.
Definition: Iterator.hpp:90
virtual void setPrevious(void)=0
Set iterator to previous element if attempt to position before begining of elements.

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