CMS 3D CMS Logo

List of all members | Public Member Functions
FWModelExpressionSelector Class Reference

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

Public Member Functions

 FWModelExpressionSelector ()
 
 FWModelExpressionSelector (const FWModelExpressionSelector &)=delete
 
const FWModelExpressionSelectoroperator= (const FWModelExpressionSelector &)=delete
 
void select (FWEventItem *iItem, const std::string &iExpression, Color_t iColor=-1) const
 

Detailed Description

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

Usage: <usage>

Definition at line 30 of file FWModelExpressionSelector.h.

Constructor & Destructor Documentation

◆ FWModelExpressionSelector() [1/2]

FWModelExpressionSelector::FWModelExpressionSelector ( )
inline

Definition at line 32 of file FWModelExpressionSelector.h.

32 {}

◆ FWModelExpressionSelector() [2/2]

FWModelExpressionSelector::FWModelExpressionSelector ( const FWModelExpressionSelector )
delete

Member Function Documentation

◆ operator=()

const FWModelExpressionSelector& FWModelExpressionSelector::operator= ( const FWModelExpressionSelector )
delete

◆ select()

void FWModelExpressionSelector::select ( FWEventItem iItem,
const std::string &  iExpression,
Color_t  iColor = -1 
) const

Throws an FWExpressionException if there is a problem

Definition at line 72 of file FWModelExpressionSelector.cc.

References cms::cuda::assert(), reco::parser::baseExceptionWhat(), edm::TypeWithDict::byName(), FWEventItem::changeManager(), FWEventItem::ModelInfo::displayProperties(), MillePedeFileConverter_cfg::e, fireworks::expression::indexFromNewFormatToOldFormat(), FWEventItem::modelData(), FWEventItem::modelInfo(), FWEventItem::modelType(), EcalTangentSkim_cfg::o, fireworks::expression::oldToNewFormat(), parse(), FWEventItem::select(), FWDisplayProperties::setColor(), FWEventItem::setDisplayProperties(), FWEventItem::size(), AlCaHLTBitMon_QueryRunRegistry::string, and groupFilesInBlocks::temp.

72  {
73  using namespace fireworks::expression;
74 
77 
78  //Backwards compatibility with old format
79  std::string temp = oldToNewFormat(iExpression);
80 
81  //now setup the parser
82  using namespace boost::spirit::classic;
83  reco::parser::SelectorPtr selectorPtr;
84  reco::parser::Grammar grammar(selectorPtr, type);
85  try {
86  if (!parse(temp.c_str(), grammar.use_parser<0>() >> end_p, space_p).full) {
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  indexFromNewFormatToOldFormat(temp, e.where - temp.c_str(), iExpression));
94  //std::cout <<"failed to parse "<<iExpression<<" because "<<reco::parser::baseExceptionWhat(e)<<std::endl;
95  }
96 
97  FWChangeSentry sentry(*(iItem->changeManager()));
98  for (unsigned int index = 0; index < iItem->size(); ++index) {
99  edm::ObjectWithDict o(type, const_cast<void*>(iItem->modelData(index)));
100  if ((*selectorPtr)(o)) {
101  iItem->select(index);
102  if (iColor > 0) {
104  props.setColor(iColor);
105  iItem->setDisplayProperties(index, props);
106  }
107  }
108  }
109 }
size_t size() const
Definition: FWEventItem.cc:457
long indexFromNewFormatToOldFormat(const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
vector< string > parse(string line, const string &delimiter)
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
void setColor(Color_t iColor)
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:33
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:123
assert(be >=bs)
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
void select(int iIndex) const
Definition: FWEventItem.cc:224
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
const TClass * modelType() const
Definition: FWEventItem.cc:464
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate &#39;what&#39; message for the exception
Definition: Exception.h:36
std::string oldToNewFormat(const std::string &iExpression)
void setDisplayProperties(int iIndex, const FWDisplayProperties &) const
Definition: FWEventItem.cc:247
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
std::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:18