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
FWModelFilter Class Reference

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

Public Member Functions

const std::string & expression () const
 
 FWModelFilter (const std::string &iExpression, const std::string &iClassName)
 
bool passesFilter (const void *) const
 
void setClassName (const std::string &)
 
void setExpression (const std::string &)
 
bool trivialFilter () const
 
virtual ~FWModelFilter ()
 

Private Attributes

std::string m_className
 
std::string m_expression
 
reco::parser::SelectorPtr m_selector
 
edm::TypeWithDict m_type
 

Detailed Description

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

Usage: <usage>

Definition at line 32 of file FWModelFilter.h.

Constructor & Destructor Documentation

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

Definition at line 38 of file FWModelFilter.cc.

References setExpression().

39  :
40  m_className(iClassName),
42 {
43  setExpression(iExpression);
44 }
edm::TypeWithDict m_type
Definition: FWModelFilter.h:63
std::string m_className
Definition: FWModelFilter.h:61
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:60
void setExpression(const std::string &)
FWModelFilter::~FWModelFilter ( )
virtual

Definition at line 51 of file FWModelFilter.cc.

52 {
53 }

Member Function Documentation

const std::string & FWModelFilter::expression ( ) const

Definition at line 117 of file FWModelFilter.cc.

References m_expression.

Referenced by FWEventItem::filterExpression().

118 {
119  return m_expression;
120 }
std::string m_expression
Definition: FWModelFilter.h:60
bool FWModelFilter::passesFilter ( const void *  iObject) const

Definition at line 123 of file FWModelFilter.cc.

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

Referenced by FWEventItem::runFilter().

124 {
125  if(m_expression.empty() || !m_selector.get()) {
126  return true;
127  }
128 
129  edm::ObjectWithDict o(m_type, const_cast<void *>(iObject));
130  return (*m_selector)(o);
131 }
reco::parser::SelectorPtr m_selector
Definition: FWModelFilter.h:62
edm::TypeWithDict m_type
Definition: FWModelFilter.h:63
std::string m_expression
Definition: FWModelFilter.h:60
void FWModelFilter::setClassName ( const std::string &  iClassName)

Definition at line 102 of file FWModelFilter.cc.

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

Referenced by FWEventItem::FWEventItem().

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 }
edm::TypeWithDict m_type
Definition: FWModelFilter.h:63
std::string m_className
Definition: FWModelFilter.h:61
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:60
std::string m_expression
Definition: FWModelFilter.h:60
void setExpression(const std::string &)
void FWModelFilter::setExpression ( const std::string &  iExpression)

Throws an FWExpressionException if there is a problem

Definition at line 71 of file FWModelFilter.cc.

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

Referenced by FWModelFilter(), setClassName(), and FWEventItem::setFilterExpression().

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<0>() >> end_p, space_p).full) {
85  m_selector = 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 }
long indexFromNewFormatToOldFormat(const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
reco::parser::SelectorPtr m_selector
Definition: FWModelFilter.h:62
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:37
Evaluator * parse(const T &text)
edm::TypeWithDict m_type
Definition: FWModelFilter.h:63
std::string m_expression
Definition: FWModelFilter.h:60
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:40
boost::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:17
size_t size() const
std::string oldToNewFormat(const std::string &iExpression)
bool FWModelFilter::trivialFilter ( ) const

Definition at line 134 of file FWModelFilter.cc.

References m_expression.

135 {
136  return m_expression.empty();
137 }
std::string m_expression
Definition: FWModelFilter.h:60

Member Data Documentation

std::string FWModelFilter::m_className
private

Definition at line 61 of file FWModelFilter.h.

Referenced by setClassName().

std::string FWModelFilter::m_expression
private

Definition at line 60 of file FWModelFilter.h.

Referenced by expression(), passesFilter(), setClassName(), setExpression(), and trivialFilter().

reco::parser::SelectorPtr FWModelFilter::m_selector
private

Definition at line 62 of file FWModelFilter.h.

Referenced by passesFilter(), and setExpression().

edm::TypeWithDict FWModelFilter::m_type
private

Definition at line 63 of file FWModelFilter.h.

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