PageRenderTime 26ms CodeModel.GetById 12ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 1ms

/DetectorDescription/Parser/src/FIPConfiguration.cc

https://github.com/aivanov-cern/cmssw
C++ | 117 lines | 71 code | 19 blank | 27 comment | 4 complexity | 936d2d979d053d298373cbf92794320d MD5 | raw file
  1
  2/***************************************************************************
  3                          FIPConfiguration.cc  -  description
  4                             -------------------
  5    begin                : Sun Nov 13 2005
  6    email                : case@ucdhep.ucdavis.edu
  7 ***************************************************************************/
  8
  9/***************************************************************************
 10 *                                                                         *
 11 *           FIPConfiguration sub-component of DDD                                *
 12 *                                                                         *
 13 ***************************************************************************/
 14
 15#include "DetectorDescription/Parser/interface/FIPConfiguration.h"
 16#include "DetectorDescription/Parser/interface/DDLParser.h"
 17#include "DetectorDescription/Base/interface/DDdebug.h"
 18
 19#include "FWCore/ParameterSet/interface/FileInPath.h"
 20
 21#include <iostream>
 22
 23using namespace XERCES_CPP_NAMESPACE;
 24
 25FIPConfiguration::FIPConfiguration( DDCompactView& cpv )
 26  : configHandler_( cpv ),
 27    cpv_( cpv )
 28{ 
 29  //  parser_ = DDLParser::instance();
 30  //  std::cout << "Making a FIPConfiguration with configHandler_ at " << &configHandler_ << std::endl;
 31}
 32
 33FIPConfiguration::~FIPConfiguration( void )
 34{
 35  //  parser_->getXMLParser()->setContentHandler(0);  
 36}
 37
 38const std::vector<std::string>&
 39FIPConfiguration::getFileList( void ) const
 40{
 41  return files_;
 42}
 43
 44const std::vector<std::string>&
 45FIPConfiguration::getURLList( void ) const
 46{
 47  return urls_;
 48}
 49
 50bool
 51FIPConfiguration::doValidation( void ) const
 52{
 53  return configHandler_.doValidation();
 54}
 55
 56std::string
 57FIPConfiguration::getSchemaLocation( void ) const
 58{
 59  return configHandler_.getSchemaLocation();
 60}
 61
 62void
 63FIPConfiguration::dumpFileList(void) const
 64{
 65  std::cout << "File List:" << std::endl;
 66  std::cout << "  number of files=" << files_.size() << std::endl;
 67  for (std::vector<std::string>::const_iterator it = files_.begin(); it != files_.end(); ++it)
 68    std::cout << *it << std::endl;
 69}
 70
 71//-----------------------------------------------------------------------
 72//  Here the Xerces parser is used to process the content of the 
 73//  configuration file.
 74//-----------------------------------------------------------------------
 75
 76int
 77FIPConfiguration::readConfig( const std::string& filename, bool fullPath )
 78{
 79  std::string absoluteFileName (filename);
 80  if (!fullPath) {
 81    edm::FileInPath fp(filename);
 82    // config file
 83    absoluteFileName = fp.fullPath();
 84  }
 85
 86  DCOUT('P', "FIPConfiguration::ReadConfig(): started");
 87
 88  // Set the parser to use the handler for the configuration file.
 89  // This makes sure the Parser is initialized and gets a handle to it.
 90  DDLParser ddlp(cpv_);
 91  ddlp.getXMLParser()->setContentHandler(&configHandler_);
 92  ddlp.getXMLParser()->parse(absoluteFileName.c_str());
 93  const std::vector<std::string>& vURLs = configHandler_.getURLs();
 94  const std::vector<std::string>& vFiles = configHandler_.getFileNames();
 95  size_t maxInd = vFiles.size();
 96  size_t ind = 0;
 97  // ea. file listed in the config
 98  for(; ind < maxInd ; ++ind)
 99  {
100    edm::FileInPath fp(vURLs[ind] + "/" + vFiles[ind]);
101    //    std::cout << "FileInPath says..." << fp.fullPath() << std::endl;
102    files_.push_back(fp.fullPath());
103    urls_.push_back("");
104  }
105
106  //   std::vector<std::string> fnames = configHandler_.getFileNames();
107  //   std::cout << "there are " << fnames.size() << " files." << std::endl;
108  //   for (size_t i = 0; i < fnames.size(); ++i)
109  //     std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl;
110  return 0;
111}
112
113int
114FIPConfiguration::readConfig( const std::string& filename )
115{
116  return readConfig( filename, false );
117}