CMS 3D CMS Logo

Public Member Functions | Private Member Functions

FWModelExpressionSelector Class Reference

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

List of all members.

Public Member Functions

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

Private Member Functions

 FWModelExpressionSelector (const FWModelExpressionSelector &)
const FWModelExpressionSelectoroperator= (const FWModelExpressionSelector &)

Detailed Description

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

Usage: <usage>

Definition at line 30 of file FWModelExpressionSelector.h.


Constructor & Destructor Documentation

FWModelExpressionSelector::FWModelExpressionSelector ( ) [inline]

Definition at line 34 of file FWModelExpressionSelector.h.

                               {
   }
FWModelExpressionSelector::FWModelExpressionSelector ( const FWModelExpressionSelector ) [private]

Member Function Documentation

const FWModelExpressionSelector& FWModelExpressionSelector::operator= ( const FWModelExpressionSelector ) [private]
void FWModelExpressionSelector::select ( FWEventItem iItem,
const std::string &  iExpression,
Color_t  c = -1 
) const

Throws an FWExpressionException if there is a problem

Definition at line 74 of file FWModelExpressionSelector.cc.

References reco::parser::baseExceptionWhat(), FWEventItem::changeManager(), alignCSCRings::e, getHLTprescales::index, fireworks::expression::indexFromNewFormatToOldFormat(), FWEventItem::modelData(), FWEventItem::modelInfo(), FWEventItem::modelType(), python::connectstrParser::o, fireworks::expression::oldToNewFormat(), triggerExpression::parse(), FWEventItem::select(), FWDisplayProperties::setColor(), FWEventItem::setDisplayProperties(), FWEventItem::size(), and groupFilesInBlocks::temp.

Referenced by CmsShowEDI::runSelection().

{
   using namespace fireworks::expression;

   ROOT::Reflex::Type type= ROOT::Reflex::Type::ByName(iItem->modelType()->GetName());
   assert(type != ROOT::Reflex::Type());

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

   //now setup the parser
   using namespace boost::spirit::classic;
   reco::parser::SelectorPtr selectorPtr;
   reco::parser::Grammar grammar(selectorPtr,type);
   try {
      if(!parse(temp.c_str(), grammar.use_parser<0>() >> end_p, space_p).full) {
         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;
   }


   FWChangeSentry sentry(*(iItem->changeManager()));
   for( unsigned int index = 0; index < iItem->size(); ++index ) {
      ROOT::Reflex::Object o(type, const_cast<void *>(iItem->modelData(index)));

      if((*selectorPtr)(o)) {
         iItem->select(index);

         if (iColor > 0) {
            FWDisplayProperties props = iItem->modelInfo(index).displayProperties();
            props.setColor(iColor);
            iItem->setDisplayProperties(index, props);
         }
      }
   }
}