Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:55:08

0001 #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
0002 
0003 #include <cstddef>
0004 #include <iostream>
0005 #include <memory>
0006 
0007 #include "DetectorDescription/Parser/interface/DDLParser.h"
0008 #include "FWCore/ParameterSet/interface/FileInPath.h"
0009 #include "xercesc/util/XercesVersion.hpp"
0010 
0011 class DDCompactView;
0012 
0013 using namespace XERCES_CPP_NAMESPACE;
0014 
0015 FIPConfiguration::FIPConfiguration(DDCompactView& cpv) : configHandler_(cpv), cpv_(cpv) {}
0016 
0017 FIPConfiguration::~FIPConfiguration(void) {}
0018 
0019 const std::vector<std::string>& FIPConfiguration::getFileList(void) const { return files_; }
0020 
0021 const std::vector<std::string>& FIPConfiguration::getURLList(void) const { return urls_; }
0022 
0023 bool FIPConfiguration::doValidation(void) const { return configHandler_.doValidation(); }
0024 
0025 std::string FIPConfiguration::getSchemaLocation(void) const { return configHandler_.getSchemaLocation(); }
0026 
0027 void FIPConfiguration::dumpFileList(void) const {
0028   std::cout << "File List:" << std::endl;
0029   std::cout << "  number of files=" << files_.size() << std::endl;
0030   for (const auto& file : files_)
0031     std::cout << file << std::endl;
0032 }
0033 
0034 //-----------------------------------------------------------------------
0035 //  Here the Xerces parser is used to process the content of the
0036 //  configuration file.
0037 //-----------------------------------------------------------------------
0038 
0039 int FIPConfiguration::readConfig(const std::string& filename, bool fullPath) {
0040   std::string absoluteFileName(filename);
0041   if (!fullPath) {
0042     edm::FileInPath fp(filename);
0043     // config file
0044     absoluteFileName = fp.fullPath();
0045   }
0046 
0047   // Set the parser to use the handler for the configuration file.
0048   // This makes sure the Parser is initialized and gets a handle to it.
0049   DDLParser ddlp(cpv_);
0050   ddlp.getXMLParser()->setContentHandler(&configHandler_);
0051   ddlp.getXMLParser()->parse(absoluteFileName.c_str());
0052   const std::vector<std::string>& vURLs = configHandler_.getURLs();
0053   const std::vector<std::string>& vFiles = configHandler_.getFileNames();
0054   size_t maxInd = vFiles.size();
0055   size_t ind = 0;
0056   // ea. file listed in the config
0057   for (; ind < maxInd; ++ind) {
0058     edm::FileInPath fp(vURLs[ind] + "/" + vFiles[ind]);
0059     //    std::cout << "FileInPath says..." << fp.fullPath() << std::endl;
0060     files_.emplace_back(fp.fullPath());
0061     urls_.emplace_back("");
0062   }
0063 
0064   //   std::vector<std::string> fnames = configHandler_.getFileNames();
0065   //   std::cout << "there are " << fnames.size() << " files." << std::endl;
0066   //   for (size_t i = 0; i < fnames.size(); ++i)
0067   //     std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl;
0068   return 0;
0069 }
0070 
0071 int FIPConfiguration::readConfig(const std::string& filename) { return readConfig(filename, false); }