RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
LessQuery.h
Go to the documentation of this file.
1//
2// Copyright (c) 2003-2020 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#include <RDGeneral/export.h>
11#ifndef RD_LESSQUERY_H
12#define RD_LESSQUERY_H
13#include "Query.h"
14#include "EqualityQuery.h"
15
16namespace Queries {
17//! \brief a Query implementing < using a particular
18//! value (and an optional tolerance)
19template <class MatchFuncArgType, class DataFuncArgType = MatchFuncArgType,
20 bool needsConversion = false>
22 : public EqualityQuery<MatchFuncArgType, DataFuncArgType, needsConversion> {
23 public:
24 LessQuery() { this->d_tol = 0; }
25 //! constructs with our target value
26 explicit LessQuery(DataFuncArgType v) {
27 this->d_val = v;
28 this->d_tol = 0;
29 this->df_negate = false;
30 }
31 //! constructs with our target value and a tolerance
32 LessQuery(DataFuncArgType v, DataFuncArgType t) {
33 this->d_val = v;
34 this->d_tol = t;
35 this->df_negate = false;
36 }
37
38 bool Match(const DataFuncArgType what) const override {
39 MatchFuncArgType mfArg =
40 this->TypeConvert(what, Int2Type<needsConversion>());
41 if (queryCmp(this->d_val, mfArg, this->d_tol) < 0) {
42 return !this->getNegation();
43 } else {
44 return this->getNegation();
45 }
46 }
47
49 const override {
52 res->setNegation(this->getNegation());
53 res->setVal(this->d_val);
54 res->setTol(this->d_tol);
55 res->setDataFunc(this->d_dataFunc);
56 res->d_description = this->d_description;
57 res->d_queryType = this->d_queryType;
58 return res;
59 }
60
61 std::string getFullDescription() const override {
62 std::ostringstream res;
63 res << this->getDescription();
64 res << " " << this->d_val;
65 if (this->getNegation()) {
66 res << " ! < ";
67 } else {
68 res << " < ";
69 }
70 return res.str();
71 }
72};
73} // namespace Queries
74#endif
a Query implementing ==: arguments must match a particular value (within an optional tolerance)
void setTol(MatchFuncArgType what)
sets our tolerance
void setVal(MatchFuncArgType what)
sets our target value
class to allow integer values to pick templates
Definition Query.h:26
a Query implementing < using a particular value (and an optional tolerance)
Definition LessQuery.h:22
bool Match(const DataFuncArgType what) const override
returns whether or not we match the argument
Definition LessQuery.h:38
std::string getFullDescription() const override
returns a fuller text description
Definition LessQuery.h:61
LessQuery(DataFuncArgType v, DataFuncArgType t)
constructs with our target value and a tolerance
Definition LessQuery.h:32
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const override
returns a copy of this Query
Definition LessQuery.h:48
LessQuery(DataFuncArgType v)
constructs with our target value
Definition LessQuery.h:26
Base class for all queries.
Definition Query.h:45
std::string d_queryType
Definition Query.h:153
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
Definition Query.h:94
void setNegation(bool what)
sets whether or not we are negated
Definition Query.h:59
std::string d_description
Definition Query.h:152
#define RDKIT_QUERY_EXPORT
Definition export.h:629
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition Query.h:197