CMS 3D CMS Logo

Public Member Functions | Private Attributes

FWExpressionEvaluator Class Reference

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

List of all members.

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().

                                                                          :
   m_className(iClassName),
   m_type(edm::TypeWithDict::byName(iClassName))
{
   setExpression(iExpression);
}
FWExpressionEvaluator::~FWExpressionEvaluator ( ) [virtual]

Definition at line 51 of file FWExpressionEvaluator.cc.

{
}

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.

{
   if(m_expression.empty() || !m_expr.get()) {
      return 0;
   }

   edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
   return m_expr->value(o);
}
const std::string & FWExpressionEvaluator::expression ( ) const

Definition at line 117 of file FWExpressionEvaluator.cc.

References m_expression.

{
   return m_expression;
}
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().

{
   //NOTE: How do we handle the case where the filter was created before
   // the library for the class was loaded and therefore we don't have
   // a dictionary for it?

   m_className = iClassName;
   m_type = edm::TypeWithDict::byName(iClassName);
   setExpression(m_expression);
}
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().

{
   if(m_type != edm::TypeWithDict() && iExpression.size()) {
      using namespace fireworks::expression;

      //Backwards compatibility with old format
      std::string temp = oldToNewFormat(iExpression);

      //now setup the parser
      using namespace boost::spirit::classic;
      reco::parser::ExpressionPtr tmpPtr;
      reco::parser::Grammar grammar(tmpPtr,m_type);
      try {
         if(parse(temp.c_str(), grammar.use_parser<1>() >> end_p, space_p).full) {
            m_expr = tmpPtr;
            m_expression = iExpression;
         } else {
            throw FWExpressionException("syntax error", -1);
            //std::cout <<"failed to parse "<<iExpression<<" because of syntax error"<<std::endl;
         }
      } catch(const reco::parser::BaseException& e) {
         //NOTE: need to calculate actual position before doing the regex
         throw FWExpressionException(reco::parser::baseExceptionWhat(e), indexFromNewFormatToOldFormat(temp,e.where-temp.c_str(),iExpression));
         //std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
      }
   } else {
      m_expression=iExpression;
   }
}

Member Data Documentation

std::string FWExpressionEvaluator::m_className [private]

Definition at line 62 of file FWExpressionEvaluator.h.

Referenced by setClassName().

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().

Definition at line 64 of file FWExpressionEvaluator.h.

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