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

plain.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_IMORPH_PLAIN_HH
00027 # define MLN_CORE_IMAGE_IMORPH_PLAIN_HH
00028 
00033 
00034 # include <mln/core/internal/image_identity.hh>
00035 # include <mln/core/routine/duplicate.hh>
00036 # include <mln/metal/is_not_const.hh>
00037 
00038 
00039 namespace mln
00040 {
00041 
00042   // Forward declaration.
00043   template <typename I> struct plain;
00044 
00045 
00046   namespace internal
00047   {
00048 
00050     template <typename I>
00051     struct data< plain<I> >
00052     {
00053       data(const I& ima);
00054       I ima_;
00055     };
00056 
00057   } // end of namespace mln::internal
00058 
00059 
00060   namespace trait
00061   {
00062 
00063     template <typename I>
00064     struct image_< plain<I> > : image_< I > // Same as I except...
00065     {
00066       // ...these changes:
00067       typedef trait::image::category::identity_morpher category;
00068       typedef mln_internal_trait_image_speed_from(I) speed; // Un-fastest.
00069     };
00070 
00071   } // end of namespace mln::trait
00072 
00073 
00074 
00080   //
00081   template <typename I>
00082   class plain
00083 
00084     : public mln::internal::image_identity< I, mln_domain(I), plain<I> >,
00085       private mlc_is_not_const(I)::check_t
00086   {
00087     typedef plain<I> self_;
00088     typedef mln::internal::image_identity<I, mln_domain(I), self_> super_;
00089 
00090   public:
00091 
00093     typedef plain< tag::image_<I> > skeleton;
00094 
00096     plain();
00097 
00099     plain(const plain<I>& rhs);
00100 
00102     plain(const I& ima);
00103 
00105     void init_(const I& ima);
00106 
00108     plain<I>& operator=(const plain<I>& rhs);
00109 
00111     plain<I>& operator=(const I& ima);
00112 
00114     operator I () const;
00115   };
00116 
00117 
00118 
00119 # ifndef MLN_INCLUDE_ONLY
00120 
00121 
00122   // internal::data< plain<I> >
00123 
00124   namespace internal
00125   {
00126 
00127     template <typename I>
00128     inline
00129     data< plain<I> >::data(const I& ima)
00130       : ima_(duplicate(ima))
00131     {
00132     }
00133 
00134   } // end of namespace mln::internal
00135 
00136 
00137   // plain<I>
00138 
00139   template <typename I>
00140   inline
00141   plain<I>::plain()
00142   {
00143   }
00144 
00145   template <typename I>
00146   inline
00147   plain<I>::plain(const plain<I>& rhs)
00148     : super_()
00149   {
00150     mln_precondition(rhs.is_valid());
00151     init_(rhs.data_->ima_);
00152   }
00153 
00154   template <typename I>
00155   inline
00156   plain<I>::plain(const I& ima)
00157   {
00158     mln_precondition(ima.is_valid());
00159     init_(ima);
00160   }
00161 
00162   template <typename I>
00163   inline
00164   void
00165   plain<I>::init_(const I& ima)
00166   {
00167     mln_precondition(ima.is_valid());
00168     this->data_ = new internal::data< plain<I> >(ima);
00169   }
00170 
00171   template <typename I>
00172   inline
00173   plain<I>&
00174   plain<I>::operator=(const plain<I>& rhs)
00175   {
00176     mln_precondition(rhs.is_valid());
00177     if (&rhs == this)
00178       return *this;
00179     this->destroy();
00180     init_(rhs.data_->ima_);
00181     return *this;
00182   }
00183 
00184   template <typename I>
00185   inline
00186   plain<I>&
00187   plain<I>::operator=(const I& ima)
00188   {
00189     mln_precondition(ima.is_valid());
00190     this->destroy();
00191     init_(ima);
00192     return *this;
00193   }
00194 
00195   template <typename I>
00196   inline
00197   plain<I>::operator I () const
00198   {
00199     mln_precondition(this->is_valid());
00200     return duplicate(this->data_->ima_);
00201   }
00202 
00203 # endif // ! MLN_INCLUDE_ONLY
00204 
00205 } // end of namespace mln
00206 
00207 
00208 #endif // ! MLN_CORE_IMAGE_IMORPH_PLAIN_HH

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