/src/rdkit/Code/Query/LessEqualQuery.h
Line | Count | Source |
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_LESSEQUALQUERY_H |
12 | | #define RD_LESSEQUALQUERY_H |
13 | | #include "Query.h" |
14 | | #include "EqualityQuery.h" |
15 | | |
16 | | namespace Queries { |
17 | | //! \brief a Query implementing <= using a particular |
18 | | //! value (and an optional tolerance) |
19 | | template <class MatchFuncArgType, class DataFuncArgType = MatchFuncArgType, |
20 | | bool needsConversion = false> |
21 | | class RDKIT_QUERY_EXPORT LessEqualQuery |
22 | | : public EqualityQuery<MatchFuncArgType, DataFuncArgType, needsConversion> { |
23 | | public: |
24 | 147k | LessEqualQuery() { this->d_tol = 0; }Queries::LessEqualQuery<int, RDKit::Atom const*, true>::LessEqualQuery() Line | Count | Source | 24 | 147k | LessEqualQuery() { this->d_tol = 0; } |
Unexecuted instantiation: Queries::LessEqualQuery<int, RDKit::Bond const*, true>::LessEqualQuery() |
25 | | //! constructs with our target value |
26 | | explicit LessEqualQuery(DataFuncArgType what) { |
27 | | this->d_val = what; |
28 | | this->d_tol = 0; |
29 | | this->df_negate = false; |
30 | | } |
31 | | //! constructs with our target value and a tolerance |
32 | | LessEqualQuery(DataFuncArgType v, DataFuncArgType t) { |
33 | | this->d_val = v; |
34 | | this->d_tol = t; |
35 | | this->df_negate = false; |
36 | | } |
37 | | |
38 | 0 | bool Match(const DataFuncArgType what) const override { |
39 | 0 | MatchFuncArgType mfArg = |
40 | 0 | this->TypeConvert(what, Int2Type<needsConversion>()); |
41 | 0 | if (queryCmp(this->d_val, mfArg, this->d_tol) <= 0) { |
42 | 0 | return !this->getNegation(); |
43 | 0 | } else { |
44 | 0 | return this->getNegation(); |
45 | 0 | } |
46 | 0 | } Unexecuted instantiation: Queries::LessEqualQuery<int, RDKit::Atom const*, true>::Match(RDKit::Atom const*) const Unexecuted instantiation: Queries::LessEqualQuery<int, RDKit::Bond const*, true>::Match(RDKit::Bond const*) const |
47 | | |
48 | | Query<MatchFuncArgType, DataFuncArgType, needsConversion> *copy() |
49 | 136k | const override { |
50 | 136k | LessEqualQuery<MatchFuncArgType, DataFuncArgType, needsConversion> *res = |
51 | 136k | new LessEqualQuery<MatchFuncArgType, DataFuncArgType, |
52 | 136k | needsConversion>(); |
53 | 136k | res->setNegation(this->getNegation()); |
54 | 136k | res->setVal(this->d_val); |
55 | 136k | res->setTol(this->d_tol); |
56 | 136k | res->setDataFunc(this->d_dataFunc); |
57 | 136k | res->d_description = this->d_description; |
58 | 136k | res->d_queryType = this->d_queryType; |
59 | 136k | return res; |
60 | 136k | } Queries::LessEqualQuery<int, RDKit::Atom const*, true>::copy() const Line | Count | Source | 49 | 136k | const override { | 50 | 136k | LessEqualQuery<MatchFuncArgType, DataFuncArgType, needsConversion> *res = | 51 | 136k | new LessEqualQuery<MatchFuncArgType, DataFuncArgType, | 52 | 136k | needsConversion>(); | 53 | 136k | res->setNegation(this->getNegation()); | 54 | 136k | res->setVal(this->d_val); | 55 | 136k | res->setTol(this->d_tol); | 56 | 136k | res->setDataFunc(this->d_dataFunc); | 57 | 136k | res->d_description = this->d_description; | 58 | 136k | res->d_queryType = this->d_queryType; | 59 | 136k | return res; | 60 | 136k | } |
Unexecuted instantiation: Queries::LessEqualQuery<int, RDKit::Bond const*, true>::copy() const |
61 | | |
62 | 0 | std::string getFullDescription() const override { |
63 | 0 | std::ostringstream res; |
64 | 0 | res << this->getDescription(); |
65 | 0 | res << " " << this->d_val; |
66 | 0 | if (this->getNegation()) { |
67 | 0 | res << " ! <= "; |
68 | 0 | } else { |
69 | 0 | res << " <= "; |
70 | 0 | } |
71 | 0 | return res.str(); |
72 | 0 | } Unexecuted instantiation: Queries::LessEqualQuery<int, RDKit::Atom const*, true>::getFullDescription() const Unexecuted instantiation: Queries::LessEqualQuery<int, RDKit::Bond const*, true>::getFullDescription() const |
73 | | }; |
74 | | } // namespace Queries |
75 | | #endif |