15#pragma warning(disable : 4800)
43template <
class MatchFuncArgType,
class DataFuncArgType = MatchFuncArgType,
44 bool needsConversion =
false>
55 Query() : d_matchFunc(nullptr), d_dataFunc(nullptr) {}
56 virtual ~Query() { this->d_children.clear(); }
64 void setDescription(
const std::string &descr) { this->d_description = descr; }
67 this->d_description = std::string(descr);
74 return getDescription();
76 return "not " + getDescription();
81 void setTypeLabel(
const std::string &typ) { this->d_queryType = typ; }
83 void setTypeLabel(
const char *typ) { this->d_queryType = std::string(typ); }
85 const std::string &
getTypeLabel()
const {
return this->d_queryType; }
89 this->d_matchFunc = what;
92 bool (*
getMatchFunc()
const)(MatchFuncArgType) {
return this->d_matchFunc; }
95 this->d_dataFunc = what;
99 return this->d_dataFunc;
110 virtual bool Match(
const DataFuncArgType arg)
const {
113 if (this->d_matchFunc) {
114 tRes = this->d_matchFunc(mfArg);
116 tRes =
static_cast<bool>(mfArg);
119 if (this->getNegation()) {
135 for (
auto iter = this->beginChildren(); iter != this->endChildren();
139 res->
d_val = this->d_val;
140 res->
d_tol = this->d_tol;
150 MatchFuncArgType d_val = 0;
151 MatchFuncArgType d_tol = 0;
152 std::string d_description =
"";
153 std::string d_queryType =
"";
155 bool df_negate{
false};
156 bool (*d_matchFunc)(MatchFuncArgType);
164 MatchFuncArgType (*d_dataFunc)(DataFuncArgType);
165 MatchFuncArgType (*d_dataFuncSameType)(MatchFuncArgType);
171 MatchFuncArgType mfArg;
172 if (this->d_dataFuncSameType !=
nullptr &&
173 std::is_same<MatchFuncArgType, DataFuncArgType>::value) {
174 mfArg = this->d_dataFuncSameType(what);
185 MatchFuncArgType mfArg;
186 mfArg = this->d_dataFunc(what);
196template <
class T1,
class T2>
197int queryCmp(
const T1 v1,
const T2 v2,
const T1 tol) {
#define PRECONDITION(expr, mess)
class to allow integer values to pick templates
Base class for all queries.
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
MatchFuncArgType TypeConvert(DataFuncArgType what, Int2Type< true >) const
const std::string & getTypeLabel() const
returns our text label.
bool(*)(MatchFuncArgType) getMatchFunc() const
returns our match function:
std::shared_ptr< Query< MatchFuncArgType, DataFuncArgType, needsConversion > > CHILD_TYPE
virtual std::string getFullDescription() const
returns a fuller text description
virtual bool Match(const DataFuncArgType arg) const
returns whether or not we match the argument
MatchFuncArgType TypeConvert(MatchFuncArgType what, Int2Type< false >) const
calls our dataFunc (if it's set) on what and returns the result, otherwise returns what
void addChild(CHILD_TYPE child)
adds a child to our list of children
void setDescription(const char *descr)
This is an overloaded member function, provided for convenience. It differs from the above function o...
CHILD_VECT_CI endChildren() const
returns an iterator for the end of our child vector
MatchFuncArgType MATCH_FUNC_ARG_TYPE
CHILD_VECT_CI beginChildren() const
returns an iterator for the beginning of our child vector
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
void setTypeLabel(const std::string &typ)
sets our type label
std::vector< CHILD_TYPE > CHILD_VECT
DataFuncArgType DATA_FUNC_ARG_TYPE
bool getNegation() const
returns whether or not we are negated
void setNegation(bool what)
sets whether or not we are negated
virtual Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
const std::string & getDescription() const
returns our text description
typename CHILD_VECT::const_iterator CHILD_VECT_CI
void setMatchFunc(bool(*what)(MatchFuncArgType))
sets our match function
void setTypeLabel(const char *typ)
This is an overloaded member function, provided for convenience. It differs from the above function o...
typename CHILD_VECT::iterator CHILD_VECT_I
MatchFuncArgType(*)(DataFuncArgType) getDataFunc() const
returns our data function:
void setDescription(const std::string &descr)
sets our text description
std::string d_description
bool(* d_matchFunc)(MatchFuncArgType)
#define RDKIT_QUERY_EXPORT
int queryCmp(const T1 v1, const T2 v2, const T1 tol)