RDKit: LessEqualQuery.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

LessEqualQuery.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_LESSEQUALQUERY_H__
11 #define __RD_LESSEQUALQUERY_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 LessEqualQuery
21 : public EqualityQuery<MatchFuncArgType, DataFuncArgType, needsConversion> {
22 public:
23 LessEqualQuery() { this->d_tol = 0; };
24 //! constructs with our target value
25 explicit LessEqualQuery(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 LessEqualQuery(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 =
39 this->TypeConvert(what, Int2Type<needsConversion>());
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 };
52
53 Query<MatchFuncArgType, DataFuncArgType, needsConversion> *copy() const {
54 LessEqualQuery<MatchFuncArgType, DataFuncArgType, needsConversion> *res =
55 new LessEqualQuery<MatchFuncArgType, DataFuncArgType,
56 needsConversion>();
57 res->setNegation(this->getNegation());
58 res->setVal(this->d_val);
59 res->setTol(this->d_tol);
60 res->setDataFunc(this->d_dataFunc);
61 res->d_description = this->d_description;
62 return res;
63 };
64
65 std::string getFullDescription() const {
66 std::ostringstream res;
67 res << this->getDescription();
68 res << " " << this->d_val;
69 if (this->getNegation())
70 res << " ! <= ";
71 else
72 res << " <= ";
73 return res.str();
74 };
75 };
76 }
77 #endif
Queries::Query::getNegation
bool getNegation() const
returns whether or not we are negated
Definition: Query.h:63
Queries
Definition: AndQuery.h:15
Queries::queryCmp
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition: Query.h:177
Queries::Query::getDescription
const std::string & getDescription() const
returns our text description
Definition: Query.h:74
Queries::Query::setNegation
void setNegation(bool what)
sets whether or not we are negated
Definition: Query.h:61
Queries::EqualityQuery::setTol
void setTol(MatchFuncArgType what)
sets our tolerance
Definition: EqualityQuery.h:43
EqualityQuery.h
Queries::Query::TypeConvert
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
Query.h
Queries::LessEqualQuery::Match
bool Match(const DataFuncArgType what) const
returns whether or not we match the argument
Definition: LessEqualQuery.h:37
Queries::EqualityQuery::setVal
void setVal(MatchFuncArgType what)
sets our target value
Definition: EqualityQuery.h:38
Queries::LessEqualQuery::LessEqualQuery
LessEqualQuery(DataFuncArgType what)
constructs with our target value
Definition: LessEqualQuery.h:25
Queries::Int2Type
class to allow integer values to pick templates
Definition: Query.h:26
Queries::LessEqualQuery::LessEqualQuery
LessEqualQuery(DataFuncArgType v, DataFuncArgType t)
constructs with our target value and a tolerance
Definition: LessEqualQuery.h:31
Queries::LessEqualQuery
a Query implementing <= using a particular value (and an optional tolerance)
Definition: LessEqualQuery.h:20
Queries::EqualityQuery::d_tol
MatchFuncArgType d_tol
Definition: EqualityQuery.h:91
Queries::LessEqualQuery::getFullDescription
std::string getFullDescription() const
returns a fuller text description
Definition: LessEqualQuery.h:65
Queries::Query::d_dataFunc
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Definition: Query.h:146
Queries::LessEqualQuery::LessEqualQuery
LessEqualQuery()
Definition: LessEqualQuery.h:23
Queries::EqualityQuery
a Query implementing ==: arguments must match a particular value (within an optional tolerance) ...
Definition: EqualityQuery.h:22
Queries::Query::df_negate
bool df_negate
Definition: Query.h:144
Queries::Query::setDataFunc
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
Definition: Query.h:90
Queries::LessEqualQuery::copy
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
Definition: LessEqualQuery.h:53
Queries::Query::d_description
std::string d_description
Definition: Query.h:139
Queries::Query
Base class for all queries.
Definition: Query.h:45
Queries::EqualityQuery::d_val
MatchFuncArgType d_val
Definition: EqualityQuery.h:90