CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/DetectorDescription/Parser/src/DDLSAX2ExpressionHandler.cc

Go to the documentation of this file.
00001 /***************************************************************************
00002                           DDLSAX2ExpressionHandler.cc  -  description
00003                              -------------------
00004     begin                : Mon Feb 25, 2002
00005     email                : case@ucdhep.ucdavis.edu
00006  ***************************************************************************/
00007 
00008 /***************************************************************************
00009  *                                                                         *
00010  *           DDDParser sub-component of DDD                                *
00011  *                                                                         *
00012  ***************************************************************************/
00013 
00014 #include "DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler.h"
00015 #include "DetectorDescription/Parser/src/StrX.h"
00016 
00017 #include "DetectorDescription/Base/interface/DDdebug.h"
00018 
00019 #include "DetectorDescription/ExprAlgo/interface/ExprEvalSingleton.h"
00020 
00021 #include <iostream>
00022 #include <vector>
00023 #include <string>
00024 
00025 // ---------------------------------------------------------------------------
00026 //  DDLSAX2Handler: Constructors and Destructor
00027 // ---------------------------------------------------------------------------
00028 DDLSAX2ExpressionHandler::DDLSAX2ExpressionHandler( DDCompactView& cpv )
00029   : DDLSAX2FileHandler::DDLSAX2FileHandler( cpv )
00030 {}
00031 
00032 DDLSAX2ExpressionHandler::~DDLSAX2ExpressionHandler( void )
00033 {}
00034 
00035 // This does most of the work, it sets and determines whether it is 
00036 // in a ConstantsSection element, and if so, to process all the 
00037 // constants accordingly.
00038 void
00039 DDLSAX2ExpressionHandler::startElement( const XMLCh* const uri,
00040                                         const XMLCh* const localname,
00041                                         const XMLCh* const qname,
00042                                         const Attributes& attrs )
00043 {
00044   ++elementCount_;
00045   attrCount_ += attrs.getLength();
00046 
00047   pElementName = StrX(qname).localForm();
00048 
00049   if (pElementName == "Constant") 
00050   {
00051     ++elementTypeCounter_[pElementName];
00052     DCOUT_V('P', std::string("DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler: start ") + pElementName);
00053     unsigned int numAtts = attrs.getLength();
00054     std::string varName, varValue;
00055     for (unsigned int i = 0; i < numAtts; ++i)
00056     {
00057       std::string myattname(StrX(attrs.getLocalName(i)).localForm());
00058       std::string myvalue(StrX(attrs.getValue(i)).localForm());
00059 
00060       std::string myQName(StrX(attrs.getQName(i)).localForm());
00061       DCOUT_V('P', std::string("DetectorDescription/Parser/interface/DDLSAX2ExpressionHandler: ") + "getLocalName = " + myattname + "  getValue = " +  myvalue + "   getQName = " + myQName);
00062 
00063       // attributes unit and quantity are not used right now.
00064       if (myattname == "name")
00065         varName = myvalue;
00066       else if (myattname == "value")
00067         varValue = myvalue;
00068     }
00069     //      DDLParser* beingParsed = DDLParser::instance();
00070     //      std::string nmspace = getnmspace(extractFileName( beingParsed->getCurrFileName()));
00071     ExprEvalInterface & ev = ExprEvalSingleton::instance();
00072     ev.set(nmspace_, varName, varValue);
00073   }
00074 }
00075 
00076 void
00077 DDLSAX2ExpressionHandler::endElement( const XMLCh* const uri,
00078                                       const XMLCh* const localname,
00079                                       const XMLCh* const qname )
00080 {}