# eoFunctor.h

    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: /cvsroot/eodev/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
    00046 class eoFunctorBase
    00047 {
    00048 public :
    00050     virtual ~eoFunctorBase() {}
    00051
    00053     struct procedure_tag {};
    00055     struct unary_function_tag {};
    00057     struct binary_function_tag {};
    00058 };
    00059
    00067 template <class R>
    00068 class eoF : public eoFunctorBase
    00069 {
    00070 public :
    00071
    00073     virtual ~eoF() {}
    00074
    00076     typedef R result_type;
    00077
    00079     virtual R operator()() = 0;
    00080
    00082     static eoFunctorBase::procedure_tag functor_category()
    00083     {
    00084         return eoFunctorBase::procedure_tag();
    00085     }
    00086 };
    00087
    00094 template<class R>
    00095 eoFunctorBase::procedure_tag functor_category(const eoF<R>&)
    00096 {
    00097     return eoFunctorBase::procedure_tag();
    00098 }
    00099
    00107 template <class A1, class R>
    00108 class eoUF : public eoFunctorBase, public std::unary_function<A1, R>
    00109 {
    00110 public :
    00111
    00113     virtual ~eoUF() {}
    00114
    00116     virtual R operator()(A1) = 0;
    00117
    00119     static eoFunctorBase::unary_function_tag functor_category()
    00120     {
    00121         return eoFunctorBase::unary_function_tag();
    00122     }
    00123 };
    00124
    00130 template<class R, class A1>
    00131 eoFunctorBase::unary_function_tag functor_category(const eoUF<A1, R>&)
    00132 {
    00133     return eoFunctorBase::unary_function_tag();
    00134 }
    00135
    00136
    00144 template <class A1, class A2, class R>
    00145 class eoBF : public eoFunctorBase, public std::binary_function<A1, A2, R>
    00146 {
    00147 public :
    00149     virtual ~eoBF() {}
    00150
    00151     //typedef R result_type;
    00152     //typedef A1 first_argument_type;
    00153     //typedef A2 second_argument_type;
    00154
    00156     virtual R operator()(A1, A2) = 0;
    00157
    00159     static eoFunctorBase::binary_function_tag functor_category()
    00160     {
    00161         return eoFunctorBase::binary_function_tag();
    00162     }
    00163 };
    00164
    00170 template<class R, class A1, class A2>
    00171 eoFunctorBase::binary_function_tag functor_category(const eoBF<A1, A2, R>&)
    00172 {
    00173     return eoFunctorBase::binary_function_tag();
    00174 }
    00175
    00176
    00177 #endif