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