• Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List

images.hh

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

Generated on Tue Oct 4 2011 15:23:58 for Milena (Olena) by  doxygen 1.7.1