RDKit
Open-source cheminformatics and machine learning.
GreaterQuery.h
Go to the documentation of this file.
1 //
2 // Copyright (c) 2003-2006 Greg Landrum and Rational Discovery LLC
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #ifndef __RD_GREATERQUERY_H__
11 #define __RD_GREATERQUERY_H__
12 #include "Query.h"
13 #include "EqualityQuery.h"
14 
15 namespace Queries {
16  //! \brief a Query implementing > using a particular
17  //! value (and an optional tolerance)
18  template <class MatchFuncArgType, class DataFuncArgType=MatchFuncArgType,
19  bool needsConversion=false>
20  class GreaterQuery :
21  public EqualityQuery<MatchFuncArgType, DataFuncArgType,needsConversion> {
22 
23  public:
25  this->d_tol = 0;
26  };
27  //! constructs with our target value
28  explicit GreaterQuery(DataFuncArgType v) {
29  this->d_val = v;
30  this->d_tol = 0;
31  this->df_negate = false;
32  };
33  //! constructs with our target value and a tolerance
34  GreaterQuery(DataFuncArgType v,DataFuncArgType t) {
35  this->d_val = v;
36  this->d_tol = t;
37  this->df_negate = false;
38  };
39 
40  bool Match(const DataFuncArgType what) const {
41  MatchFuncArgType mfArg = this->TypeConvert(what,Int2Type<needsConversion>());
42  if( queryCmp(this->d_val,mfArg,this->d_tol) > 0 ){
43  if( this->getNegation() ) return false;
44  else return true;
45  } else {
46  if( this->getNegation() ) return true;
47  else return false;
48  }
49  };
50 
52  copy( ) const {
55  res->setVal(this->d_val);
56  res->setTol(this->d_tol);
57  res->setNegation(this->getNegation());
58  res->setDataFunc(this->d_dataFunc);
59  res->d_description = this->d_description;
60  return res;
61  };
62 
63  std::string getFullDescription() const {
64  std::ostringstream res;
65  res<<this->getDescription();
66  res<<" "<<this->d_val;
67  if(this->getNegation()) res<<" ! > ";
68  else res<<" > ";
69  return res.str();
70  };
71  };
72 
73 }
74 #endif
bool getNegation() const
returns whether or not we are negated
Definition: Query.h:60
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition: Query.h:161
const std::string & getDescription() const
returns our text description
Definition: Query.h:67
void setNegation(bool what)
sets whether or not we are negated
Definition: Query.h:58
void setTol(MatchFuncArgType what)
sets our tolerance
Definition: EqualityQuery.h:47
MatchFuncArgType TypeConvert(MatchFuncArgType what, Int2Type< false >) const
calls our dataFunc (if it&#39;s set) on what and returns the result, otherwise returns what ...
Definition: Query.h:134
bool Match(const DataFuncArgType what) const
returns whether or not we match the argument
Definition: GreaterQuery.h:40
void setVal(MatchFuncArgType what)
sets our target value
Definition: EqualityQuery.h:42
std::string getFullDescription() const
returns a fuller text description
Definition: GreaterQuery.h:63
class to allow integer values to pick templates
Definition: Query.h:26
MatchFuncArgType d_tol
Definition: EqualityQuery.h:94
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Definition: Query.h:130
a Query implementing ==: arguments must match a particular value (within an optional tolerance) ...
Definition: EqualityQuery.h:22
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
Definition: GreaterQuery.h:52
bool df_negate
Definition: Query.h:128
GreaterQuery(DataFuncArgType v)
constructs with our target value
Definition: GreaterQuery.h:28
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
Definition: Query.h:81
std::string d_description
Definition: Query.h:123
GreaterQuery(DataFuncArgType v, DataFuncArgType t)
constructs with our target value and a tolerance
Definition: GreaterQuery.h:34
a Query implementing > using a particular value (and an optional tolerance)
Definition: GreaterQuery.h:20
Base class for all queries.
Definition: Query.h:46
MatchFuncArgType d_val
Definition: EqualityQuery.h:93