CMS 3D CMS Logo

FIPConfiguration.cc

Go to the documentation of this file.
00001 
00002 /***************************************************************************
00003                           FIPConfiguration.cc  -  description
00004                              -------------------
00005     begin                : Sun Nov 13 2005
00006     email                : case@ucdhep.ucdavis.edu
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *           FIPConfiguration sub-component of DDD                                *
00012  *                                                                         *
00013  ***************************************************************************/
00014 
00015 //--------------------------------------------------------------------------
00016 //  Includes
00017 //--------------------------------------------------------------------------
00018 // Parser parts
00019 #include "DetectorDescription/Parser/interface/FIPConfiguration.h"
00020 #include "DetectorDescription/Parser/interface/DDLParser.h"
00021 #include "DetectorDescription/Parser/interface/DDLSAX2ConfigHandler.h"
00022 #include "StrX.h"
00023 #include "DetectorDescription/Base/interface/DDdebug.h"
00024 #include "DetectorDescription/Base/interface/DDException.h"
00025 
00026 
00027 // Xerces dependencies
00028 #include <xercesc/util/PlatformUtils.hpp>
00029 #include <xercesc/sax2/SAX2XMLReader.hpp>
00030 #include <xercesc/sax2/XMLReaderFactory.hpp>
00031 #include <xercesc/sax/SAXException.hpp>
00032 
00033 // EDM Dependencies
00034 #include "FWCore/ParameterSet/interface/FileInPath.h"
00035 #include "FWCore/Utilities/interface/EDMException.h"
00036 
00037 // STL
00038 #include <string>
00039 #include <iostream>
00040 #include <map>
00041 
00042 
00043 using namespace xercesc_2_7;
00044 
00045 //--------------------------------------------------------------------------
00046 //  FIPConfiguration:  Default constructor and destructor.
00047 //--------------------------------------------------------------------------
00048 FIPConfiguration::~FIPConfiguration()
00049 {
00050   //  parser_->getXMLParser()->setContentHandler(0);  
00051 }
00052 
00053 FIPConfiguration::FIPConfiguration() : configHandler_()
00054 { 
00055   parser_ = DDLParser::instance();
00056   //  std::cout << "Making a FIPConfiguration with configHandler_ at " << &configHandler_ << std::endl;
00057 }
00058 
00059 const std::vector<std::string>&  FIPConfiguration::getFileList(void) const
00060 {
00061   return files_;
00062 }
00063 
00064 const std::vector<std::string>&  FIPConfiguration::getURLList(void) const
00065 {
00066   return urls_;
00067 }
00068 
00069 bool FIPConfiguration::doValidation() const { return configHandler_.doValidation(); }
00070 
00071 std::string FIPConfiguration::getSchemaLocation() const { return configHandler_.getSchemaLocation(); }
00072 
00073 void FIPConfiguration::dumpFileList(void) const {
00074   std::cout << "File List:" << std::endl;
00075   std::cout << "  number of files=" << files_.size() << std::endl;
00076   for (std::vector<std::string>::const_iterator it = files_.begin(); it != files_.end(); ++it)
00077     std::cout << *it << std::endl;
00078 }
00079 
00080 //-----------------------------------------------------------------------
00081 //  Here the Xerces parser is used to process the content of the 
00082 //  configuration file.
00083 //-----------------------------------------------------------------------
00084 int FIPConfiguration::readConfig(const std::string& filename)
00085 {
00086   DCOUT('P', "FIPConfiguration::ReadConfig(): started");
00087 
00088   // Set the parser to use the handler for the configuration file.
00089   // This makes sure the Parser is initialized and gets a handle to it.
00090   parser_->getXMLParser()->setContentHandler(&configHandler_);
00091   edm::FileInPath fp(filename);
00092   // config file
00093   std::string absoluteFileName (filename);
00094   absoluteFileName = fp.fullPath();
00095   parser_->getXMLParser()->parse(absoluteFileName.c_str());
00096   const std::vector<std::string>& vURLs = configHandler_.getURLs();
00097   const std::vector<std::string>& vFiles = configHandler_.getFileNames();
00098   size_t maxInd = vFiles.size();
00099   size_t ind = 0;
00100   // ea. file listed in the config
00101   for(; ind < maxInd ; ++ind) {
00102     edm::FileInPath fp(vURLs[ind] + "/" + vFiles[ind]);
00103     //    std::cout << "FileInPath says..." << fp.fullPath() << std::endl;
00104     files_.push_back(fp.fullPath());
00105     urls_.push_back("");
00106   }
00107 
00108   //   std::vector<std::string> fnames = configHandler_.getFileNames();
00109   //   std::cout << "there are " << fnames.size() << " files." << std::endl;
00110   //   for (size_t i = 0; i < fnames.size(); ++i)
00111   //     std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl;
00112   return 0;
00113 }

Generated on Tue Jun 9 17:32:25 2009 for CMSSW by  doxygen 1.5.4