Go to the documentation of this file.00001
00002 #ifndef vipl_section_iterator_txx_
00003 #define vipl_section_iterator_txx_
00004
00005
00006
00007 #include "vipl_section_iterator.h"
00008 #include <vipl/section/vipl_section_container.h>
00009 #include <vipl/section/vipl_section_descriptor.h>
00010 #include <vipl/filter/vipl_filter_abs.h>
00011 #if 0
00012 #include <vcl_iostream.h>
00013 #endif
00014
00015 #ifdef VCL_VC
00016
00017 # pragma warning( push )
00018 # pragma warning( disable : 4390 )
00019 #endif
00020
00021
00022 template < class DataType >
00023 vipl_section_iterator< DataType > ::vipl_section_iterator(
00024 vipl_section_descriptor< DataType >* desc ,
00025 vipl_section_container< DataType >* containr)
00026 : hsreal_descriptor(desc),
00027 hscontainer(containr),
00028 hsincr_count(0)
00029 {
00030 if (desc) { FILTER_IMPTR_INC_REFCOUNT(desc); }
00031 if (containr) { FILTER_IMPTR_INC_REFCOUNT(containr); }
00032 #if 0
00033 vcl_cerr << "Warning: called unimplemented constructor with signature "
00034 << "vipl_section_descriptor< DataType >* desc, vipl_section_container< DataType >* containr\n";
00035 #endif
00036 }
00037
00038 #ifdef VCL_VC
00039
00040 # pragma warning( pop )
00041 # pragma warning( disable : 4390 )
00042 #endif
00043
00044
00045
00046 template < class DataType >
00047 vipl_section_iterator< DataType > ::vipl_section_iterator(
00048 vipl_section_descriptor< DataType >* desc ,
00049 vipl_section_container< DataType >* containr ,
00050 int t)
00051 : hsreal_descriptor(0),
00052 hscontainer(0),
00053 hsincr_count(0)
00054 {
00055 hsreal_descriptor = desc->virtual_copy();
00056 hscontainer = containr->virtual_copy();
00057 }
00058
00059 template < class DataType >
00060 vipl_section_iterator< DataType > ::~vipl_section_iterator()
00061 {
00062 if (ref_container()) FILTER_IMPTR_DEC_REFCOUNT(ref_container());
00063 if (ref_real_descriptor()) FILTER_IMPTR_DEC_REFCOUNT(ref_real_descriptor());
00064 #if 0
00065 vcl_cerr << "Warning: called unimplemented vipl_section_iterator destructor\n";
00066 #endif
00067 }
00068
00069 template < class DataType >
00070 vipl_section_iterator< DataType > ::vipl_section_iterator()
00071 : hsreal_descriptor(0),
00072 hscontainer(0),
00073 hsincr_count(0)
00074
00075 {
00076 }
00077
00078 template < class DataType >
00079 vipl_section_iterator< DataType > ::vipl_section_iterator(const vipl_section_iterator< DataType > &t)
00080 : hsreal_descriptor(0),
00081 hscontainer(0),
00082 hsincr_count(t.hsincr_count)
00083
00084 {
00085
00086
00087
00088
00089
00090 if (t.hsreal_descriptor)
00091 hsreal_descriptor = t.hsreal_descriptor->virtual_copy();
00092 if (t.hscontainer)
00093 hscontainer = t.hscontainer->virtual_copy();
00094 }
00095
00096 template < class DataType >
00097 vipl_section_iterator< DataType >& vipl_section_iterator< DataType > ::operator++()
00098 {
00099
00100 if (ref_container()->next_section(*ref_real_descriptor()))
00101 ++ref_incr_count();
00102 else {
00103
00104
00105 FILTER_IMPTR_DEC_REFCOUNT(ref_real_descriptor());
00106 }
00107 return *this;
00108 }
00109
00110
00111 template < class DataType >
00112 vipl_section_iterator< DataType > vipl_section_iterator< DataType > ::operator++(int )
00113 {
00114 vipl_section_iterator<DataType> rtn(*this);
00115 ++(*this);
00116 return rtn;
00117 }
00118
00119
00120 template < class DataType >
00121 vipl_section_descriptor< DataType > vipl_section_iterator< DataType > ::operator*()
00122 {
00123 return *real_descriptor();
00124 }
00125
00126
00127
00128
00129
00130
00131 template < class DataType >
00132 bool vipl_section_iterator< DataType > ::operator==( const vipl_section_iterator< DataType >& p) const
00133 {
00134 if (this == &p) return true;
00135
00136
00137 if (real_descriptor() == p.real_descriptor()) return true;
00138 else if ((! real_descriptor()) ^ (! p.real_descriptor()))
00139 return false;
00140 if (*p.container() == *container() &&
00141 p.incr_count() == incr_count()) return true;
00142 return false;
00143 }
00144
00145 template < class DataType >
00146 bool vipl_section_iterator< DataType > ::operator!=( const vipl_section_iterator< DataType >& p) const
00147 {
00148 return !(*this == p);
00149 }
00150
00151 template < class DataType >
00152 vipl_section_iterator< DataType >& vipl_section_iterator< DataType > ::operator=(
00153 const
00154 vipl_section_iterator< DataType >& p)
00155 {
00156 if (&p != this) {
00157 if (hscontainer) FILTER_IMPTR_DEC_REFCOUNT(hscontainer);
00158 if (hsreal_descriptor) FILTER_IMPTR_DEC_REFCOUNT(hsreal_descriptor);
00159 if (p.hsreal_descriptor)
00160 hsreal_descriptor = p.hsreal_descriptor->virtual_copy();
00161 hscontainer = p.hscontainer->virtual_copy();
00162 }
00163 return *this;
00164 }
00165
00166 #endif // vipl_section_iterator_txx_