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

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_PW_IMAGE_HH
00027 # define MLN_PW_IMAGE_HH
00028 
00032 
00033 # include <mln/pw/internal/image_base.hh>
00034 # include <mln/core/concept/function.hh>
00035 # include <mln/value/set.hh>
00036 
00037 
00038 namespace mln
00039 {
00040 
00041   // Forward declaration.
00042   namespace pw { template <typename F, typename S> class image; }
00043 
00044 
00045   // Properties
00046 
00047   namespace trait
00048   {
00049 
00050     template <typename F, typename S>
00051     struct image_< pw::image<F,S> >
00052       : pw_image_<F,S, pw::image<F,S> >
00053     {
00054     };
00055 
00056   } // end of namespace mln::traits.
00057 
00058 
00059   namespace internal
00060   {
00061 
00063     template <typename F, typename S>
00064     struct data< mln::pw::image<F,S> >
00065     {
00066       data(const F& f, const S& ps);
00067       F f_;
00068       S domain_;
00069     };
00070 
00071   } // end of namespace mln::internal
00072 
00073 
00076   template <typename F, typename S>
00077   pw::image<F,S>
00078   operator | (const Function_v2v<F>& f, const Site_Set<S>& ps);
00079 
00080 
00081   namespace pw
00082   {
00083 
00090     //
00091     template <typename F, typename S>
00092     class image :
00093       public pw::internal::image_base< F, S, image<F,S> >
00094     {
00095       typedef pw::internal::image_base< F, S, image<F,S> > super_;
00096 
00097     public:
00099       typedef image< tag::function_<F>, tag::domain_<S> > skeleton;
00100 
00102       image();
00103 
00105       image(const Function_v2v<F>& f, const Site_Set<S>& ps);
00106 
00107     };
00108 
00109   } // end of namespace mln::pw
00110 
00111 
00113 
00114   template <typename F, typename S, typename E, typename J>
00115   void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model);
00116 
00117 
00118 # ifndef MLN_INCLUDE_ONLY
00119 
00121 
00122   template <typename F, typename S, typename E, typename J>
00123   void init_(tag::image_t, pw::image<F,S>& target, const Image<J>& model)
00124   {
00125     F f;
00126     init_(tag::function, f, exact(model));
00127     S s;
00128     init_(tag::domain, s, exact(model));
00129     target.init_(f, s);
00130   }
00131 
00132 
00133   // Operator.
00134 
00135   template <typename F, typename S>
00136   inline
00137   pw::image<F,S>
00138   operator | (const Function_v2v<F>& f, const Site_Set<S>& ps)
00139   {
00140     pw::image<F,S> tmp(f, ps);
00141     return tmp;
00142   }
00143 
00144 
00145   // data< pw::image >
00146 
00147   namespace internal
00148   {
00149 
00150     template <typename F, typename S>
00151     inline
00152     data< mln::pw::image<F,S> >::data(const F& f, const S& ps)
00153       : f_(f),
00154       domain_(ps)
00155     {
00156     }
00157 
00158   } // end of namespace mln::internal
00159 
00160 
00161 
00162   // pw::image<F,S>
00163 
00164   namespace pw
00165   {
00166 
00167     template <typename F, typename S>
00168     inline
00169     image<F,S>::image()
00170     {
00171     }
00172 
00173     template <typename F, typename S>
00174     inline
00175     image<F,S>::image(const Function_v2v<F>& f, const Site_Set<S>& ps)
00176     {
00177       this->data_ = new mln::internal::data< image<F,S> >(exact(f), exact(ps));
00178     }
00179 
00180 
00181   } // end of namespace mln::pw
00182 
00183 # endif // ! MLN_INCLUDE_ONLY
00184 
00185 } // end of namespace mln
00186 
00187 
00188 #endif // ! MLN_PW_IMAGE_HH

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