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