EvolvingObjects
|
00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- 00002 00003 //----------------------------------------------------------------------------- 00004 // eoFunctor.h 00005 // (c) Maarten Keijzer 2000 00006 /* 00007 This library is free software; you can redistribute it and/or 00008 modify it under the terms of the GNU Lesser General Public 00009 License as published by the Free Software Foundation; either 00010 version 2 of the License, or (at your option) any later version. 00011 00012 This library is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 Lesser General Public License for more details. 00016 00017 You should have received a copy of the GNU Lesser General Public 00018 License along with this library; if not, write to the Free Software 00019 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 Contact: todos@geneura.ugr.es, http://geneura.ugr.es 00022 mak@dhi.dk 00023 CVS Info: $Date: 2004-12-01 09:22:48 $ $Header: /home/nojhan/dev/eodev/eodev_cvs/eo/src/eoFunctor.h,v 1.7 2004-12-01 09:22:48 evomarc Exp $ $Author: evomarc $ 00024 */ 00025 //----------------------------------------------------------------------------- 00026 00027 #ifndef _eoFunctor_h 00028 #define _eoFunctor_h 00029 00030 #include <functional> 00031 00050 class eoFunctorBase 00051 { 00052 public : 00054 virtual ~eoFunctorBase() {} 00055 00057 struct procedure_tag {}; 00059 struct unary_function_tag {}; 00061 struct binary_function_tag {}; 00062 }; 00073 template <class R> 00074 class eoF : public eoFunctorBase 00075 { 00076 public : 00077 00079 virtual ~eoF() {} 00080 00082 typedef R result_type; 00083 00085 virtual R operator()() = 0; 00086 00088 static eoFunctorBase::procedure_tag functor_category() 00089 { 00090 return eoFunctorBase::procedure_tag(); 00091 } 00092 }; 00093 00100 template<class R> 00101 eoFunctorBase::procedure_tag functor_category(const eoF<R>&) 00102 { 00103 return eoFunctorBase::procedure_tag(); 00104 } 00105 00113 template <class A1, class R> 00114 class eoUF : public eoFunctorBase, public std::unary_function<A1, R> 00115 { 00116 public : 00117 00119 virtual ~eoUF() {} 00120 00122 virtual R operator()(A1) = 0; 00123 00125 static eoFunctorBase::unary_function_tag functor_category() 00126 { 00127 return eoFunctorBase::unary_function_tag(); 00128 } 00129 }; 00130 00136 template<class R, class A1> 00137 eoFunctorBase::unary_function_tag functor_category(const eoUF<A1, R>&) 00138 { 00139 return eoFunctorBase::unary_function_tag(); 00140 } 00141 00142 00150 template <class A1, class A2, class R> 00151 class eoBF : public eoFunctorBase, public std::binary_function<A1, A2, R> 00152 { 00153 public : 00155 virtual ~eoBF() {} 00156 00157 //typedef R result_type; 00158 //typedef A1 first_argument_type; 00159 //typedef A2 second_argument_type; 00160 00162 virtual R operator()(A1, A2) = 0; 00163 00165 static eoFunctorBase::binary_function_tag functor_category() 00166 { 00167 return eoFunctorBase::binary_function_tag(); 00168 } 00169 }; 00170 00176 template<class R, class A1, class A2> 00177 eoFunctorBase::binary_function_tag functor_category(const eoBF<A1, A2, R>&) 00178 { 00179 return eoFunctorBase::binary_function_tag(); 00180 } 00181 00184 #endif