00001 #ifndef Utilities_TrinarySelectorSetter_h 00002 #define Utilities_TrinarySelectorSetter_h 00003 /* \class reco::parser::TrinarySelectorSetter 00004 * 00005 * Trinary selector setter 00006 * 00007 * \author original version: Chris Jones, Cornell, 00008 * adapted to Reflex by Luca Lista, INFN 00009 * 00010 * \version $Revision: 1.2 $ 00011 * 00012 */ 00013 #include "PhysicsTools/Utilities/src/SelectorStack.h" 00014 #include "PhysicsTools/Utilities/src/ComparisonStack.h" 00015 #include "PhysicsTools/Utilities/src/ExpressionStack.h" 00016 #include "PhysicsTools/Utilities/src/TrinarySelector.h" 00017 #include <boost/shared_ptr.hpp> 00018 00019 namespace reco { 00020 namespace parser { 00021 class TrinarySelectorSetter { 00022 public: 00023 TrinarySelectorSetter(SelectorStack& selStack, 00024 ComparisonStack& cmpStack, 00025 ExpressionStack& expStack) : 00026 selStack_(selStack), cmpStack_(cmpStack), expStack_(expStack) { } 00027 00028 void operator()(const char *, const char *) const { 00029 boost::shared_ptr<ExpressionBase> rhs = expStack_.back(); expStack_.pop_back(); 00030 boost::shared_ptr<ExpressionBase> mid = expStack_.back(); expStack_.pop_back(); 00031 boost::shared_ptr<ExpressionBase> lhs = expStack_.back(); expStack_.pop_back(); 00032 boost::shared_ptr<ComparisonBase> comp2 = cmpStack_.back(); cmpStack_.pop_back(); 00033 boost::shared_ptr<ComparisonBase> comp1 = cmpStack_.back(); cmpStack_.pop_back(); 00034 #ifdef BOOST_SPIRIT_DEBUG 00035 BOOST_SPIRIT_DEBUG_OUT << "pushing trinary selector" << std::endl; 00036 #endif 00037 selStack_.push_back(SelectorPtr(new TrinarySelector(lhs, comp1, mid, comp2, rhs))); 00038 } 00039 private: 00040 SelectorStack& selStack_; 00041 ComparisonStack& cmpStack_; 00042 ExpressionStack& expStack_; 00043 }; 00044 } 00045 } 00046 00047 #endif