Milena (Olena)  User documentation 2.0a Id
ch_piter.hh
00001 // Copyright (C) 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_CORE_IMAGE_CH_PITER_HH
00028 # define MLN_CORE_IMAGE_CH_PITER_HH
00029 
00036 # include <mln/core/internal/image_identity.hh>
00037 
00038 
00039 
00040 namespace mln
00041 {
00042 
00043   // Forward declaration.
00044   template <typename I, typename Fwd> class ch_piter_image;
00045 
00046 
00047   namespace internal
00048   {
00049 
00051     template <typename I, typename Fwd>
00052     struct data< ch_piter_image<I,Fwd> >
00053     {
00054       data(I& ima);
00055       I ima_;
00056     };
00057 
00058   } // end of namespace mln::internal
00059 
00060 
00061   namespace trait
00062   {
00063 
00064     template <typename I, typename Fwd>
00065     struct image_< ch_piter_image<I,Fwd> > : image_< I > // Same as I except...
00066     {
00067       // ...theis change.
00068       typedef trait::image::category::identity_morpher category;
00069     };
00070 
00071   } // end of namespace mln::trait
00072 
00073 
00074 
00075   // FIXME: Doc!
00076 
00077   template <typename I, typename Fwd>
00078   class ch_piter_image : public internal::image_identity< I,
00079                                                           mln_domain(I),
00080                                                           ch_piter_image<I,Fwd> >
00081   {
00082   public:
00083 
00085     typedef ch_piter_image< tag::image_<I>, Fwd > skeleton;
00086 
00087     typedef Fwd fwd_piter;
00088     typedef Fwd bkd_piter; // FIXME
00089     typedef fwd_piter piter;
00090 
00091     ch_piter_image();
00092     ch_piter_image(I& ima);
00093 
00094     // Deferred initialization.
00095     void init_(I& ima);
00096   };
00097 
00098 
00099 
00100   template <typename Fwd, typename I>
00101   ch_piter_image<I,Fwd>
00102   ch_piter(Image<I>& ima);
00103 
00104 
00105 
00106 # ifndef MLN_INCLUDE_ONLY
00107 
00108 
00109   // internal::data< ch_piter_image<I,S> >
00110 
00111   namespace internal
00112   {
00113 
00114     template <typename I, typename Fwd>
00115     inline
00116     data< ch_piter_image<I,Fwd> >::data(I& ima)
00117       : ima_(ima)
00118     {
00119     }
00120 
00121   } // end of namespace mln::internal
00122 
00123 
00124   // ch_piter_image<I,Fwd>
00125 
00126   template <typename I, typename Fwd>
00127   inline
00128   ch_piter_image<I,Fwd>::ch_piter_image()
00129   {
00130   }
00131 
00132   template <typename I, typename Fwd>
00133   inline
00134   ch_piter_image<I,Fwd>::ch_piter_image(I& ima)
00135   {
00136     mln_precondition(ima.is_valid());
00137     init_(ima);
00138   }
00139 
00140   template <typename I, typename Fwd>
00141   inline
00142   void
00143   ch_piter_image<I,Fwd>::init_(I& ima)
00144   {
00145     mln_precondition(ima.is_valid());
00146     this->data_ = new internal::data< ch_piter_image<I,Fwd> >(ima);
00147   }
00148 
00149 
00150   // ch_piter
00151 
00152   template <typename Fwd, typename I>
00153   inline
00154   ch_piter_image<I,Fwd>
00155   ch_piter(Image<I>& ima)
00156   {
00157     ch_piter_image<I,Fwd> tmp(exact(ima));
00158     return tmp;
00159   }
00160 
00161 # endif // ! MLN_INCLUDE_ONLY
00162 
00163 } // end of namespace mln
00164 
00165 
00166 #endif // ! MLN_CORE_IMAGE_CH_PITER_HH
 All Classes Namespaces Functions Variables Typedefs Enumerator