Milena (Olena)
User documentation 2.0a Id
|
00001 // Copyright (C) 2007, 2008, 2009, 2011 EPITA Research and Development 00002 // Laboratory (LRDE) 00003 // 00004 // This file is part of Olena. 00005 // 00006 // Olena is free software: you can redistribute it and/or modify it under 00007 // the terms of the GNU General Public License as published by the Free 00008 // Software Foundation, version 2 of the License. 00009 // 00010 // Olena is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with Olena. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 // As a special exception, you may use this file as part of a free 00019 // software project without restriction. Specifically, if other files 00020 // instantiate templates or use macros or inline functions from this 00021 // file, or you compile this file and link it with other files to produce 00022 // an executable, this file does not by itself cause the resulting 00023 // executable to be covered by the GNU General Public License. This 00024 // exception does not however invalidate any other reasons why the 00025 // executable file might be covered by the GNU General Public License. 00026 00027 #ifndef MLN_TRAIT_IMAGES_HH 00028 # define MLN_TRAIT_IMAGES_HH 00029 00039 00040 # include <iostream> 00041 # include <string> 00042 00043 # include <mln/trait/undef.hh> 00044 # include <mln/trait/image/props.hh> 00045 # include <mln/trait/value_.hh> 00046 00047 # include <mln/metal/bexpr.hh> 00048 # include <mln/metal/equal.hh> 00049 # include <mln/metal/if.hh> 00050 # include <mln/metal/is_const.hh> 00051 00052 00053 00054 # define mln_trait_image_category(I) typename mln::trait::image_< I >::category 00055 # define mln_trait_image_speed(I) typename mln::trait::image_< I >::speed 00056 # define mln_trait_image_size(I) typename mln::trait::image_< I >::size 00057 00058 # define mln_trait_image_value_access(I) typename mln::trait::image_< I >::value_access 00059 # define mln_trait_image_value_storage(I) typename mln::trait::image_< I >::value_storage 00060 # define mln_trait_image_value_browsing(I) typename mln::trait::image_< I >::value_browsing 00061 # define mln_trait_image_value_io(I) typename mln::trait::image_< I >::value_io 00062 # define mln_trait_image_pw_io(I) typename mln::trait::image_< I >::pw_io 00063 # define mln_trait_image_vw_io(I) typename mln::trait::image_< I >::vw_io 00064 # define mln_trait_image_vw_set(I) typename mln::trait::image_< I >::vw_set 00065 # define mln_trait_image_value_alignment(I) typename mln::trait::image_< I>::value_alignment 00066 00067 # define mln_trait_image_localization(I) typename mln::trait::image_< I >::localization 00068 # define mln_trait_image_dimension(I) typename mln::trait::image_< I >::dimension 00069 00070 # define mln_trait_image_ext_domain(I) typename mln::trait::image_< I >::ext_domain 00071 # define mln_trait_image_ext_value(I) typename mln::trait::image_< I >::ext_value 00072 # define mln_trait_image_ext_io(I) typename mln::trait::image_< I >::ext_io 00073 00074 # define mln_trait_image_kind(I) typename mln::trait::image_< I >::kind 00075 # define mln_trait_image_nature(I) typename mln::trait::image_< I >::nature 00076 # define mln_trait_image_quant(I) typename mln::trait::image_< I >::quant 00077 00078 00079 // For value_io: I const => read_only, otherwise like I 00080 00081 # define mln_internal_trait_image_value_io_from(I) \ 00082 \ 00083 mlc_if( mlc_is_const(I), \ 00084 mln::trait::image::value_io::read_only, \ 00085 mln_trait_image_value_io(I) ) 00086 00087 # define mln_internal_trait_image_pw_io_from(I) \ 00088 \ 00089 mlc_if( mlc_is_const(I), \ 00090 mln::trait::image::pw_io::read, \ 00091 mln_trait_image_pw_io(I) ) 00092 00093 00094 # define mln_internal_trait_image_vw_io_from(I) \ 00095 \ 00096 mlc_if( mlc_is_const(I), \ 00097 mln::trait::image::vw_io::read, \ 00098 mln_trait_image_vw_io(I) ) 00099 00100 00101 # define mln_internal_trait_image_speed_from(I) \ 00102 \ 00103 mlc_if( mlc_equal( mln_trait_image_speed(I), mln::trait::image::speed::fastest ), \ 00104 mln::trait::image::speed::fast, \ 00105 mln_trait_image_speed(I) ) 00106 00107 00108 00109 namespace mln 00110 { 00111 00112 // Primitive types. 00113 template <typename T> struct image1d; 00114 template <typename T> class image2d; 00115 template <typename T> struct image3d; 00116 namespace pw { template <typename F, typename S> class image; } 00117 00118 // Morphers. 00119 template <typename I, typename F> struct image_if_base; 00120 template <typename I, typename D> struct decorated_image; 00121 template <typename I, typename S> class sub_image; 00122 template <typename I> class safe_image; 00123 template <typename T, typename I> struct cast_image_; 00124 namespace value { template <unsigned n, typename I> struct stack_image; } 00125 00126 00127 namespace trait 00128 { 00129 00130 template <typename I> 00131 struct undefined_image_ 00132 { 00133 // misc 00134 typedef undef category; 00135 typedef undef speed; 00136 typedef undef size; 00137 00138 // value 00139 typedef undef vw_io; 00140 typedef undef vw_set; 00141 typedef undef value_alignment; 00142 typedef undef value_access; 00143 typedef undef value_storage; 00144 typedef undef value_browsing; 00145 typedef undef value_io; 00146 00147 // site 00148 typedef undef pw_io; 00149 typedef undef localization; 00150 typedef undef dimension; 00151 00152 // extended domain 00153 typedef undef ext_domain; 00154 typedef undef ext_value; 00155 typedef undef ext_io; 00156 00157 // data (I::value) 00158 typedef undef kind; 00159 typedef undef nature; 00160 typedef undef quant; 00161 }; 00162 00163 00164 template <typename I> 00165 struct image_ : undefined_image_<I> 00166 { 00167 }; 00168 00169 00170 template <typename I> 00171 struct image_<const I> : image_<I> 00172 { 00173 // FIXME: TODO: io cannot contain "write"... 00174 }; 00175 00176 00177 template <typename T, typename I> 00178 struct default_image_ : undefined_image_<I> 00179 { 00180 private: 00181 typedef mlc_equal(mln_trait_value_quant(T), 00182 trait::value::quant::high) is_high_quant_; 00183 public: 00184 typedef mln_trait_value_kind(T) kind; 00185 typedef mlc_if( is_high_quant_, 00186 trait::image::quant::high, 00187 trait::image::quant::low ) quant; 00188 // FIXME: typedef undef value; // scalar, vectorial, structed 00189 00190 // speed is fast by default (neither "fastest" nor "slow") 00191 typedef trait::image::speed::fast speed; 00192 }; 00193 00194 00195 template <typename D, typename T, typename I> 00196 struct default_image_morpher : default_image_<T, I> 00197 { 00198 // misc => delegation except for 'category' 00199 typedef typename image_<D>::size size; 00200 typedef mln_internal_trait_image_speed_from(D) speed; // un-fastest 00201 00202 // Image geometry 00203 typedef typename image_<D>::localization localization; 00204 typedef typename image_<D>::dimension dimension; 00205 00206 // Memory organization 00207 typedef typename image_<D>::value_alignment value_alignment; 00208 typedef typename image_<D>::value_access value_access; 00209 typedef typename image_<D>::value_storage value_storage; 00210 typedef typename image_<D>::value_browsing value_browsing; 00211 // un-write when D is const 00212 typedef mln_internal_trait_image_value_io_from(D) value_io; 00213 00214 // value wise access => delegation 00215 typedef mln_internal_trait_image_vw_io_from(D) vw_io; 00216 typedef typename image_<D>::vw_set vw_set; 00217 00218 00219 // site wise access => delegation 00220 typedef mln_internal_trait_image_pw_io_from(D) pw_io; 00221 00222 // extended domain => delegation 00223 typedef typename image_<D>::ext_domain ext_domain; 00224 typedef typename image_<D>::ext_value ext_value; 00225 typedef typename image_<D>::ext_io ext_io; 00226 00227 // data (I::value) => delegation 00228 typedef typename image_<D>::nature nature; 00229 typedef typename image_<D>::kind kind; 00230 typedef typename image_<D>::quant quant; 00231 }; 00232 00233 00234 } // end of namespace mln::trait 00235 00236 } // end of namespace mln 00237 00238 00239 # include <mln/trait/image/print.hh> 00240 00241 00242 #endif // ! MLN_TRAIT_IMAGES_HH