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

c.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_FUN_C_HH
00027 # define MLN_FUN_C_HH
00028 
00036 
00037 # include <mln/fun/internal/selector.hh>
00038 # include <mln/metal/unqualif.hh>
00039 
00040 
00041 namespace mln
00042 {
00043 
00045   template <typename E>
00046   struct C_Function;
00047 
00048 
00050   template <typename R, typename A>
00051   struct category< R (*)(A) >
00052   {
00053     typedef C_Function<void> ret;
00054   };
00055 
00056 
00057 
00058   // Forward declaration.
00059   namespace fun { template <typename F> struct C; }
00060 
00061 
00062 
00063   namespace trait
00064   {
00065 
00066     template <template <class> class Op,
00067               typename R, typename A>
00068     struct set_unary_< Op, C_Function, R (*)(A) >
00069     {
00070       typedef Op< fun::C<R (*)(A)> > Op_;
00071       typedef typename Op_::ret ret;
00072     };
00073 
00074     template <template <class, class> class Op,
00075               typename O,
00076               typename R, typename A>
00077     struct set_binary_< Op,
00078                         Object,      O,
00079                         C_Function,  R (*)(A) >
00080     {
00081       typedef Op< O, fun::C<R (*)(A)> > Op_;
00082       typedef typename Op_::ret ret;
00083     };
00084 
00085   } // end of namespace trait
00086 
00087 
00088 
00089   namespace fun
00090   {
00091 
00092     template <typename F> struct C;
00093 
00094 
00095     // FIXME: Doc!
00096     template <typename R, typename A>
00097     struct C< R (*)(A) >
00098       :
00099       fun::internal::selector_< R, A, C<R(*)(A)> >::ret
00100     {
00101       C();
00102       C(R (*f)(A));
00103       typedef R result;
00104       R operator()(const mlc_unqualif(A)& a) const;
00105     protected:
00106       R (*f_)(A);
00107     };
00108 
00109 
00110 # ifndef MLN_INCLUDE_ONLY
00111 
00112     template <typename R, typename A>
00113     inline
00114     C<R(*)(A)>::C()
00115     {
00116     }
00117 
00118     template <typename R, typename A>
00119     inline
00120     C<R(*)(A)>::C(R (*f)(A))
00121       : f_(f)
00122     {
00123     }
00124 
00125     template <typename R, typename A>
00126     inline
00127     R
00128     C<R(*)(A)>::operator()(const mlc_unqualif(A)& a) const
00129     {
00130       return f_(a);
00131     }
00132 
00133 # endif // ! MLN_INCLUDE_ONLY
00134 
00135   } // end of namespace mln::fun
00136 
00137 } // end of namespace mln
00138 
00139 
00140 #endif // ! MLN_FUN_C_HH

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