LessQuery.h
Go to the documentation of this file.
//
// Copyright (c) 2003-2006 Greg Landrum and Rational Discovery LLC
//
// @@ All Rights Reserved @@
// This file is part of the RDKit.
// The contents are covered by the terms of the BSD license
// which is included in the file license.txt, found at the root
// of the RDKit source tree.
//
#ifndef __RD_LESSQUERY_H__
#define __RD_LESSQUERY_H__
#include "Query.h"
#include "EqualityQuery.h"
namespace Queries {
//! \brief a Query implementing < using a particular
//! value (and an optional tolerance)
template <class MatchFuncArgType, class DataFuncArgType=MatchFuncArgType,
bool needsConversion=false>
class LessQuery :
public EqualityQuery<MatchFuncArgType, DataFuncArgType,needsConversion> {
public:
LessQuery() { this->d_tol = 0;};
//! constructs with our target value
explicit LessQuery(DataFuncArgType v) {
this->d_val = v;
this->d_tol = 0;
this->df_negate = false;
};
//! constructs with our target value and a tolerance
LessQuery(DataFuncArgType v,DataFuncArgType t) {
this->d_val = v;
this->d_tol = t;
this->df_negate = false;
};
bool Match(const DataFuncArgType what) const {
MatchFuncArgType mfArg = this->TypeConvert(what,Int2Type<needsConversion>());
if( queryCmp(this->d_val,mfArg,this->d_tol) < 0 ){
if( this->getNegation() ) return false;
else return true;
} else {
if( this->getNegation() ) return true;
else return false;
}
};
Query<MatchFuncArgType,DataFuncArgType,needsConversion> *
copy( ) const {
LessQuery<MatchFuncArgType,DataFuncArgType,needsConversion> *res =
new LessQuery<MatchFuncArgType,DataFuncArgType,needsConversion>();
res->setNegation(this->getNegation());
res->setVal(this->d_val);
res->setTol(this->d_tol);
res->setDataFunc(this->d_dataFunc);
res->d_description = this->d_description;
return res;
};
std::string getFullDescription() const {
std::ostringstream res;
res<<this->getDescription();
res<<" "<<this->d_val;
if(this->getNegation()) res<<" ! < ";
else res<<" < ";
return res.str();
};
};
}
#endif
Queries::Query::getNegation
bool getNegation() const
returns whether or not we are negated
Definition: Query.h:60
Queries::LessQuery::copy
Query< MatchFuncArgType, DataFuncArgType, needsConversion > * copy() const
returns a copy of this Query
Definition: LessQuery.h:50
Queries
Definition: AndQuery.h:15
Queries::queryCmp
int queryCmp(const T1 v1, const T2 v2, const T1 tol)
Definition: Query.h:161
Queries::Query::getDescription
const std::string & getDescription() const
returns our text description
Definition: Query.h:67
Queries::Query::setNegation
void setNegation(bool what)
sets whether or not we are negated
Definition: Query.h:58
Queries::EqualityQuery::setTol
void setTol(MatchFuncArgType what)
sets our tolerance
Definition: EqualityQuery.h:47
EqualityQuery.h
Queries::Query::TypeConvert
MatchFuncArgType TypeConvert(MatchFuncArgType what, Int2Type< false >) const
calls our dataFunc (if it's set) on what and returns the result, otherwise returns what ...
Definition: Query.h:134
Queries::LessQuery::Match
bool Match(const DataFuncArgType what) const
returns whether or not we match the argument
Definition: LessQuery.h:38
Query.h
Queries::EqualityQuery::setVal
void setVal(MatchFuncArgType what)
sets our target value
Definition: EqualityQuery.h:42
Queries::LessQuery::LessQuery
LessQuery(DataFuncArgType v, DataFuncArgType t)
constructs with our target value and a tolerance
Definition: LessQuery.h:32
Queries::LessQuery::LessQuery
LessQuery()
Definition: LessQuery.h:24
Queries::Int2Type
class to allow integer values to pick templates
Definition: Query.h:26
Queries::EqualityQuery::d_tol
MatchFuncArgType d_tol
Definition: EqualityQuery.h:94
Queries::LessQuery::LessQuery
LessQuery(DataFuncArgType v)
constructs with our target value
Definition: LessQuery.h:26
Queries::Query::d_dataFunc
MatchFuncArgType(* d_dataFunc)(DataFuncArgType)
Definition: Query.h:130
Queries::LessQuery
a Query implementing < using a particular value (and an optional tolerance)
Definition: LessQuery.h:20
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:128
Queries::Query::setDataFunc
void setDataFunc(MatchFuncArgType(*what)(DataFuncArgType))
sets our data function
Definition: Query.h:81
Queries::Query::d_description
std::string d_description
Definition: Query.h:123
Queries::LessQuery::getFullDescription
std::string getFullDescription() const
returns a fuller text description
Definition: LessQuery.h:61
Queries::Query
Base class for all queries.
Definition: Query.h:46
Queries::EqualityQuery::d_val
MatchFuncArgType d_val
Definition: EqualityQuery.h:93