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

extended.hh

00001 // Copyright (C) 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_EXTENDED_HH
00027 # define MLN_CORE_IMAGE_DMORPH_EXTENDED_HH
00028 
00036 
00037 # include <mln/core/internal/image_domain_morpher.hh>
00038 # include <mln/core/site_set/box.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00044 
00045   // Forward declaration.
00046   template <typename I> class extended;
00047 
00048 
00049   namespace internal
00050   {
00051 
00053     template <typename I>
00054     struct data< extended<I> >
00055     {
00056       data(I& ima, const box<mln_site(I)>& b_);
00057 
00058       I ima_;
00059       box<mln_site(I)> b_;
00060     };
00061 
00062   } // end of namespace mln::internal
00063 
00064 
00065 
00066   namespace trait
00067   {
00068 
00069     template <typename I>
00070     struct image_< extended<I> > : default_image_morpher< I,
00071                                                           mln_value(I),
00072                                                           extended<I> >
00073     {
00074       typedef trait::image::category::domain_morpher category;
00075 
00076       typedef trait::image::ext_domain::none      ext_domain;
00077       typedef trait::image::ext_value::irrelevant ext_value;
00078       typedef trait::image::ext_io::irrelevant    ext_io;
00079 
00080       typedef trait::image::value_storage::disrupted value_storage;
00081     };
00082 
00083   } // end of namespace mln::trait
00084 
00085 
00086 
00090   //
00091   template <typename I>
00092   struct extended : public internal::image_domain_morpher< I,
00093                                                            box<mln_site(I)>,
00094                                                            extended<I> >,
00095                     private mlc_not_equal(mln_trait_image_ext_domain(I),
00096                                           trait::image::ext_domain::none)::check_t
00097   {
00099     typedef mln_value(I) value;
00100 
00102     typedef tag::image_<I> skeleton; // This property is lost!
00103 
00105     extended();
00106 
00108     extended(I& ima, const box<mln_site(I)>& b);
00109 
00111     void init_(I& ima, const box<mln_site(I)>& b);
00112 
00114     const box<mln_site(I)>& domain() const;
00115   };
00116 
00117 
00118 
00119   template <typename I, typename J>
00120   void init_(tag::image_t, extended<I>& target, const J& model);
00121 
00122 
00123   template <typename I, typename B>
00124   extended<const I>
00125   extended_to(const Image<I>& ima, const Box<B>& b);
00126 
00127   template <typename I, typename B>
00128   extended<I>
00129   extended_to(Image<I>& ima, const Box<B>& b);
00130 
00131 
00132 
00133 # ifndef MLN_INCLUDE_ONLY
00134 
00135   // init_
00136 
00137   template <typename I, typename J>
00138   inline
00139   void init_(tag::image_t, extended<I>& target, const J& model)
00140   {
00141     I ima;
00142     init_(tag::image, ima, model);
00143     box<mln_site(I)> b;
00144     init_(tag::bbox, b, model);
00145     target.init_(ima, b);
00146   }
00147 
00148 
00149   // internal::data< extended<I> >
00150 
00151   namespace internal
00152   {
00153 
00154     template <typename I>
00155     inline
00156     data< extended<I> >::data(I& ima, const box<mln_site(I)>& b)
00157       : ima_(ima),
00158         b_(b)
00159     {
00160     }
00161 
00162   } // end of namespace mln::internal
00163 
00164 
00165   // extended<I>
00166 
00167   template <typename I>
00168   inline
00169   extended<I>::extended()
00170   {
00171   }
00172 
00173   template <typename I>
00174   inline
00175   extended<I>::extended(I& ima, const box<mln_site(I)>& b)
00176   {
00177     init_(ima, b);
00178   }
00179 
00180   template <typename I>
00181   inline
00182   void
00183   extended<I>::init_(I& ima, const box<mln_site(I)>& b)
00184   {
00185     mln_precondition(! this->is_valid());
00186     this->data_ = new internal::data< extended<I> >(ima, b);
00187   }
00188 
00189   template <typename I>
00190   inline
00191   const box<mln_site(I)>&
00192   extended<I>::domain() const
00193   {
00194     return this->data_->b_;
00195   }
00196 
00197 
00198   // extended_to
00199 
00200   template <typename I, typename B>
00201   extended<const I>
00202   extended_to(const Image<I>& ima, const Box<B>& b)
00203   {
00204     mlc_not_equal(mln_trait_image_ext_domain(I),
00205                   trait::image::ext_domain::none)::check();
00206     mln_precondition(exact(ima).is_valid());
00207     extended<const I> tmp(exact(ima), exact(b));
00208     return tmp;
00209   }
00210 
00211   template <typename I, typename B>
00212   extended<I>
00213   extended_to(Image<I>& ima, const Box<B>& b)
00214   {
00215     mlc_not_equal(mln_trait_image_ext_domain(I),
00216                   trait::image::ext_domain::none)::check();
00217     mln_precondition(exact(ima).is_valid());
00218     extended<I> tmp(exact(ima), exact(b));
00219     return tmp;
00220   }
00221 
00222 # endif // ! MLN_INCLUDE_ONLY
00223 
00224 } // end of namespace mln
00225 
00226 
00227 #endif // ! MLN_CORE_IMAGE_DMORPH_EXTENDED_HH

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