Back to index

salome-kernel  6.5.0
FindKeyPredicate.hxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : FindKeyPredicate.hxx
00024 //  Author : Eric Fayolle (EDF)
00025 //  Module : KERNEL
00026 // Modified by : $LastChangedBy$
00027 // Date        : $LastChangedDate: 2007-01-08 19:01:14 +0100 (lun, 08 jan 2007) $
00028 // Id          : $Id: FindKeyPredicate.hxx,v 1.3.2.1.10.2.12.1 2012-04-12 14:05:06 vsr Exp $
00029 //
00030 #ifndef __FIND_KEY_PREDICATE__
00031 #define __FIND_KEY_PREDICATE__
00032 
00033 #include <functional>
00034 #include <utility>
00035 #include "DisplayPair.hxx"
00036 
00037 template < typename T >
00038 struct FindKeyPredicate : public std::unary_function < T, bool > 
00039 {
00040   T _value;
00041   FindKeyPredicate(const T& value):_value(value){}
00042   inline bool operator()(const T &v1, const T& v2) const {
00043     std::cout << "FindKeyPredicate Generic -> :" << &(v1.first) << std::endl;
00044     return ( v1 == _value );
00045   }
00046 };
00047 
00048 // Pour les MAPs avec une clef sous forme de pair
00049 // template <typename T1, typename T2, typename T3>
00050 // struct FindKeyPredicate<  std::pair<const std::pair<T1,T2>, T3 > > : 
00051 //   public std::binary_function < std::pair<const std::pair<T1,T2>, T3 >,
00052 //                              std::pair<const std::pair<T1,T2>, T3 >, bool > 
00053 // {
00054 //   std::pair<T1,T2> _value;
00055 //   FindKeyPredicate(const std::pair<T1,T2> & value):_value(value){
00056 //     std::cout << "1-Initializing with value " << _value << std::endl;
00057 //   }
00058 //   bool operator()( const std::pair<const std::pair<T1,T2>, T3 > & v1,  
00059 //                 const std::pair<const std::pair<T1,T2>, T3 > v2) const {
00060 //     std::cout << "1-> :" << v1 << "," << v2 << " " << std::endl;
00061 //     return (v1.first <= _value ) && (_value < v2.first) ;
00062 //   }
00063 // };
00064 
00065 template <typename T1, typename T2>
00066 struct FindKeyPredicate<  std::pair<T1,T2> > : public std::unary_function < std::pair<T1,T2>, bool > 
00067 {
00068   T1 _value;
00069   FindKeyPredicate(const T1 & value):_value(value){
00070     std::cout << "FindKeyPredicate 2-Initializing with value " << _value << std::endl;
00071   }
00072   
00073   inline bool operator()( const std::pair<T1,T2> & v1) const {
00074     std::cout << "FindKeyPredicate 2-> :" << v1.first << std::endl;
00075     return v1.first == _value  ;
00076   }
00077 };
00078 
00079 #endif