00001
00002
00003
00004
00005
00006 #ifndef __RD_XORQUERY_H__
00007 #define __RD_XORQUERY_H__
00008
00009 #include "Query.h"
00010
00011 namespace Queries{
00012
00013
00014 template <class MatchFuncArgType, class DataFuncArgType=MatchFuncArgType,
00015 bool needsConversion=false>
00016 class XOrQuery : public Query<MatchFuncArgType, DataFuncArgType,needsConversion> {
00017
00018 public:
00019 typedef Query<MatchFuncArgType, DataFuncArgType,needsConversion> BASE;
00020 XOrQuery() {
00021 this->df_negate = false;
00022 };
00023
00024 bool Match(const DataFuncArgType what) const {
00025 bool res = false;
00026 typename BASE::CHILD_VECT_CI it1;
00027 for(it1=this->beginChildren();
00028 it1!=this->endChildren();
00029 ++it1){
00030 bool tmp = (*it1)->Match(what);
00031 if( tmp ){
00032 if( res ){
00033 res = false;
00034 break;
00035 } else{
00036 res = true;
00037 }
00038 }
00039 }
00040 if( this->getNegation() ) res = !res;
00041 return res;
00042 };
00043
00044 Query<MatchFuncArgType,DataFuncArgType,needsConversion> *
00045 copy( ) const {
00046 XOrQuery<MatchFuncArgType,DataFuncArgType,needsConversion> *res =
00047 new XOrQuery<MatchFuncArgType,DataFuncArgType,needsConversion>();
00048
00049 typename BASE::CHILD_VECT_CI i;
00050 for(i=this->beginChildren();
00051 i!=this->endChildren();
00052 ++i){
00053 res->addChild(*i);
00054 }
00055 res->setNegation(this->getNegation());
00056 res->d_description = this->d_description;
00057 return res;
00058 };
00059 };
00060
00061 }
00062 #endif