Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:51:48

0001 #ifndef DETECTOR_DESCRIPTION_PARSER_DDL_SAX2_FILE_HANDLER_H
0002 #define DETECTOR_DESCRIPTION_PARSER_DDL_SAX2_FILE_HANDLER_H
0003 
0004 #include <cstddef>
0005 #include <map>
0006 #include <string>
0007 #include <vector>
0008 #include <xercesc/sax2/Attributes.hpp>
0009 
0010 #include "DetectorDescription/Core/interface/DDCompactView.h"
0011 #include "DetectorDescription/Core/interface/DDName.h"
0012 #include "DetectorDescription/Parser/interface/DDLElementRegistry.h"
0013 #include "DetectorDescription/Parser/interface/DDLSAX2Handler.h"
0014 
0015 class DDCompactView;
0016 class DDLElementRegistry;
0017 
0018 /// DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file.
0019 /** @class DDLSAX2FileHandler
0020  * @author Michael Case
0021  *
0022  *  DDLSAX2FileHandler.h  -  description
0023  *  -------------------
0024  *  begin: Tue Oct 23 2001
0025  *
0026  *  DDLSAX2FileHandler has the same structure as the DDLSAX2ConfigHandler as they
0027  *  both inherit from DDLSAX2Handler which inherits from Xerces C++ DefaultHandler.
0028  *  SAX2 is event driven.  So, when the start of an element is encountered in the 
0029  *  XML, then a call is made to the handler's startElement.  The same for endElement.
0030  * 
0031  *  The design of DDXMLElement allows for processing whichever type of Element the
0032  *  XML Parser encounters.
0033  *
0034  */
0035 class DDLSAX2FileHandler : public DDLSAX2Handler {
0036 public:
0037   DDLSAX2FileHandler(DDCompactView& cpv, DDLElementRegistry&);
0038   ~DDLSAX2FileHandler() override;
0039 
0040   void init();
0041 
0042   // -----------------------------------------------------------------------
0043   //  Handlers for the SAX ContentHandler interface
0044   // -----------------------------------------------------------------------
0045 
0046   void startElement(const XMLCh* uri, const XMLCh* localname, const XMLCh* qname, const Attributes& attrs) override;
0047   void endElement(const XMLCh* uri, const XMLCh* localname, const XMLCh* qname) override;
0048   void characters(const XMLCh* chars, XMLSize_t length) override;
0049   void comment(const XMLCh* chars, XMLSize_t length) override;
0050 
0051   //! creates all DDConstant from the evaluator which has been already 'filled' in the first scan of the documents
0052   void createDDConstants() const;
0053 
0054 protected:
0055   DDLElementRegistry& registry() { return registry_; }
0056 
0057 private:
0058   virtual const std::string& parent() const;
0059   virtual const std::string& self() const;
0060 
0061 private:
0062   std::vector<std::string> namesMap_;
0063   std::vector<size_t> names_;
0064   DDCompactView& cpv_;
0065   DDLElementRegistry& registry_;
0066 };
0067 
0068 #endif