RDKit
Open-source cheminformatics and machine learning.
GreaterEqualQuery.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_GREATEREQUALQUERY_H__
11 #define __RD_GREATEREQUALQUERY_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>
21  : public EqualityQuery<MatchFuncArgType, DataFuncArgType, needsConversion> {
22  public:
23  GreaterEqualQuery() { this->d_tol = 0; };
24  //! constructs with our target value
25  explicit GreaterEqualQuery(DataFuncArgType what) {
26  this->d_val = what;
27  this->d_tol = 0;
28  this->df_negate = false;
29  };
30  //! constructs with our target value and a tolerance
31  GreaterEqualQuery(DataFuncArgType v, DataFuncArgType t) {
32  this->d_val = v;
33  this->d_tol = t;
34  this->df_negate = false;
35  };
36 
37  bool Match(const DataFuncArgType what) const {
38  MatchFuncArgType mfArg =
40  if (queryCmp(this->d_val, mfArg, this->d_tol) >= 0) {
41  if (this->getNegation())
42  return false;
43  else
44  return true;
45  } else {
46  if (this->getNegation())
47  return true;
48  else
49  return false;
50  }
51  };
54  new GreaterEqualQuery<MatchFuncArgType, DataFuncArgType,
55  needsConversion>();
56  res->setVal(this->d_val);
57  res->setTol(this->d_tol);
58  res->setNegation(this->getNegation());
59  res->setDataFunc(this->d_dataFunc);
60  res->d_description = this->d_description;
61  return res;
62  };
63 
64  std::string getFullDescription() const {
65  std::ostringstream res;
66  res << this->getDescription();
67  res << " " << this->d_val;
68  if (this->getNegation())
69  res << " ! >= ";
70  else
71  res << " >= ";
72  return res.str();
73  };
74 };
75 }
76 #endif
bool getNegation() const
returns whether or not we are negated
Definition: Query.h:63
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition: Query.h:177
const std::string & getDescription() const
returns our text description
Definition: Query.h:74
void setNegation(bool what)
sets whether or not we are negated
Definition: Query.h:61
void setTol(MatchFuncArgType what)
sets our tolerance
Definition: EqualityQuery.h:43
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:150
void setVal(MatchFuncArgType what)
sets our target value
Definition: EqualityQuery.h:38
std::string getFullDescription() const
returns a fuller text description
class to allow integer values to pick templates
Definition: Query.h:26
bool Match(const DataFuncArgType what) const
returns whether or not we match the argument
GreaterEqualQuery(DataFuncArgType what)
constructs with our target value
MatchFuncArgType d_tol
Definition: EqualityQuery.h:91
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Definition: Query.h:146
a Query implementing ==: arguments must match a particular value (within an optional tolerance) ...
Definition: EqualityQuery.h:22
bool df_negate
Definition: Query.h:144
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
Definition: Query.h:90
std::string d_description
Definition: Query.h:139
a Query implementing >= using a particular value (and an optional tolerance)
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
Base class for all queries.
Definition: Query.h:45
MatchFuncArgType d_val
Definition: EqualityQuery.h:90
GreaterEqualQuery(DataFuncArgType v, DataFuncArgType t)
constructs with our target value and a tolerance