File indexing completed on 2024-04-06 12:11:41
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #include <sstream>
0015 #include "TClass.h"
0016 #include "FWCore/Reflection/interface/ObjectWithDict.h"
0017 #include "FWCore/Reflection/interface/TypeWithDict.h"
0018
0019 #include "CommonTools/Utils/interface/parser/Grammar.h"
0020 #include "CommonTools/Utils/interface/parser/Exception.h"
0021
0022
0023 #include "Fireworks/Core/interface/FWModelExpressionSelector.h"
0024 #include "Fireworks/Core/interface/FWEventItem.h"
0025 #include "Fireworks/Core/interface/FWModelChangeManager.h"
0026 #include "Fireworks/Core/interface/FWExpressionException.h"
0027 #include "Fireworks/Core/src/expressionFormatHelpers.h"
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072 void FWModelExpressionSelector::select(FWEventItem* iItem, const std::string& iExpression, Color_t iColor) const {
0073 using namespace fireworks::expression;
0074
0075 edm::TypeWithDict type(edm::TypeWithDict::byName(iItem->modelType()->GetName()));
0076 assert(type != edm::TypeWithDict());
0077
0078
0079 std::string temp = oldToNewFormat(iExpression);
0080
0081
0082 using namespace boost::spirit::classic;
0083 reco::parser::SelectorPtr selectorPtr;
0084 reco::parser::Grammar grammar(selectorPtr, type);
0085 try {
0086 if (!parse(temp.c_str(), grammar.use_parser<0>() >> end_p, space_p).full) {
0087 throw FWExpressionException("syntax error", -1);
0088
0089 }
0090 } catch (const reco::parser::BaseException& e) {
0091
0092 throw FWExpressionException(reco::parser::baseExceptionWhat(e),
0093 indexFromNewFormatToOldFormat(temp, e.where - temp.c_str(), iExpression));
0094
0095 }
0096
0097 FWChangeSentry sentry(*(iItem->changeManager()));
0098 for (unsigned int index = 0; index < iItem->size(); ++index) {
0099 edm::ObjectWithDict o(type, const_cast<void*>(iItem->modelData(index)));
0100 if ((*selectorPtr)(o)) {
0101 iItem->select(index);
0102 if (iColor > 0) {
0103 FWDisplayProperties props = iItem->modelInfo(index).displayProperties();
0104 props.setColor(iColor);
0105 iItem->setDisplayProperties(index, props);
0106 }
0107 }
0108 }
0109 }
0110
0111
0112
0113