OFFIS DCMTK  Version 3.6.0
ofsetit.h
1 /*
2  *
3  * Copyright (C) 2003-2010, OFFIS e.V.
4  * All rights reserved. See COPYRIGHT file for details.
5  *
6  * This software and supporting documentation were developed by
7  *
8  * OFFIS e.V.
9  * R&D Division Health
10  * Escherweg 2
11  * D-26121 Oldenburg, Germany
12  *
13  *
14  * Module: ofstd
15  *
16  * Author: Thomas Wilkens
17  *
18  * Purpose: Template class which represents an iterator class for corres-
19  * ponding set data structures in ofstd.
20  *
21  * Last Update: $Author: joergr $
22  * Update Date: $Date: 2010-10-14 13:15:50 $
23  * CVS/RCS Revision: $Revision: 1.4 $
24  * Status: $State: Exp $
25  *
26  * CVS/RCS Log at end of file
27  *
28  */
29 
30 #ifndef OFSETIT_H
31 #define OFSETIT_H
32 
33 #include "dcmtk/config/osconfig.h"
34 #include "dcmtk/ofstd/oftypes.h"
35 #include "dcmtk/ofstd/ofset.h"
36 
51 template <class T> class OFSetIterator
52 {
53  protected:
57  unsigned int pos;
58 
59  public:
64  : ofset( ofsetv ), pos( 0 )
65  {
66  }
67 
70  virtual ~OFSetIterator()
71  {
72  }
73 
77  {
78  pos = 0;
79  }
80 
83  void ResetEnd()
84  {
85  unsigned int num = ofset.NumberOfElements();
86 
87  if( num == 0 )
88  pos = 0;
89  else
90  pos = num - 1;
91  }
92 
96  T *Object()
97  {
98  if( pos == ofset.NumberOfElements() )
99  return( NULL );
100  else
101  return( &ofset[pos] );
102  }
103 
106  void Next()
107  {
108  if( pos < ofset.NumberOfElements() )
109  pos++;
110  }
111 
114  void Prev()
115  {
116  unsigned int num = ofset.NumberOfElements();
117 
118  if( pos == 0 || pos == num )
119  pos = num;
120  else
121  pos--;
122  }
123 
128  OFBool operator==( const OFSetIterator<T> &other ) const
129  {
130  // two iterators are considered to be identical, if and only if they operate on the
131  // exact same set (identical addresses) and they currently refer to the same element
132  if( &ofset == &other.ofset && pos == other.pos )
133  return( OFTrue );
134  else
135  return( OFFalse );
136  }
137 
142  OFBool operator!=( const OFSetIterator<T> &other ) const
143  {
144  return( !( *this == other ) );
145  }
146 };
147 
148 #endif
149 
150 /*
151 ** CVS/RCS Log:
152 ** $Log: ofsetit.h,v $
153 ** Revision 1.4 2010-10-14 13:15:50 joergr
154 ** Updated copyright header. Added reference to COPYRIGHT file.
155 **
156 ** Revision 1.3 2010-10-05 08:36:51 joergr
157 ** Fixed various Doxygen API documentation issues.
158 **
159 ** Revision 1.2 2005/12/08 16:06:02 meichel
160 ** Changed include path schema for all DCMTK header files
161 **
162 ** Revision 1.1 2003/08/20 14:45:25 wilkens
163 ** Added new class OFSetIterator, an iterator class for OFxxxSet data structures.
164 **
165 **
166 */


Generated on Thu Dec 20 2012 for OFFIS DCMTK Version 3.6.0 by Doxygen 1.8.2