CMS 3D CMS Logo

ExpressionSelectorSetter.h
Go to the documentation of this file.
1 #ifndef CommonTools_Utils_ExpressionSelectorSetter_h
2 #define CommonTools_Utils_ExpressionSelectorSetter_h
3 /* \class reco::parser::ExpressionSelectorSetter
4  *
5  * Creates an implicit Binary selector setter by comparing an expression to 0
6  *
7  * \author original version: Chris Jones, Cornell,
8  * adapted by Luca Lista, INFN
9  *
10  * \version $Revision: 1.2 $
11  *
12  */
19 
20 #include <functional>
21 
22 namespace reco {
23  namespace parser {
25  public:
27  : selStack_(selStack), expStack_(expStack) {}
28 
29  void operator()(const char* begin, const char*) const {
30  if (expStack_.empty())
31  throw Exception(begin) << "Grammar error: empty expression stack. Please contact developer."
32  << "\"";
33  std::shared_ptr<ExpressionBase> rhs = expStack_.back();
34  expStack_.pop_back();
35  std::shared_ptr<ExpressionBase> lhs(new ExpressionNumber(0.0));
36  std::shared_ptr<ComparisonBase> comp(new Comparison<std::not_equal_to<double> >());
37 #ifdef BOOST_SPIRIT_DEBUG
38  BOOST_SPIRIT_DEBUG_OUT << "pushing expression selector" << std::endl;
39 #endif
40  selStack_.push_back(SelectorPtr(new BinarySelector(lhs, comp, rhs)));
41  }
42 
43  private:
46  };
47  } // namespace parser
48 } // namespace reco
49 
50 #endif
std::vector< std::shared_ptr< ExpressionBase > > ExpressionStack
void operator()(const char *begin, const char *) const
std::vector< SelectorPtr > SelectorStack
Definition: SelectorStack.h:18
fixed size matrix
ExpressionSelectorSetter(SelectorStack &selStack, ExpressionStack &expStack)
std::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:18