CMS 3D CMS Logo

FWModelExpressionSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWModelExpressionSelector
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Wed Jan 23 10:37:22 EST 2008
11 //
12 
13 // system include files
14 #include <sstream>
15 #include "TClass.h"
18 
21 
22 // user include files
28 //
29 // constants, enums and typedefs
30 //
31 
32 //
33 // static data member definitions
34 //
35 
36 //
37 // constructors and destructor
38 //
39 /*
40  FWModelExpressionSelector::FWModelExpressionSelector()
41  {
42  }
43  */
44 // FWModelExpressionSelector::FWModelExpressionSelector(const FWModelExpressionSelector& rhs)
45 // {
46 // // do actual copying here;
47 // }
48 
49 /*FWModelExpressionSelector::~FWModelExpressionSelector()
50  {
51  }
52  */
53 //
54 // assignment operators
55 //
56 // const FWModelExpressionSelector& FWModelExpressionSelector::operator=(const FWModelExpressionSelector& rhs)
57 // {
58 // //An exception safe implementation is
59 // FWModelExpressionSelector temp(rhs);
60 // swap(rhs);
61 //
62 // return *this;
63 // }
64 
65 //
66 // member functions
67 //
68 
69 //
70 // const member functions
71 //
72 void FWModelExpressionSelector::select(FWEventItem* iItem, const std::string& iExpression, Color_t iColor) const {
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 }
110 
111 //
112 // static member functions
113 //
FWModelChangeManager.h
edm::TypeWithDict::byName
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
FWModelExpressionSelector.h
FWEventItem::modelInfo
ModelInfo modelInfo(int iIndex) const
Definition: FWEventItem.cc:446
reco::parser::baseExceptionWhat
const char * baseExceptionWhat(const BaseException &e)
returns the appropriate 'what' message for the exception
Definition: Exception.h:36
fireworks::expression::oldToNewFormat
std::string oldToNewFormat(const std::string &iExpression)
Definition: expressionFormatHelpers.cc:25
boost::spirit::classic
Definition: DDPartSelection.cc:10
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
FWExpressionException.h
cms::cuda::assert
assert(be >=bs)
FWEventItem::modelData
const void * modelData(int iIndex) const
Definition: FWEventItem.cc:466
TypeWithDict.h
FWExpressionException
Definition: FWExpressionException.h:28
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
FWEventItem::select
void select(int iIndex) const
Definition: FWEventItem.cc:224
FWEventItem::changeManager
FWModelChangeManager * changeManager() const
Definition: FWEventItem.h:123
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:36
ObjectWithDict.h
Exception.h
FWChangeSentry
Definition: FWModelChangeManager.h:68
FWEventItem::modelType
const TClass * modelType() const
Definition: FWEventItem.cc:464
FWModelExpressionSelector::select
void select(FWEventItem *iItem, const std::string &iExpression, Color_t iColor=-1) const
Definition: FWModelExpressionSelector.cc:72
expressionFormatHelpers.h
fireworks::expression
Definition: expressionFormatHelpers.cc:24
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
dumpparser.parse
def parse(path, config)
Definition: dumpparser.py:13
edm::TypeWithDict
Definition: TypeWithDict.h:38
FWDisplayProperties::setColor
void setColor(Color_t iColor)
Definition: FWDisplayProperties.h:62
reco::parser::BaseException
boost::spirit::classic::parser_error< reco::parser::SyntaxErrors > BaseException
Definition: Exception.h:33
fireworks::expression::indexFromNewFormatToOldFormat
long indexFromNewFormatToOldFormat(const std::string &iNewFormat, long iNewFormatIndex, const std::string &iOldFormat)
Definition: expressionFormatHelpers.cc:33
FWEventItem::setDisplayProperties
void setDisplayProperties(int iIndex, const FWDisplayProperties &) const
Definition: FWEventItem.cc:247
reco::parser::Grammar
Definition: Grammar.h:45
FWEventItem.h
FWEventItem::ModelInfo::displayProperties
const FWDisplayProperties & displayProperties() const
Definition: FWEventItem.h:64
FWDisplayProperties
Definition: FWDisplayProperties.h:28
FWEventItem
Definition: FWEventItem.h:56
type
type
Definition: HCALResponse.h:21
reco::parser::SelectorPtr
std::shared_ptr< SelectorBase > SelectorPtr
Definition: SelectorPtr.h:18
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
FWEventItem::size
size_t size() const
Definition: FWEventItem.cc:457
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
Grammar.h