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 
16  : configHandler_( cpv ),
17  cpv_( cpv )
18 {}
19 
21 {}
22 
23 const std::vector<std::string>&
25 {
26  return files_;
27 }
28 
29 const std::vector<std::string>&
31 {
32  return urls_;
33 }
34 
35 bool
37 {
39 }
40 
43 {
45 }
46 
47 void
49 {
50  std::cout << "File List:" << std::endl;
51  std::cout << " number of files=" << files_.size() << std::endl;
52  for (const auto & file : files_)
53  std::cout << file << std::endl;
54 }
55 
56 //-----------------------------------------------------------------------
57 // Here the Xerces parser is used to process the content of the
58 // configuration file.
59 //-----------------------------------------------------------------------
60 
61 int
63 {
64  std::string absoluteFileName (filename);
65  if (!fullPath) {
66  edm::FileInPath fp(filename);
67  // config file
68  absoluteFileName = fp.fullPath();
69  }
70 
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_.emplace_back(fp.fullPath());
86  urls_.emplace_back("");
87  }
88 
89  // std::vector<std::string> fnames = configHandler_.getFileNames();
90  // std::cout << "there are " << fnames.size() << " files." << std::endl;
91  // for (size_t i = 0; i < fnames.size(); ++i)
92  // std::cout << "url=" << configHandler_.getURLs()[i] << " file=" << configHandler_.getFileNames()[i] << std::endl;
93  return 0;
94 }
95 
96 int
98 {
99  return readConfig( filename, false );
100 }
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:83
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:56
std::vector< std::string > files_
~FIPConfiguration() override
std::string fullPath() const
Definition: FileInPath.cc:197
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