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

sub_image.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_CORE_IMAGE_DMORPH_SUB_IMAGE_HH
00027 # define MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_HH
00028 
00036 
00037 # include <mln/core/internal/image_domain_morpher.hh>
00038 
00039 
00040 
00041 namespace mln
00042 {
00043 
00044 
00045   // Forward declaration.
00046   template <typename I, typename S> class sub_image;
00047 
00048 
00049   namespace internal
00050   {
00051 
00053     template <typename I, typename S>
00054     struct data< sub_image<I,S> >
00055     {
00056       data(const I& ima, const S& pset);
00057 
00058       I ima_;
00059       S domain_;
00060     };
00061 
00062   } // end of namespace mln::internal
00063 
00064 
00065 
00066   namespace trait
00067   {
00068 
00069     template <typename I, typename S>
00070     struct image_< sub_image<I,S> > : default_image_morpher< I,
00071                                                              mln_value(I),
00072                                                              sub_image<I,S> >
00073     {
00074 //     private:
00075 //       typedef mln_trait_image_data(I) I_data_;
00076 //       typedef mlc_equal(I_data_, trait::data::linear) I_data_are_linear_;
00077 //     public:
00078 
00079       typedef trait::image::category::domain_morpher category;
00080 
00081       typedef trait::image::ext_domain::none      ext_domain;  // No extension of domain.
00082       typedef trait::image::ext_value::irrelevant ext_value;
00083       typedef trait::image::ext_io::irrelevant    ext_io;
00084 
00085       typedef trait::image::vw_io::none                    vw_io;
00086       typedef trait::image::vw_set::none                   vw_set;
00087       typedef trait::image::value_alignment::not_aligned   value_alignment;
00088       typedef trait::image::value_storage::disrupted value_storage;
00089       // HOT FIXME: except if S is a Box
00090     };
00091 
00092   } // end of namespace mln::trait
00093 
00094 
00095 
00099   //
00100   template <typename I, typename S>
00101   struct sub_image : public internal::image_domain_morpher< I,
00102                                                             S,
00103                                                             sub_image<I,S> >
00104   {
00106     typedef sub_image< tag::image_<I>, tag::domain_<S> > skeleton;
00107 
00109     sub_image();
00110 
00112     sub_image(const I& ima, const S& pset);
00113 
00115     void init_(const I& ima, const S& pset);
00116 
00118     const S& domain() const;
00119 
00121     operator sub_image<const I, S>() const;
00122   };
00123 
00124 
00125 
00126 
00127 
00128   template <typename I, typename S>
00129   sub_image<const I, S>
00130   operator|(const Image<I>& ima, const Site_Set<S>& pset);
00131 
00132 
00133   template <typename I, typename S>
00134   sub_image<I, S>
00135   operator|(Image<I>& ima, const Site_Set<S>& pset);
00136 
00137 
00138 
00139   template <typename I, typename S, typename J>
00140   void init_(tag::image_t, sub_image<I,S>& target, const J& model);
00141 
00142 
00143 
00144 # ifndef MLN_INCLUDE_ONLY
00145 
00146   // init_
00147 
00148   template <typename I, typename S, typename J>
00149   inline
00150   void init_(tag::image_t, sub_image<I,S>& target, const J& model)
00151   {
00152     I ima;
00153     init_(tag::image, ima, model);
00154     S pset;
00155     init_(tag::domain, pset, model);
00156     target.init_(ima, pset);
00157   }
00158 
00159 
00160   // internal::data< sub_image<I,S> >
00161 
00162   namespace internal
00163   {
00164 
00165     template <typename I, typename S>
00166     inline
00167     data< sub_image<I,S> >::data(const I& ima, const S& pset)
00168       : ima_(ima),
00169         domain_(pset)
00170     {
00171     }
00172 
00173   } // end of namespace mln::internal
00174 
00175 
00176   // sub_image<I,S>
00177 
00178   template <typename I, typename S>
00179   inline
00180   sub_image<I,S>::sub_image()
00181   {
00182   }
00183 
00184   template <typename I, typename S>
00185   inline
00186   sub_image<I,S>::sub_image(const I& ima, const S& pset)
00187   {
00188     init_(ima, pset);
00189   }
00190 
00191   template <typename I, typename S>
00192   inline
00193   void
00194   sub_image<I,S>::init_(const I& ima, const S& pset)
00195   {
00196     mln_precondition(! this->is_valid());
00197     this->data_ = new internal::data< sub_image<I,S> >(ima, pset);
00198   }
00199 
00200   template <typename I, typename S>
00201   inline
00202   const S&
00203   sub_image<I,S>::domain() const
00204   {
00205     return this->data_->domain_;
00206   }
00207 
00208   template <typename I, typename S>
00209   inline
00210   sub_image<I,S>::operator sub_image<const I, S>() const
00211   {
00212     sub_image<const I, S> tmp(this->data_->ima_,
00213                               this->data_->domain_);
00214     return tmp;
00215   }
00216 
00217 
00218   // Operators.
00219 
00220   template <typename I, typename S>
00221   inline
00222   sub_image<const I, S>
00223   operator|(const Image<I>& ima, const Site_Set<S>& pset)
00224   {
00225     sub_image<const I, S> tmp(exact(ima), exact(pset));
00226     return tmp;
00227   }
00228 
00229   template <typename I, typename S>
00230   inline
00231   sub_image<I, S>
00232   operator|(Image<I>& ima, const Site_Set<S>& pset)
00233   {
00234     sub_image<I, S> tmp(exact(ima), exact(pset));
00235     return tmp;
00236   }
00237 
00238 # endif // ! MLN_INCLUDE_ONLY
00239 
00240 } // end of namespace mln
00241 
00242 
00243 #endif // ! MLN_CORE_IMAGE_DMORPH_SUB_IMAGE_HH

Generated on Thu Sep 8 2011 18:32:40 for Milena (Olena) by  doxygen 1.7.1