CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
FWExpressionEvaluator Class Reference

#include <Fireworks/Core/interface/FWExpressionEvaluator.h>

Public Member Functions

double evalExpression (const void *) const
 
const std::string & expression () const
 
 FWExpressionEvaluator (const std::string &iExpression, const std::string &iClassName)
 
void setClassName (const std::string &)
 
void setExpression (const std::string &)
 
virtual ~FWExpressionEvaluator ()
 

Private Attributes

std::string m_className
 
reco::parser::ExpressionPtr m_expr
 
std::string m_expression
 
edm::TypeWithDict m_type
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 35 of file FWExpressionEvaluator.h.

Constructor & Destructor Documentation

FWExpressionEvaluator::FWExpressionEvaluator ( const std::string &  iExpression,
const std::string &  iClassName 
)

Definition at line 38 of file FWExpressionEvaluator.cc.

References setExpression().

39  :
40  m_className(iClassName),
42 {
43  setExpression(iExpression);
44 }
static TypeWithDict byName(std::string const &className)
void setExpression(const std::string &)
FWExpressionEvaluator::~FWExpressionEvaluator ( )
virtual

Definition at line 51 of file FWExpressionEvaluator.cc.

52 {
53 }

Member Function Documentation

double FWExpressionEvaluator::evalExpression ( const void *  iObject) const

Definition at line 123 of file FWExpressionEvaluator.cc.

References m_expr, m_expression, m_type, and python.connectstrParser::o.

124 {
125  if(m_expression.empty() || !m_expr.get()) {
126  return 0;
127  }
128 
129  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
130  return m_expr->value(o);
131 }
reco::parser::ExpressionPtr m_expr
const std::string & FWExpressionEvaluator::expression ( ) const

Definition at line 117 of file FWExpressionEvaluator.cc.

References m_expression.

118 {
119  return m_expression;
120 }
void FWExpressionEvaluator::setClassName ( const std::string &  iClassName)

Definition at line 102 of file FWExpressionEvaluator.cc.

References edm::TypeWithDict::byName(), m_className, m_expression, m_type, and setExpression().

103 {
104  //NOTE: How do we handle the case where the filter was created before
105  // the library for the class was loaded and therefore we don't have
106  // a dictionary for it?
107 
108  m_className = iClassName;
109  m_type = edm::TypeWithDict::byName(iClassName);
111 }
static TypeWithDict byName(std::string const &className)
void setExpression(const std::string &)
void FWExpressionEvaluator::setExpression ( const std::string &  iExpression)

Throws an FWExpressionException if there is a problem

Definition at line 71 of file FWExpressionEvaluator.cc.

References reco::parser::baseExceptionWhat(), alignCSCRings::e, fireworks::expression::indexFromNewFormatToOldFormat(), m_expr, m_expression, m_type, fireworks::expression::oldToNewFormat(), triggerExpression::parse(), edm::TypeWithDict::size(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

Referenced by FWExpressionEvaluator(), and setClassName().

72 {
73  if(m_type != edm::TypeWithDict() && iExpression.size()) {
74  using namespace fireworks::expression;
75 
76  //Backwards compatibility with old format
77  std::string temp = oldToNewFormat(iExpression);
78 
79  //now setup the parser
80  using namespace boost::spirit::classic;
82  reco::parser::Grammar grammar(tmpPtr,m_type);
83  try {
84  if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full) {
85  m_expr = tmpPtr;
86  m_expression = iExpression;
87  } else {
88  throw FWExpressionException("syntax error", -1);
89  //std::cout <<"failed to parse "<<iExpression<<" because of syntax error"<<std::endl;
90  }
91  } catch(const reco::parser::BaseException& e) {
92  //NOTE: need to calculate actual position before doing the regex
94  //std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
95  }
96  } else {
97  m_expression=iExpression;
98  }
99 }
reco::parser::ExpressionPtr m_expr
long indexFromNewFormatToOldFormat(const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:37
Evaluator * parse(const T &text)
boost::shared_ptr< ExpressionBase > ExpressionPtr
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:40
size_t size() const
std::string oldToNewFormat(const std::string &iExpression)

Member Data Documentation

std::string FWExpressionEvaluator::m_className
private

Definition at line 62 of file FWExpressionEvaluator.h.

Referenced by setClassName().

reco::parser::ExpressionPtr FWExpressionEvaluator::m_expr
private

Definition at line 63 of file FWExpressionEvaluator.h.

Referenced by evalExpression(), and setExpression().

std::string FWExpressionEvaluator::m_expression
private

Definition at line 61 of file FWExpressionEvaluator.h.

Referenced by evalExpression(), expression(), setClassName(), and setExpression().

edm::TypeWithDict FWExpressionEvaluator::m_type
private

Definition at line 64 of file FWExpressionEvaluator.h.

Referenced by evalExpression(), setClassName(), and setExpression().