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 #include "DetectorDescription/Parser/interface/FIPConfiguration.h" 00016 #include "DetectorDescription/Parser/interface/DDLParser.h" 00017 #include "DetectorDescription/Base/interface/DDdebug.h" 00018 00019 #include "FWCore/ParameterSet/interface/FileInPath.h" 00020 00021 #include <iostream> 00022 00023 using namespace XERCES_CPP_NAMESPACE; 00024 00025 FIPConfiguration::FIPConfiguration( DDCompactView& cpv ) 00026 : configHandler_( cpv ), 00027 cpv_( cpv ) 00028 { 00029 // parser_ = DDLParser::instance(); 00030 // std::cout << "Making a FIPConfiguration with configHandler_ at " << &configHandler_ << std::endl; 00031 } 00032 00033 FIPConfiguration::~FIPConfiguration( void ) 00034 { 00035 // parser_->getXMLParser()->setContentHandler(0); 00036 } 00037 00038 const std::vector<std::string>& 00039 FIPConfiguration::getFileList( void ) const 00040 { 00041 return files_; 00042 } 00043 00044 const std::vector<std::string>& 00045 FIPConfiguration::getURLList( void ) const 00046 { 00047 return urls_; 00048 } 00049 00050 bool 00051 FIPConfiguration::doValidation( void ) const 00052 { 00053 return configHandler_.doValidation(); 00054 } 00055 00056 std::string 00057 FIPConfiguration::getSchemaLocation( void ) const 00058 { 00059 return configHandler_.getSchemaLocation(); 00060 } 00061 00062 void 00063 FIPConfiguration::dumpFileList(void) const 00064 { 00065 std::cout << "File List:" << std::endl; 00066 std::cout << " number of files=" << files_.size() << std::endl; 00067 for (std::vector<std::string>::const_iterator it = files_.begin(); it != files_.end(); ++it) 00068 std::cout << *it << std::endl; 00069 } 00070 00071 //----------------------------------------------------------------------- 00072 // Here the Xerces parser is used to process the content of the 00073 // configuration file. 00074 //----------------------------------------------------------------------- 00075 00076 int 00077 FIPConfiguration::readConfig( const std::string& filename, bool fullPath ) 00078 { 00079 std::string absoluteFileName (filename); 00080 if (!fullPath) { 00081 edm::FileInPath fp(filename); 00082 // config file 00083 absoluteFileName = fp.fullPath(); 00084 } 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 DDLParser ddlp(cpv_); 00091 ddlp.getXMLParser()->setContentHandler(&configHandler_); 00092 ddlp.getXMLParser()->parse(absoluteFileName.c_str()); 00093 const std::vector<std::string>& vURLs = configHandler_.getURLs(); 00094 const std::vector<std::string>& vFiles = configHandler_.getFileNames(); 00095 size_t maxInd = vFiles.size(); 00096 size_t ind = 0; 00097 // ea. file listed in the config 00098 for(; ind < maxInd ; ++ind) 00099 { 00100 edm::FileInPath fp(vURLs[ind] + "/" + vFiles[ind]); 00101 // std::cout << "FileInPath says..." << fp.fullPath() << std::endl; 00102 files_.push_back(fp.fullPath()); 00103 urls_.push_back(""); 00104 } 00105 00106 // std::vector<std::string> fnames = configHandler_.getFileNames(); 00107 // std::cout << "there are " << fnames.size() << " files." << std::endl; 00108 // for (size_t i = 0; i < fnames.size(); ++i) 00109 // std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl; 00110 return 0; 00111 } 00112 00113 int 00114 FIPConfiguration::readConfig( const std::string& filename ) 00115 { 00116 return readConfig( filename, false ); 00117 }