GreaterQuery.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_GREATERQUERY_H__
00011 #define __RD_GREATERQUERY_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 GreaterQuery :
00021     public EqualityQuery<MatchFuncArgType, DataFuncArgType,needsConversion> {
00022 
00023   public:
00024     GreaterQuery() {
00025       this->d_tol = 0;
00026     };
00027     //! constructs with our target value
00028     explicit GreaterQuery(DataFuncArgType v) {
00029       this->d_val = v;
00030       this->d_tol = 0;
00031       this->df_negate = false;
00032     };
00033     //! constructs with our target value and a tolerance
00034     GreaterQuery(DataFuncArgType v,DataFuncArgType t) {
00035       this->d_val = v;
00036       this->d_tol = t;
00037       this->df_negate = false;
00038     };
00039 
00040     bool Match(const DataFuncArgType what) const {
00041       MatchFuncArgType mfArg = this->TypeConvert(what,Int2Type<needsConversion>());
00042       if( queryCmp(this->d_val,mfArg,this->d_tol) > 0 ){
00043         if( this->getNegation() ) return false;
00044         else return true;
00045       } else {
00046         if( this->getNegation() ) return true;
00047         else return false;
00048       }
00049     };
00050 
00051     Query<MatchFuncArgType,DataFuncArgType,needsConversion> *
00052     copy( ) const {
00053       GreaterQuery<MatchFuncArgType,DataFuncArgType,needsConversion> *res =
00054         new GreaterQuery<MatchFuncArgType,DataFuncArgType,needsConversion>();
00055       res->setVal(this->d_val);
00056       res->setTol(this->d_tol);
00057       res->setNegation(this->getNegation());
00058       res->setDataFunc(this->d_dataFunc);
00059       res->d_description = this->d_description;
00060       return res;
00061     };
00062 
00063   };
00064 
00065 }
00066 #endif