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 OLENA_CORE_IMAGE2D_HH
00029 # define OLENA_CORE_IMAGE2D_HH
00030
00031 # include <oln/core/point2d.hh>
00032 # include <oln/core/dpoint2d.hh>
00033 # include <oln/core/fwd_iter2d.hh>
00034 # include <oln/core/bkd_iter2d.hh>
00035 # include <oln/core/impl/image_array2d.hh>
00036 # include <oln/core/image.hh>
00037 # include <oln/io/readable.hh>
00038
00039 # include <iostream>
00040 # include <stdlib.h>
00041
00042 namespace oln {
00043
00044 template<class T, class Exact = mlc::final>
00045 class image2d;
00046
00053 template<class T, class Exact>
00054 struct image_id<image2d<T, Exact> >
00055 {
00056 enum{dim = 2};
00057 typedef T value_type;
00058 typedef typename mlc::exact_vt<image2d<T, Exact>, Exact>::ret exact_type;
00059 typedef impl::image_array2d<T> impl_type;
00060 typedef point2d point_type;
00061 typedef image2d_size size_type;
00062 };
00063
00070 template<class T, class Exact>
00071 struct image_traits<image2d<T, Exact> >:
00072 public image_traits<image<image_id<image2d<T, Exact> >::dim,
00073 typename image_id<image2d<T, Exact> >::value_type,
00074 typename image_id<image2d<T, Exact> >::impl_type,
00075 typename image_id<image2d<T, Exact> >::exact_type> >
00076 {};
00077
00078
00079
00080
00088 template<class T, class Exact>
00089 class image2d:
00090 public image<image_id<image2d<T, Exact> >::dim,
00091 typename image_id<image2d<T, Exact> >::value_type,
00092 typename image_id<image2d<T, Exact> >::impl_type,
00093 typename image_id<image2d<T, Exact> >::exact_type>
00094 {
00095
00096 public:
00097
00098 typedef image2d<T, Exact> self_type;
00099 typedef typename image_id<image2d<T, Exact> >::value_type value_type;
00100 typedef typename image_id<image2d<T, Exact> >::exact_type exact_type;
00101 typedef typename image_id<image2d<T, Exact> >::impl_type impl_type;
00102 typedef oln::image<image_id<image2d<T, Exact> >::dim,
00103 value_type,
00104 impl_type,
00105 exact_type> super_type;
00106
00107 friend class abstract::image<exact_type>;
00108
00109
00110 image2d() :
00111 super_type()
00112 {
00113 mlc_init_static_hierarchy(Exact);
00114 }
00115
00116
00123 image2d(coord nrows, coord ncols, coord border = 2) :
00124 super_type(new impl_type(image2d_size(nrows, ncols, border)))
00125 {
00126 mlc_init_static_hierarchy(Exact);
00127 }
00128
00133 image2d(const image2d_size& size) :
00134 super_type(new impl_type(size))
00135 {
00136 mlc_init_static_hierarchy(Exact);
00137 }
00138
00147 image2d(self_type& rhs) :
00148 super_type(rhs)
00149 {
00150 mlc_init_static_hierarchy(Exact);
00151 }
00152
00153
00161 image2d(const io::internal::anything& r)
00162 : super_type()
00163 {
00164 mlc_init_static_hierarchy(Exact);
00165 r.assign(*this);
00166 }
00167
00175 image2d&
00176 operator=(const io::internal::anything& r)
00177 {
00178 return r.assign(*this);
00179 }
00180
00188 exact_type&
00189 operator=(self_type rhs)
00190 {
00191 return this->exact().assign(rhs.exact());
00192 }
00193
00194 static std::string
00195 name()
00196 {
00197 return
00198 std::string("image2d<")
00199 + ntg_name(T) + ","
00200 + Exact::name() + ">";
00201 }
00202
00204
00205 template<class U>
00206 struct mute
00207 {
00208 typedef image2d<U> ret;
00209 };
00210
00211 image2d(const self_type& rhs);
00212
00213 protected:
00214
00216 exact_type
00217 clone_() const
00218 {
00219 exact_type output(this->nrows(), this->ncols(), this->border());
00220 clone_to(output.impl());
00221 return output;
00222 }
00223
00224 };
00225
00231 template <class T, class Exact>
00232 struct dim_traits<2, T, Exact>
00233 {
00234 typedef image2d<T, Exact> img_type;
00235 };
00236 }
00237
00238 #endif // ! OLENA_CORE_IMAGE2D_HH