CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FIPConfiguration.cc
Go to the documentation of this file.
2 
3 #include <cstddef>
4 #include <iostream>
5 #include <memory>
6 
9 #include "xercesc/util/XercesVersion.hpp"
10 
11 class DDCompactView;
12 
13 using namespace XERCES_CPP_NAMESPACE;
14 
15 FIPConfiguration::FIPConfiguration(DDCompactView& cpv) : configHandler_(cpv), cpv_(cpv) {}
16 
18 
19 const std::vector<std::string>& FIPConfiguration::getFileList(void) const { return files_; }
20 
21 const std::vector<std::string>& FIPConfiguration::getURLList(void) const { return urls_; }
22 
24 
26 
28  std::cout << "File List:" << std::endl;
29  std::cout << " number of files=" << files_.size() << std::endl;
30  for (const auto& file : files_)
31  std::cout << file << std::endl;
32 }
33 
34 //-----------------------------------------------------------------------
35 // Here the Xerces parser is used to process the content of the
36 // configuration file.
37 //-----------------------------------------------------------------------
38 
40  std::string absoluteFileName(filename);
41  if (!fullPath) {
42  edm::FileInPath fp(filename);
43  // config file
44  absoluteFileName = fp.fullPath();
45  }
46 
47  // Set the parser to use the handler for the configuration file.
48  // This makes sure the Parser is initialized and gets a handle to it.
49  DDLParser ddlp(cpv_);
50  ddlp.getXMLParser()->setContentHandler(&configHandler_);
51  ddlp.getXMLParser()->parse(absoluteFileName.c_str());
52  const std::vector<std::string>& vURLs = configHandler_.getURLs();
53  const std::vector<std::string>& vFiles = configHandler_.getFileNames();
54  size_t maxInd = vFiles.size();
55  size_t ind = 0;
56  // ea. file listed in the config
57  for (; ind < maxInd; ++ind) {
58  edm::FileInPath fp(vURLs[ind] + "/" + vFiles[ind]);
59  // std::cout << "FileInPath says..." << fp.fullPath() << std::endl;
60  files_.emplace_back(fp.fullPath());
61  urls_.emplace_back("");
62  }
63 
64  // std::vector<std::string> fnames = configHandler_.getFileNames();
65  // std::cout << "there are " << fnames.size() << " files." << std::endl;
66  // for (size_t i = 0; i < fnames.size(); ++i)
67  // std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl;
68  return 0;
69 }
70 
71 int FIPConfiguration::readConfig(const std::string& filename) { return readConfig(filename, false); }
DDLSAX2ConfigHandler configHandler_
std::vector< std::string > urls_
const std::string getSchemaLocation() const
const std::vector< std::string > & getURLList(void) const override
Return a list of urls as a std::vector of strings.
const std::vector< std::string > & getFileList(void) const override
Return a list of files as a std::vector of strings.
int readConfig(const std::string &filename) override
Read in the configuration file.
FIPConfiguration(DDCompactView &cpv)
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:81
void dumpFileList(void) const override
Print out the list of files.
DDCompactView & cpv_
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:63
const std::vector< std::string > & getURLs() const
SAX2XMLReader * getXMLParser()
Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.
Definition: DDLParser.cc:51
std::vector< std::string > files_
std::string getSchemaLocation() const override
Return the designation for where to look for the schema.
~FIPConfiguration() override
tuple filename
Definition: lut2db_cfg.py:20
std::string fullPath() const
Definition: FileInPath.cc:161
const std::vector< std::string > & getFileNames() const
tuple cout
Definition: gather_cfg.py:144
const bool doValidation() const
bool doValidation() const override
Return whether Validation should be on or off and where the DDL SchemaLocation is.