CMS 3D CMS Logo

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