• 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_v2v;
00042   template <typename E> struct Function_v2b;
00043   template <typename E> struct Function_vv2v;
00044   template <typename E> struct Function_vv2b;
00045 
00046 
00048   template <>
00049   struct Function<void>
00050   {
00051     typedef Object<void> super;
00052   };
00053 
00054 
00060   //
00061   template <typename E>
00062   struct Function : public Object<E>
00063   {
00064     typedef Function<void> category;
00065 
00068 
00069   protected:
00070     Function();
00071     Function(const Function&);
00072   };
00073 
00074 
00075   /*-----------------.
00076   | Value -> Value.  |
00077   `-----------------*/
00078 
00079   template <>
00080   struct Function_v2v<void> { typedef Function<void> super; };
00081 
00082 
00089   //
00090   template <typename E>
00091   struct Function_v2v : public Function<E>
00092   {
00093     typedef Function_v2v<void> category;
00094     typedef void mutable_result; // Meaning: no mutable result by default.
00095   protected:
00096     Function_v2v();
00097     Function_v2v(const Function_v2v&);
00098   };
00099 
00100 
00101   /*----------------.
00102   | Value -> bool.  |
00103   `----------------*/
00104 
00105   template <>
00106   struct Function_v2b<void> { typedef Function_v2v<void> super; };
00107 
00108 
00115   //
00116   template <typename E>
00117   struct Function_v2b : public virtual Function_v2v<E>
00118   {
00119     typedef Function_v2b<void> category;
00120     typedef bool result;
00121   protected:
00122     Function_v2b();
00123     Function_v2b(const Function_v2b&);
00124   };
00125 
00126 
00127 
00128   /*--------------------------.
00129   | (Value, Value) -> Value.  |
00130   `--------------------------*/
00131 
00132   template <>
00133   struct Function_vv2v<void> { typedef Function<void> super; };
00134 
00135 
00142   //
00143   template <typename E>
00144   struct Function_vv2v : public Function<E>
00145   {
00146     typedef Function_vv2v<void> category;
00147   protected:
00148     Function_vv2v();
00149     Function_vv2v(const Function_vv2v&);
00150   };
00151 
00152 
00153   /*--------------------------.
00154   | (Value, Value) -> Boolean.|
00155   `--------------------------*/
00156 
00157   template <>
00158   struct Function_vv2b<void> { typedef Function<void> super; };
00159 
00160 
00167   //
00168   template <typename E>
00169   struct Function_vv2b : public Function<E>
00170   {
00171     typedef bool result;
00172     typedef Function_vv2b<void> category;
00173   protected:
00174     Function_vv2b();
00175     Function_vv2b(const Function_vv2b&);
00176   };
00177 
00178 
00179 
00180 # ifndef MLN_INCLUDE_ONLY
00181 
00182   // Function.
00183 
00184   template <typename E>
00185   inline
00186   Function<E>::Function()
00187   {
00188     typedef mln_result(E) result;
00189   }
00190 
00191   template <typename E>
00192   inline
00193   Function<E>::Function(const Function<E>& rhs)
00194     : Object<E>(rhs)
00195   {
00196   }
00197 
00198   // Function_v2v.
00199 
00200   template <typename E>
00201   inline
00202   Function_v2v<E>::Function_v2v()
00203   {
00204   }
00205 
00206   template <typename E>
00207   inline
00208   Function_v2v<E>::Function_v2v(const Function_v2v<E>& rhs)
00209     : Function<E>(rhs)
00210   {
00211   }
00212 
00213   // Function_v2b.
00214 
00215   template <typename E>
00216   inline
00217   Function_v2b<E>::Function_v2b()
00218   {
00219   }
00220 
00221   template <typename E>
00222   inline
00223   Function_v2b<E>::Function_v2b(const Function_v2b<E>& rhs)
00224     : Function_v2v<E>(rhs)
00225   {
00226   }
00227 
00228   // Function_vv2v.
00229 
00230   template <typename E>
00231   inline
00232   Function_vv2v<E>::Function_vv2v()
00233   {
00234   }
00235 
00236   template <typename E>
00237   inline
00238   Function_vv2v<E>::Function_vv2v(const Function_vv2v<E>& rhs)
00239     : Function<E>(rhs)
00240   {
00241   }
00242 
00243   // Function_vv2b.
00244 
00245   template <typename E>
00246   inline
00247   Function_vv2b<E>::Function_vv2b()
00248   {
00249   }
00250 
00251   template <typename E>
00252   inline
00253   Function_vv2b<E>::Function_vv2b(const Function_vv2b<E>& rhs)
00254     : Function<E>(rhs)
00255   {
00256   }
00257 
00258 # endif // ! MLN_INCLUDE_ONLY
00259 
00260 } // end of namespace mln
00261 
00262 
00263 #endif // ! MLN_CORE_CONCEPT_FUNCTION_HH

Generated on Thu Sep 8 2011 18:31:51 for Milena (Olena) by  doxygen 1.7.1