EvolvingObjects
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 
00046 template <class EOT>
00047 class eoInvalidateMonOp : public eoMonOp<EOT>
00048 {
00049   public:
00050     eoInvalidateMonOp(eoMonOp<EOT>& _op) : op(_op) {}
00051 
00052     bool operator()(EOT& _eo)
00053     {
00054       if (op(_eo))
00055       {
00056         _eo.invalidate();
00057         return true;
00058       }
00059 
00060       return false;
00061     }
00062 
00063   private:
00064     eoMonOp<EOT>& op;
00065 };
00066 
00080 template <class EOT>
00081 class eoInvalidateBinOp : public eoBinOp<EOT>
00082 {
00083   public:
00084     eoInvalidateBinOp(eoBinOp<EOT>& _op) : op(_op) {}
00085 
00086     bool operator()(EOT& _eo, const EOT& _eo2)
00087     {
00088       if (op(_eo, _eo2))
00089       {
00090         _eo.invalidate();
00091         return true;
00092       }
00093 
00094       return false;
00095     }
00096 
00097   private:
00098     eoBinOp<EOT>& op;
00099 };
00100 
00114 template <class EOT>
00115 class eoInvalidateQuadOp : public eoQuadOp<EOT>
00116 {
00117   public:
00118     eoInvalidateQuadOp(eoQuadOp<EOT>& _op) : op(_op) {}
00119 
00120     bool operator()(EOT& _eo1, EOT& _eo2)
00121     {
00122       if (op(_eo1, _eo2))
00123       {
00124         _eo1.invalidate();
00125         _eo2.invalidate();
00126         return true;
00127       }
00128       return false;
00129     }
00130 
00131   private:
00132     eoQuadOp<EOT>& op;
00133 };
00134 
00135 #endif
 All Classes Namespaces Files Functions Variables Typedefs Friends