00001 #ifndef CommonTools_Utils_BinarySelectorSetter_h 00002 #define CommonTools_Utils_BinarySelectorSetter_h 00003 /* \class reco::parser::BinarySelectorSetter 00004 * 00005 * Binary selector setter 00006 * 00007 * \author original version: Chris Jones, Cornell, 00008 * adapted to Reflex by Luca Lista, INFN 00009 * 00010 * \version $Revision: 1.1 $ 00011 * 00012 */ 00013 #include "CommonTools/Utils/src/SelectorStack.h" 00014 #include "CommonTools/Utils/src/ComparisonStack.h" 00015 #include "CommonTools/Utils/src/ExpressionStack.h" 00016 #include "CommonTools/Utils/src/BinarySelector.h" 00017 #include "CommonTools/Utils/interface/Exception.h" 00018 #include <boost/shared_ptr.hpp> 00019 00020 namespace reco { 00021 namespace parser { 00022 class BinarySelectorSetter { 00023 public: 00024 BinarySelectorSetter(SelectorStack& selStack, 00025 ComparisonStack& cmpStack, ExpressionStack& expStack) : 00026 selStack_(selStack), cmpStack_(cmpStack), expStack_(expStack) { } 00027 00028 void operator()(const char * begin, const char *) const { 00029 if(expStack_.empty()) 00030 throw Exception(begin) 00031 << "Grammar error: empty expression stack. Please contact developer."; 00032 if(cmpStack_.empty()) 00033 throw Exception(begin) 00034 << "Grammar error: empty comparator stack. Please contact developer." << "\""; 00035 boost::shared_ptr<ExpressionBase> rhs = expStack_.back(); expStack_.pop_back(); 00036 boost::shared_ptr<ExpressionBase> lhs = expStack_.back(); expStack_.pop_back(); 00037 boost::shared_ptr<ComparisonBase> comp = cmpStack_.back(); cmpStack_.pop_back(); 00038 #ifdef BOOST_SPIRIT_DEBUG 00039 BOOST_SPIRIT_DEBUG_OUT << "pushing binary selector" << std::endl; 00040 #endif 00041 selStack_.push_back(SelectorPtr(new BinarySelector(lhs, comp, rhs))); 00042 } 00043 private: 00044 SelectorStack & selStack_; 00045 ComparisonStack & cmpStack_; 00046 ExpressionStack & expStack_; 00047 }; 00048 } 00049 } 00050 00051 #endif