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 #ifndef OLN_MORPHER_ITER_MORPHER_HH
00029 # define OLN_MORPHER_ITER_MORPHER_HH
00030
00031 # include <oln/morpher/generic_morpher.hh>
00032
00033 namespace oln {
00034
00035 namespace morpher {
00036
00037 template <class SrcType, class IterType, class Exact = mlc::final>
00038 struct iter_morpher;
00039
00040 }
00041
00043 template <class SrcType, class IterType, class Exact>
00044 struct image_id< morpher::iter_morpher<SrcType, IterType, Exact> >
00045 {
00046 enum {dim = SrcType::dim};
00047 typedef oln_impl_type(SrcType) impl_type;
00049 typedef oln_value_type(SrcType) value_type;
00051 typedef typename mlc::exact_vt<
00052 morpher::iter_morpher<SrcType, IterType, Exact>,
00053 Exact
00054 >::ret exact_type;
00056 typedef oln_point_type(SrcType) point_type;
00057 typedef oln_dpoint_type(SrcType) dpoint_type;
00058 typedef oln_size_type(SrcType) size_type;
00059 typedef IterType iter_type;
00060 };
00061
00063 template <class SrcType, class IterType, class Exact>
00064 struct image_traits < morpher::iter_morpher<SrcType, IterType, Exact> >
00065 : public
00066 image_traits<
00067 morpher::abstract::generic_morpher<
00068 SrcType,
00069 typename image_id<morpher::iter_morpher<SrcType,
00070 IterType,
00071 Exact> >::exact_type
00072 >
00073 >
00074 {
00075 typedef IterType iter_type;
00076 };
00077
00078 namespace morpher {
00079
00080 template <class SrcType, class IterType, class Exact>
00081 struct iter_morpher
00082 : public abstract::generic_morpher<
00083 SrcType,
00084 typename image_id<iter_morpher<SrcType,
00085 IterType,
00086 Exact> >::exact_type
00087 >
00088 {
00089 typedef iter_morpher<SrcType, IterType, Exact> self_type;
00090 typedef typename image_id<self_type>::exact_type exact_type;
00091 typedef abstract::generic_morpher<SrcType, exact_type> super_type;
00092
00093 typedef typename image_id<exact_type>::iter_type iter_type;
00094 typedef typename image_id<exact_type>::value_type value_type;
00095 typedef typename image_id<exact_type>::point_type point_type;
00096
00098 iter_morpher(const SrcType &ima)
00099 : super_type(ima)
00100 {}
00101
00103 iter_morpher(const self_type& r)
00104 : super_type(r.get_ima())
00105 {}
00106
00112 iter_morpher() {}
00113
00118 self_type&
00119 assign(self_type& rhs)
00120 {
00121 oln_iter_type(SrcType) it(rhs);
00122
00123 for_all(it)
00124 this->at(it) = rhs[it];
00125 return this->exact();
00126 }
00127
00133 value_type&
00134 at(const point_type& p)
00135 {
00136 return const_cast<value_type &>
00137 ( const_cast<SrcType &>(this->ima_)[p] );
00138 }
00139
00145 const value_type
00146 at(const point_type& p) const
00147 {
00148 return this->ima_[p];
00149 }
00150
00152 static std::string
00153 name()
00154 {
00155 return "iter_morpher<" + super_type::name() + ">";
00156 }
00157
00158 };
00159
00161 template <class SrcType, class IterType, class Exact>
00162 struct iter_morpher<const SrcType, IterType, Exact>
00163 : public
00164 abstract::generic_morpher<
00165 const SrcType,
00166 typename image_id<iter_morpher<const SrcType,
00167 IterType,
00168 Exact> >::exact_type
00169 >
00170 {
00171 typedef iter_morpher<const SrcType, IterType, Exact> self_type;
00172 typedef typename image_id<self_type>::exact_type exact_type;
00173 typedef abstract::generic_morpher<const SrcType, exact_type>
00174 super_type;
00175
00176 typedef typename image_id<exact_type>::iter_type iter_type;
00177 typedef typename image_id<exact_type>::value_type value_type;
00178 typedef typename image_id<exact_type>::point_type point_type;
00179
00181 iter_morpher(const SrcType &ima)
00182 : super_type(ima)
00183 {}
00184
00186 iter_morpher(const self_type& r)
00187 : super_type(r.get_ima())
00188 {}
00189
00195 iter_morpher() {}
00196
00201 self_type&
00202 assign(self_type& rhs)
00203 {
00204 oln_iter_type(SrcType) it(rhs);
00205
00206 for_all(it)
00207 this->at(it) = rhs[it];
00208 return this->exact();
00209 }
00210
00216 const value_type
00217 at(const point_type& p) const
00218 {
00219 return this->ima_[p];
00220 }
00221
00223 static std::string
00224 name()
00225 {
00226 return "iter_morpher<" + super_type::name() + ">";
00227 }
00228
00229 };
00230
00271 template <class IterType, class I>
00272 const iter_morpher<I, IterType>
00273 iter_morph(I &ima)
00274 {
00275 return iter_morpher<I, IterType>(ima);
00276 }
00277
00278 }
00279
00280 }
00281
00282 #endif // !ITER_MORPHER