Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:17

0001 #ifndef CommonTools_Utils_BinarySelectorSetter_h
0002 #define CommonTools_Utils_BinarySelectorSetter_h
0003 /* \class reco::parser::BinarySelectorSetter
0004  *
0005  * Binary selector setter
0006  *
0007  * \author original version: Chris Jones, Cornell, 
0008  *         adapted by Luca Lista, INFN
0009  *
0010  * \version $Revision: 1.2 $
0011  *
0012  */
0013 #include "CommonTools/Utils/interface/parser/SelectorStack.h"
0014 #include "CommonTools/Utils/interface/parser/ComparisonStack.h"
0015 #include "CommonTools/Utils/interface/parser/ExpressionStack.h"
0016 #include "CommonTools/Utils/interface/parser/BinarySelector.h"
0017 #include "CommonTools/Utils/interface/parser/Exception.h"
0018 
0019 namespace reco {
0020   namespace parser {
0021     class BinarySelectorSetter {
0022     public:
0023       BinarySelectorSetter(SelectorStack& selStack, ComparisonStack& cmpStack, ExpressionStack& expStack)
0024           : selStack_(selStack), cmpStack_(cmpStack), expStack_(expStack) {}
0025 
0026       void operator()(const char* begin, const char*) const {
0027         if (expStack_.empty())
0028           throw Exception(begin) << "Grammar error: empty expression stack. Please contact developer.";
0029         if (cmpStack_.empty())
0030           throw Exception(begin) << "Grammar error: empty comparator stack. Please contact developer."
0031                                  << "\"";
0032         std::shared_ptr<ExpressionBase> rhs = expStack_.back();
0033         expStack_.pop_back();
0034         std::shared_ptr<ExpressionBase> lhs = expStack_.back();
0035         expStack_.pop_back();
0036         std::shared_ptr<ComparisonBase> comp = cmpStack_.back();
0037         cmpStack_.pop_back();
0038 #ifdef BOOST_SPIRIT_DEBUG
0039         BOOST_SPIRIT_DEBUG_OUT << "pushing binary selector" << std::endl;
0040 #endif
0041         selStack_.push_back(SelectorPtr(new BinarySelector(lhs, comp, rhs)));
0042       }
0043 
0044     private:
0045       SelectorStack& selStack_;
0046       ComparisonStack& cmpStack_;
0047       ExpressionStack& expStack_;
0048     };
0049   }  // namespace parser
0050 }  // namespace reco
0051 
0052 #endif