CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/CommonTools/Utils/src/ExpressionSelectorSetter.h

Go to the documentation of this file.
00001 #ifndef CommonTools_Utils_ExpressionSelectorSetter_h
00002 #define CommonTools_Utils_ExpressionSelectorSetter_h
00003 /* \class reco::parser::ExpressionSelectorSetter
00004  *
00005  * Creates an implicit Binary selector setter by comparing an expression to 0
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/ExpressionStack.h"
00015 #include "CommonTools/Utils/src/BinarySelector.h"
00016 #include "CommonTools/Utils/src/ExpressionNumber.h"
00017 #include "CommonTools/Utils/src/Comparison.h"
00018 #include "CommonTools/Utils/interface/Exception.h"
00019 #include <boost/shared_ptr.hpp>
00020 #include <functional>
00021 
00022 namespace reco {
00023   namespace parser {    
00024     class ExpressionSelectorSetter {
00025     public:
00026       ExpressionSelectorSetter(SelectorStack& selStack, ExpressionStack& expStack) : 
00027         selStack_(selStack), expStack_(expStack) { }
00028       
00029       void operator()(const char * begin, const char *) const {
00030         if(expStack_.empty())
00031           throw Exception(begin)
00032             << "Grammar error: empty expression stack. Please contact developer." << "\"";
00033         boost::shared_ptr<ExpressionBase> rhs = expStack_.back(); expStack_.pop_back();
00034         boost::shared_ptr<ExpressionBase> lhs(new ExpressionNumber(0.0));
00035         boost::shared_ptr<ComparisonBase> comp(new Comparison<std::not_equal_to<double> >());
00036 #ifdef BOOST_SPIRIT_DEBUG 
00037         BOOST_SPIRIT_DEBUG_OUT << "pushing expression selector" << std::endl;
00038 #endif
00039         selStack_.push_back(SelectorPtr(new BinarySelector(lhs, comp, rhs)));
00040       }
00041     private:
00042       SelectorStack & selStack_;
00043       ExpressionStack & expStack_;
00044     };
00045   }
00046 }
00047 
00048 #endif