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

v.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_ACCU_V_HH
00027 # define MLN_ACCU_V_HH
00028 
00032 
00033 
00034 # include <mln/core/concept/meta_accumulator.hh>
00035 # include <mln/accu/internal/base.hh>
00036 # include <mln/metal/is_a.hh>
00037 # include <mln/util/pix.hh>
00038 
00039 
00040 namespace mln
00041 {
00042 
00043   namespace accu
00044   {
00045 
00046 
00047 
00049     template <typename A>
00050     struct val : public mln::accu::internal::base< const mln_result(A)& , val<A> >
00051     {
00052       typedef mln_argument(A)  argument;
00053 
00054       val();
00055       val(const A& a);
00056 
00059       void init();
00060       void take_as_init_(const argument& t);
00061       void take(const argument& t);
00062       void take(const val<A>& other);
00063       template <typename I>
00064       void take_as_init_(const util::pix<I>& pix);
00065       template <typename I>
00066       void take(const util::pix<I>& pix);
00068 
00070       const mln_result(A)& to_result() const;
00071 
00074       bool is_valid() const;
00075 
00076     protected:
00077       A a_;
00078     };
00079 
00080 
00081     namespace meta
00082     {
00083 
00085 
00086       template <typename mA>
00087       struct val : public Meta_Accumulator< val<mA> >
00088       {
00089         template <typename V>
00090         struct with
00091         {
00092           typedef mln_accu_with(mA, mln_value(V)) A;
00093           typedef val<A> ret;
00094         };
00095       };
00096 
00097     }
00098 
00099 # ifndef MLN_INCLUDE_ONLY
00100 
00101     template <typename A>
00102     inline
00103     val<A>::val()
00104     {
00105       init();
00106     }
00107 
00108     template <typename A>
00109     inline
00110     val<A>::val(const A& a)
00111       : a_(a)
00112     {
00113       init();
00114     }
00115 
00116     template <typename A>
00117     inline
00118     void
00119     val<A>::init()
00120     {
00121       a_.init();
00122     }
00123 
00124     template <typename A>
00125     inline
00126     void
00127     val<A>::take_as_init_(const argument& t)
00128     {
00129       a_.take_as_init_(t);
00130     }
00131 
00132     template <typename A>
00133     inline
00134     void
00135     val<A>::take(const argument& t)
00136     {
00137       a_.take(t);
00138     }
00139 
00140     template <typename A>
00141     inline
00142     void
00143     val<A>::take(const val<A>& other)
00144     {
00145       a_.take(other.a_);
00146     }
00147 
00148     template <typename A>
00149     template <typename I>
00150     inline
00151     void
00152     val<A>::take_as_init_(const util::pix<I>& pix)
00153     {
00154       a_.take_as_init_(pix.v()); // FIXME: Generalize with "value(pix)".
00155     }
00156 
00157     template <typename A>
00158     template <typename I>
00159     inline
00160     void
00161     val<A>::take(const util::pix<I>& pix)
00162     {
00163       a_.take(pix.v());
00164     }
00165 
00166     template <typename A>
00167     inline
00168     const mln_result(A)&
00169     val<A>::to_result() const
00170     {
00171       return a_.to_result();
00172     }
00173 
00174     template <typename A>
00175     inline
00176     bool
00177     val<A>::is_valid() const
00178     {
00179       return a_.is_valid();
00180     }
00181 
00182 
00183 # endif // ! MLN_INCLUDE_ONLY
00184 
00185   } // end of namespace mln::accu
00186 
00187 } // end of namespace mln
00188 
00189 
00190 #endif // ! MLN_ACCU_V_HH

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