OrQuery.h

Go to the documentation of this file.
00001 //
00002 // Copyright (c) 2003-2006 Greg Landrum and Rational Discovery LLC
00003 //
00004 //   @@ All Rights Reserved  @@
00005 //
00006 #ifndef __RD_ORQUERY_H__
00007 #define __RD_ORQUERY_H__
00008 
00009 #include "Query.h"
00010 
00011 namespace Queries {
00012   //! a Query implementing AND: requires any child to be \c true
00013   template <class MatchFuncArgType, class DataFuncArgType=MatchFuncArgType,
00014     bool needsConversion=false>
00015   class OrQuery : public Query<MatchFuncArgType, DataFuncArgType,needsConversion> {
00016 
00017   public:
00018     typedef Query<MatchFuncArgType, DataFuncArgType,needsConversion> BASE;
00019     OrQuery() {
00020       this->df_negate = false;
00021     };
00022 
00023     bool Match(const DataFuncArgType what) const {
00024       bool res = false;
00025       typename BASE::CHILD_VECT_CI it1;
00026       for(it1=this->beginChildren();
00027           it1!=this->endChildren();
00028           ++it1){
00029         bool tmp = (*it1)->Match(what);
00030         if( tmp ){
00031           res = true;
00032           break;
00033         }
00034       }
00035       if( this->getNegation() ) res = !res;
00036       return res;
00037     };
00038 
00039     Query<MatchFuncArgType,DataFuncArgType,needsConversion> *  
00040     copy( ) const {
00041       OrQuery<MatchFuncArgType,DataFuncArgType,needsConversion> *res =
00042         new OrQuery<MatchFuncArgType,DataFuncArgType,needsConversion>();
00043 
00044       typename BASE::CHILD_VECT_CI i;
00045       for(i=this->beginChildren();
00046           i!=this->endChildren();
00047           ++i){
00048         res->addChild(*i);
00049       }
00050       res->setNegation(this->getNegation());
00051       res->d_description = this->d_description;
00052       return res;
00053     };
00054   };
00055 
00056 }
00057 #endif

Generated on Fri Apr 3 06:03:02 2009 for RDCode by  doxygen 1.5.6