GreaterEqualQuery.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2003-2006 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved @@
00005 //  This file is part of the RDKit.
00006 //  The contents are covered by the terms of the BSD license
00007 //  which is included in the file license.txt, found at the root
00008 //  of the RDKit source tree.
00009 //
00010 #ifndef __RD_GREATEREQUALQUERY_H__
00011 #define __RD_GREATEREQUALQUERY_H__
00012 #include "Query.h"
00013 #include "EqualityQuery.h"
00014 
00015 namespace Queries {
00016   //! \brief a Query implementing >= using a particular
00017   //!  value (and an optional tolerance)
00018   template <class MatchFuncArgType, class DataFuncArgType=MatchFuncArgType,
00019     bool needsConversion=false>
00020   class GreaterEqualQuery :
00021     public EqualityQuery<MatchFuncArgType, DataFuncArgType,needsConversion> {
00022 
00023   public:
00024     GreaterEqualQuery() { this->d_tol=0;};
00025     //! constructs with our target value
00026     explicit GreaterEqualQuery(DataFuncArgType what) {
00027       this->d_val = what;
00028       this->d_tol = 0;
00029       this->df_negate = false;
00030     };
00031     //! constructs with our target value and a tolerance
00032     GreaterEqualQuery(DataFuncArgType v,DataFuncArgType t) {
00033       this->d_val = v;
00034       this->d_tol = t;
00035       this->df_negate = false;
00036     };
00037 
00038 
00039     bool Match(const DataFuncArgType what) const {
00040       MatchFuncArgType mfArg = this->TypeConvert(what,Int2Type<needsConversion>());
00041       if( queryCmp(this->d_val,mfArg,this->d_tol) >= 0 ){
00042         if( this->getNegation() ) return false;
00043         else return true;
00044       } else {
00045         if( this->getNegation() ) return true;
00046         else return false;
00047       }
00048     };
00049     Query<MatchFuncArgType,DataFuncArgType,needsConversion> *
00050     copy( ) const {
00051       GreaterEqualQuery<MatchFuncArgType,DataFuncArgType,needsConversion> *res =
00052         new GreaterEqualQuery<MatchFuncArgType,DataFuncArgType,needsConversion>();
00053       res->setVal(this->d_val);
00054       res->setTol(this->d_tol);
00055       res->setNegation(this->getNegation());
00056       res->setDataFunc(this->d_dataFunc);
00057       res->d_description = this->d_description;
00058       return res;
00059     };
00060   };
00061 
00062 }
00063 #endif