CMS 3D CMS Logo

FIPConfiguration.cc
Go to the documentation of this file.
2 
3 #include <ext/alloc_traits.h>
4 #include <stddef.h>
5 #include <iostream>
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 (std::vector<std::string>::const_iterator it = files_.begin(); it != files_.end(); ++it)
53  std::cout << *it << 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_.push_back(fp.fullPath());
86  urls_.push_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_
std::vector< std::string > urls_
virtual void dumpFileList(void) const
Print out the list of files.
const std::string getSchemaLocation() const
FIPConfiguration(DDCompactView &cpv)
type of data representation of DDCompactView
Definition: DDCompactView.h:90
virtual const std::vector< std::string > & getFileList(void) const
Return a list of files as a std::vector of strings.
virtual ~FIPConfiguration()
DDCompactView & cpv_
virtual const std::vector< std::string > & getURLList(void) const
Return a list of urls as a std::vector of strings.
virtual bool doValidation() const
Return whether Validation should be on or off and where the DDL SchemaLocation is.
DDLParser is the main class of Detector Description Language Parser.
Definition: DDLParser.h:62
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:53
std::vector< std::string > files_
int readConfig(const std::string &filename)
Read in the configuration file.
const std::vector< std::string > & getFileNames() const
const bool doValidation() const
std::string fullPath() const
Definition: FileInPath.cc:184
std::string getSchemaLocation() const
Return the designation for where to look for the schema.