Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef CommonTools_Utils_TrinarySelectorSetter_h
0002 #define CommonTools_Utils_TrinarySelectorSetter_h
0003 /* \class reco::parser::TrinarySelectorSetter
0004  *
0005  * Trinary 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/TrinarySelector.h"
0017 
0018 namespace reco {
0019   namespace parser {
0020     class TrinarySelectorSetter {
0021     public:
0022       TrinarySelectorSetter(SelectorStack& selStack, ComparisonStack& cmpStack, ExpressionStack& expStack)
0023           : selStack_(selStack), cmpStack_(cmpStack), expStack_(expStack) {}
0024 
0025       void operator()(const char*, const char*) const {
0026         std::shared_ptr<ExpressionBase> rhs = expStack_.back();
0027         expStack_.pop_back();
0028         std::shared_ptr<ExpressionBase> mid = expStack_.back();
0029         expStack_.pop_back();
0030         std::shared_ptr<ExpressionBase> lhs = expStack_.back();
0031         expStack_.pop_back();
0032         std::shared_ptr<ComparisonBase> comp2 = cmpStack_.back();
0033         cmpStack_.pop_back();
0034         std::shared_ptr<ComparisonBase> comp1 = cmpStack_.back();
0035         cmpStack_.pop_back();
0036 #ifdef BOOST_SPIRIT_DEBUG
0037         BOOST_SPIRIT_DEBUG_OUT << "pushing trinary selector" << std::endl;
0038 #endif
0039         selStack_.push_back(SelectorPtr(new TrinarySelector(lhs, comp1, mid, comp2, rhs)));
0040       }
0041 
0042     private:
0043       SelectorStack& selStack_;
0044       ComparisonStack& cmpStack_;
0045       ExpressionStack& expStack_;
0046     };
0047   }  // namespace parser
0048 }  // namespace reco
0049 
0050 #endif