# eoInvalidateOps.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // eoInvalidateOps.h
    00005 // (c) Maarten Keijzer 2001
    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              Marc.Schoenauer@polytechnique.fr
    00023              mak@dhi.dk
    00024  */
    00025 //-----------------------------------------------------------------------------
    00026
    00027 #ifndef _eoInvalidateOps_h
    00028 #define _eoInvalidateOps_h
    00029
    00030 #include <eoOp.h>
    00031
    00045 template <class EOT>
    00046 class eoInvalidateMonOp : public eoMonOp<EOT>
    00047 {
    00048   public:
    00049     eoInvalidateMonOp(eoMonOp<EOT>& _op) : op(_op) {}
    00050
    00051     bool operator()(EOT& _eo)
    00052     {
    00053       if (op(_eo))
    00054       {
    00055         _eo.invalidate();
    00056         return true;
    00057       }
    00058
    00059       return false;
    00060     }
    00061
    00062   private:
    00063     eoMonOp<EOT>& op;
    00064 };
    00065
    00079 template <class EOT>
    00080 class eoInvalidateBinOp : public eoBinOp<EOT>
    00081 {
    00082   public:
    00083     eoInvalidateBinOp(eoBinOp<EOT>& _op) : op(_op) {}
    00084
    00085     bool operator()(EOT& _eo, const EOT& _eo2)
    00086     {
    00087       if (op(_eo, _eo2))
    00088       {
    00089         _eo.invalidate();
    00090         return true;
    00091       }
    00092
    00093       return false;
    00094     }
    00095
    00096   private:
    00097     eoBinOp<EOT>& op;
    00098 };
    00099
    00113 template <class EOT>
    00114 class eoInvalidateQuadOp : public eoQuadOp<EOT>
    00115 {
    00116   public:
    00117     eoInvalidateQuadOp(eoQuadOp<EOT>& _op) : op(_op) {}
    00118
    00119     bool operator()(EOT& _eo1, EOT& _eo2)
    00120     {
    00121       if (op(_eo1, _eo2))
    00122       {
    00123         _eo1.invalidate();
    00124         _eo2.invalidate();
    00125         return true;
    00126       }
    00127       return false;
    00128     }
    00129
    00130   private:
    00131     eoQuadOp<EOT>& op;
    00132 };
    00133
    00134 #endif