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

function.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_CONCEPT_FUNCTION_HH
00027 # define MLN_CORE_CONCEPT_FUNCTION_HH
00028 
00032 
00033 # include <mln/core/concept/object.hh>
00034 
00035 
00036 namespace mln
00037 {
00038 
00039   // Forward declarations.
00040   template <typename E> struct Function;
00041   template <typename E> struct Function_n2v;
00042   template <typename E> struct Function_v2v;
00043   template <typename E> struct Function_v2b;
00044   template <typename E> struct Function_vv2v;
00045   template <typename E> struct Function_vv2b;
00046 
00047 
00049   template <>
00050   struct Function<void>
00051   {
00052     typedef Object<void> super;
00053   };
00054 
00055 
00061   //
00062   template <typename E>
00063   struct Function : public Object<E>
00064   {
00065     typedef Function<void> category;
00066 
00069 
00070   protected:
00071     Function();
00072     Function(const Function&);
00073   };
00074 
00075 
00076   /*---------------.
00077   | Nil -> Value.  |
00078   `---------------*/
00079 
00080   template <>
00081   struct Function_n2v<void> { typedef Function<void> super; };
00082 
00083 
00090   //
00091   template <typename E>
00092   struct Function_n2v : public Function<E>
00093   {
00094     typedef Function_n2v<void> category;
00095   protected:
00096     Function_n2v();
00097     Function_n2v(const Function_n2v&);
00098   };
00099 
00100 
00101   /*-----------------.
00102   | Value -> Value.  |
00103   `-----------------*/
00104 
00105   template <>
00106   struct Function_v2v<void> { typedef Function<void> super; };
00107 
00108 
00115   //
00116   template <typename E>
00117   struct Function_v2v : public Function<E>
00118   {
00119     typedef Function_v2v<void> category;
00120     typedef void mutable_result; // Meaning: no mutable result by default.
00121   protected:
00122     Function_v2v();
00123     Function_v2v(const Function_v2v&);
00124   };
00125 
00126 
00127   /*----------------.
00128   | Value -> bool.  |
00129   `----------------*/
00130 
00131   template <>
00132   struct Function_v2b<void> { typedef Function_v2v<void> super; };
00133 
00134 
00141   //
00142   template <typename E>
00143   struct Function_v2b : public virtual Function_v2v<E>
00144   {
00145     typedef Function_v2b<void> category;
00146     typedef bool result;
00147   protected:
00148     Function_v2b();
00149     Function_v2b(const Function_v2b&);
00150   };
00151 
00152 
00153 
00154   /*--------------------------.
00155   | (Value, Value) -> Value.  |
00156   `--------------------------*/
00157 
00158   template <>
00159   struct Function_vv2v<void> { typedef Function<void> super; };
00160 
00161 
00168   //
00169   template <typename E>
00170   struct Function_vv2v : public Function<E>
00171   {
00172     typedef Function_vv2v<void> category;
00173   protected:
00174     Function_vv2v();
00175     Function_vv2v(const Function_vv2v&);
00176   };
00177 
00178 
00179   /*--------------------------.
00180   | (Value, Value) -> Boolean.|
00181   `--------------------------*/
00182 
00183   template <>
00184   struct Function_vv2b<void> { typedef Function<void> super; };
00185 
00186 
00193   //
00194   template <typename E>
00195   struct Function_vv2b : public Function<E>
00196   {
00197     typedef bool result;
00198     typedef Function_vv2b<void> category;
00199   protected:
00200     Function_vv2b();
00201     Function_vv2b(const Function_vv2b&);
00202   };
00203 
00204 
00205 
00206 # ifndef MLN_INCLUDE_ONLY
00207 
00208   // Function.
00209 
00210   template <typename E>
00211   inline
00212   Function<E>::Function()
00213   {
00214     typedef mln_result(E) result;
00215   }
00216 
00217   template <typename E>
00218   inline
00219   Function<E>::Function(const Function<E>& rhs)
00220     : Object<E>(rhs)
00221   {
00222   }
00223 
00224 
00225   // Function_n2v.
00226 
00227   template <typename E>
00228   inline
00229   Function_n2v<E>::Function_n2v()
00230   {
00231   }
00232 
00233   template <typename E>
00234   inline
00235   Function_n2v<E>::Function_n2v(const Function_n2v<E>& rhs)
00236     : Function<E>(rhs)
00237   {
00238   }
00239 
00240 
00241   // Function_v2v.
00242 
00243   template <typename E>
00244   inline
00245   Function_v2v<E>::Function_v2v()
00246   {
00247   }
00248 
00249   template <typename E>
00250   inline
00251   Function_v2v<E>::Function_v2v(const Function_v2v<E>& rhs)
00252     : Function<E>(rhs)
00253   {
00254   }
00255 
00256   // Function_v2b.
00257 
00258   template <typename E>
00259   inline
00260   Function_v2b<E>::Function_v2b()
00261   {
00262   }
00263 
00264   template <typename E>
00265   inline
00266   Function_v2b<E>::Function_v2b(const Function_v2b<E>& rhs)
00267     : Function_v2v<E>(rhs)
00268   {
00269   }
00270 
00271   // Function_vv2v.
00272 
00273   template <typename E>
00274   inline
00275   Function_vv2v<E>::Function_vv2v()
00276   {
00277   }
00278 
00279   template <typename E>
00280   inline
00281   Function_vv2v<E>::Function_vv2v(const Function_vv2v<E>& rhs)
00282     : Function<E>(rhs)
00283   {
00284   }
00285 
00286   // Function_vv2b.
00287 
00288   template <typename E>
00289   inline
00290   Function_vv2b<E>::Function_vv2b()
00291   {
00292   }
00293 
00294   template <typename E>
00295   inline
00296   Function_vv2b<E>::Function_vv2b(const Function_vv2b<E>& rhs)
00297     : Function<E>(rhs)
00298   {
00299   }
00300 
00301 # endif // ! MLN_INCLUDE_ONLY
00302 
00303 } // end of namespace mln
00304 
00305 
00306 #endif // ! MLN_CORE_CONCEPT_FUNCTION_HH

Generated on Fri Oct 19 2012 04:15:48 for Milena (Olena) by  doxygen 1.7.1