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 OLENA_MORPHER_FUNC_MORPHER_HH
00031 # define OLENA_MORPHER_FUNC_MORPHER_HH
00032
00033 # include <oln/morpher/generic_morpher.hh>
00034
00035
00036 namespace oln {
00037
00038 namespace morpher {
00039
00040 template <class SrcType, class Ftor, class Exact = mlc::final>
00041 struct func_morpher;
00042
00043
00044 }
00045
00046 template <class SrcType, class Ftor, class Exact>
00047 struct image_id<oln::morpher::func_morpher<SrcType, Ftor, Exact> >
00048 {
00049 enum {dim = SrcType::dim};
00051 typedef oln_impl_type(SrcType) impl_type;
00053 typedef oln_value_type(SrcType) value_type;
00055 typedef typename mlc::exact_vt<oln::morpher::func_morpher<SrcType, Ftor, Exact>,
00056 Exact>::ret exact_type;
00057
00058 typedef oln_point_type(SrcType) point_type;
00059 };
00060
00069 template <class SrcType, class Ftor, class Exact>
00070 struct image_traits <oln::morpher::func_morpher<SrcType, Ftor, Exact> > :
00071 public image_traits<oln::morpher::abstract::generic_morpher<SrcType,
00072 typename image_id<oln::morpher::func_morpher<SrcType, Ftor, Exact> >::exact_type> >
00073 {
00074 };
00075
00076 namespace morpher {
00077
00078
00079
00080 template <class SrcType, class Ftor, class Exact>
00081 struct func_morpher:
00082 public abstract::generic_morpher<SrcType,
00083 typename oln::image_id<func_morpher<SrcType, Ftor, Exact> >::exact_type>
00084 {
00085
00086 Ftor f;
00087
00089 typedef typename oln::image_id<func_morpher<SrcType, Ftor, Exact> >::exact_type exact_type;
00090
00092 typedef abstract::generic_morpher<SrcType,
00093 exact_type> super_type;
00094
00096 typedef typename image_id<exact_type>::value_type value_type;
00097 typedef typename image_id<exact_type>::point_type point_type;
00098 typedef typename image_id<exact_type>::impl_type impl_type;
00099
00101 func_morpher(const SrcType &ima, const Ftor f_)
00102 : super_type(ima)
00103 { f = f_;}
00104
00106 func_morpher(const func_morpher<SrcType, Ftor>& r)
00107 : super_type(r.get_ima())
00108 { f = r.f; }
00109
00114 func_morpher() {}
00115
00117 const value_type
00118 at(const point_type& p) const
00119 {
00120 return f(this->ima_, p);
00121 }
00122
00124 const impl_type*
00125 impl() const
00126 {
00127 return this->ima_.impl();
00128 }
00129
00130 static std::string
00131 name()
00132 {
00133 return "subq_morpher<" + SrcType::name() + ">";
00134 }
00135
00136 };
00137 }
00138 }
00139
00140
00141
00142 #endif // !OLENA_MORPHER_FUNC_MORPHER_HH