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 34 of file FWExpressionEvaluator.h.

Constructor & Destructor Documentation

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

Definition at line 37 of file FWExpressionEvaluator.cc.

References setExpression().

38  :
39  m_className(iClassName),
41 {
42  setExpression(iExpression);
43 }
void setExpression(const std::string &)
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:60
FWExpressionEvaluator::~FWExpressionEvaluator ( )
virtual

Definition at line 50 of file FWExpressionEvaluator.cc.

51 {
52 }

Member Function Documentation

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

Definition at line 122 of file FWExpressionEvaluator.cc.

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

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

Definition at line 116 of file FWExpressionEvaluator.cc.

References m_expression.

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

Definition at line 101 of file FWExpressionEvaluator.cc.

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

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

Throws an FWExpressionException if there is a problem

Definition at line 70 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().

71 {
72  if(m_type != edm::TypeWithDict() && iExpression.size()) {
73  using namespace fireworks::expression;
74 
75  //Backwards compatibility with old format
76  std::string temp = oldToNewFormat(iExpression);
77 
78  //now setup the parser
79  using namespace boost::spirit::classic;
81  reco::parser::Grammar grammar(tmpPtr,m_type);
82  try {
83  if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full) {
84  m_expr = tmpPtr;
85  m_expression = iExpression;
86  } else {
87  throw FWExpressionException("syntax error", -1);
88  //std::cout <<"failed to parse "<<iExpression<<" because of syntax error"<<std::endl;
89  }
90  } catch(const reco::parser::BaseException& e) {
91  //NOTE: need to calculate actual position before doing the regex
93  //std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
94  }
95  } else {
96  m_expression=iExpression;
97  }
98 }
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 61 of file FWExpressionEvaluator.h.

Referenced by setClassName().

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

Definition at line 62 of file FWExpressionEvaluator.h.

Referenced by evalExpression(), and setExpression().

std::string FWExpressionEvaluator::m_expression
private

Definition at line 60 of file FWExpressionEvaluator.h.

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

edm::TypeWithDict FWExpressionEvaluator::m_type
private

Definition at line 63 of file FWExpressionEvaluator.h.

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