RDKit
Open-source cheminformatics and machine learning.
Toggle main menu visibility
Loading...
Searching...
No Matches
LessEqualQuery.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_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
LessEqualQuery
() { this->
d_tol
= 0; }
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
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
48
Query<MatchFuncArgType, DataFuncArgType, needsConversion>
*
copy
()
49
const override
{
50
LessEqualQuery<MatchFuncArgType, DataFuncArgType, needsConversion>
*res =
51
new
LessEqualQuery
<MatchFuncArgType, DataFuncArgType,
52
needsConversion>();
53
res->
setNegation
(this->
getNegation
());
54
res->
setVal
(this->
d_val
);
55
res->
setTol
(this->
d_tol
);
56
res->
setDataFunc
(this->
d_dataFunc
);
57
res->
d_description
= this->
d_description
;
58
res->
d_queryType
= this->
d_queryType
;
59
return
res;
60
}
61
62
std::string
getFullDescription
()
const override
{
63
std::ostringstream res;
64
res << this->
getDescription
();
65
res <<
" "
<< this->
d_val
;
66
if
(this->
getNegation
()) {
67
res <<
" ! <= "
;
68
}
else
{
69
res <<
" <= "
;
70
}
71
return
res.str();
72
}
73
};
74
}
// namespace Queries
75
#endif
EqualityQuery.h
Query.h
Queries::EqualityQuery::setTol
void setTol(MatchFuncArgType what)
sets our tolerance
Definition
EqualityQuery.h:47
Queries::EqualityQuery< MatchFuncArgType, MatchFuncArgType, false >::EqualityQuery
EqualityQuery()
Definition
EqualityQuery.h:26
Queries::EqualityQuery::setVal
void setVal(MatchFuncArgType what)
sets our target value
Definition
EqualityQuery.h:42
Queries::Int2Type
class to allow integer values to pick templates
Definition
Query.h:27
Queries::LessEqualQuery::getFullDescription
std::string getFullDescription() const override
returns a fuller text description
Definition
LessEqualQuery.h:62
Queries::LessEqualQuery::LessEqualQuery
LessEqualQuery()
Definition
LessEqualQuery.h:24
Queries::LessEqualQuery::Match
bool Match(const DataFuncArgType what) const override
Definition
LessEqualQuery.h:38
Queries::LessEqualQuery::copy
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const override
returns a copy of this Query
Definition
LessEqualQuery.h:48
Queries::LessEqualQuery::LessEqualQuery
LessEqualQuery(DataFuncArgType what)
constructs with our target value
Definition
LessEqualQuery.h:26
Queries::LessEqualQuery::LessEqualQuery
LessEqualQuery(DataFuncArgType v, DataFuncArgType t)
constructs with our target value and a tolerance
Definition
LessEqualQuery.h:32
Queries::Query
Base class for all queries.
Definition
Query.h:48
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::TypeConvert
MatchFuncArgType TypeConvert(MatchFuncArgType what, Int2Type< false >) const
Definition
Query.h:174
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::d_dataFunc
std::function< MatchFuncArgType(MatchFuncArgType)> d_dataFunc
Definition
Query.h:169
Queries::Query::d_queryType
std::string d_queryType
Definition
Query.h:158
Queries::Query::setDataFunc
void setDataFunc(std::function< MatchFuncArgType(DataFuncArgType)> what)
sets our data function
Definition
Query.h:99
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::getNegation
bool getNegation() const
Definition
Query.h:64
Queries::Query::setNegation
void setNegation(bool what)
sets whether or not we are negated
Definition
Query.h:62
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::getDescription
const std::string & getDescription() const
Definition
Query.h:73
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::df_negate
bool df_negate
Definition
Query.h:160
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::d_tol
MatchFuncArgType d_tol
Definition
Query.h:156
Queries::Query< MatchFuncArgType, MatchFuncArgType, false >::d_val
MatchFuncArgType d_val
Definition
Query.h:155
Queries::Query::d_description
std::string d_description
Definition
Query.h:157
export.h
RDKIT_QUERY_EXPORT
#define RDKIT_QUERY_EXPORT
Definition
export.h:833
Queries
Definition
AndQuery.h:16
Queries::queryCmp
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition
Query.h:202
Query
LessEqualQuery.h
Generated on
for RDKit by
1.17.0