CMS 3D CMS Logo

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_
const std::vector< std::string > & getFileList(void) const override
Return a list of files as a std::vector of strings.
std::vector< std::string > urls_
const std::string getSchemaLocation() const
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:80
std::string getSchemaLocation() const override
Return the designation for where to look for the schema.
bool doValidation() const override
Return whether Validation should be on or off and where the DDL SchemaLocation is.
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_
~FIPConfiguration() override
std::string fullPath() const
Definition: FileInPath.cc:163
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 > & getFileNames() const
const bool doValidation() const