Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __RD_EQUALITYQUERY_H__
00011 #define __RD_EQUALITYQUERY_H__
00012 #include "Query.h"
00013
00014 namespace Queries {
00015
00016
00017
00018
00019 template <typename MatchFuncArgType, typename DataFuncArgType=MatchFuncArgType,
00020 bool needsConversion=false>
00021 class EqualityQuery : public Query<MatchFuncArgType, DataFuncArgType,needsConversion> {
00022
00023 public:
00024 EqualityQuery() : d_tol(0) {
00025 this->df_negate=false;
00026 };
00027
00028
00029 explicit EqualityQuery(MatchFuncArgType v) : d_val(v), d_tol(0) {
00030 this->df_negate=false;
00031 };
00032
00033
00034
00035 EqualityQuery(MatchFuncArgType v,MatchFuncArgType t) : d_val(v), d_tol(t) {
00036 this->df_negate=false;
00037 };
00038
00039
00040
00041 void setVal(MatchFuncArgType what) { this->d_val = what; };
00042
00043 const MatchFuncArgType getVal() const { return this->d_val; };
00044
00045
00046 void setTol(MatchFuncArgType what) { this->d_tol = what; };
00047
00048 const MatchFuncArgType getTol() const { return this->d_tol; };
00049
00050 virtual bool Match(const DataFuncArgType what) const {
00051 MatchFuncArgType mfArg = this->TypeConvert(what,Int2Type<needsConversion>());
00052 if( queryCmp(this->d_val,mfArg,this->d_tol) == 0 ){
00053 if( this->getNegation() ){
00054 return false;
00055 }
00056 else{
00057 return true;
00058 }
00059 } else {
00060 if( this->getNegation() ){
00061 return true;
00062 }
00063 else{
00064 return false;
00065 }
00066 }
00067 };
00068
00069 virtual Query<MatchFuncArgType,DataFuncArgType,needsConversion> *
00070 copy( ) const {
00071 EqualityQuery<MatchFuncArgType,DataFuncArgType,needsConversion> *res =
00072 new EqualityQuery<MatchFuncArgType,DataFuncArgType,needsConversion>();
00073 res->setNegation(this->getNegation());
00074 res->setVal(this->d_val);
00075 res->setTol(this->d_tol);
00076 res->setDataFunc(this->d_dataFunc);
00077 res->d_description = this->d_description;
00078 return res;
00079 };
00080
00081 protected:
00082 MatchFuncArgType d_val;
00083 MatchFuncArgType d_tol;
00084 };
00085
00086 }
00087 #endif