00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef OFSETIT_H
00031 #define OFSETIT_H
00032
00033 #include "dcmtk/config/osconfig.h"
00034 #include "dcmtk/ofstd/oftypes.h"
00035 #include "dcmtk/ofstd/ofset.h"
00036
00051 template <class T> class OFSetIterator
00052 {
00053 protected:
00055 OFSet<T> &ofset;
00057 unsigned int pos;
00058
00059 public:
00063 OFSetIterator( OFSet<T> &ofsetv )
00064 : ofset( ofsetv ), pos( 0 )
00065 {
00066 }
00067
00070 virtual ~OFSetIterator()
00071 {
00072 }
00073
00076 void ResetBeginning()
00077 {
00078 pos = 0;
00079 }
00080
00083 void ResetEnd()
00084 {
00085 unsigned int num = ofset.NumberOfElements();
00086
00087 if( num == 0 )
00088 pos = 0;
00089 else
00090 pos = num - 1;
00091 }
00092
00096 T *Object()
00097 {
00098 if( pos == ofset.NumberOfElements() )
00099 return( NULL );
00100 else
00101 return( &ofset[pos] );
00102 }
00103
00106 void Next()
00107 {
00108 if( pos < ofset.NumberOfElements() )
00109 pos++;
00110 }
00111
00114 void Prev()
00115 {
00116 unsigned int num = ofset.NumberOfElements();
00117
00118 if( pos == 0 || pos == num )
00119 pos = num;
00120 else
00121 pos--;
00122 }
00123
00128 OFBool operator==( const OFSetIterator<T> &other ) const
00129 {
00130
00131
00132 if( &ofset == &other.ofset && pos == other.pos )
00133 return( OFTrue );
00134 else
00135 return( OFFalse );
00136 }
00137
00142 OFBool operator!=( const OFSetIterator<T> &other ) const
00143 {
00144 return( !( *this == other ) );
00145 }
00146 };
00147
00148 #endif
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166