CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
DDLParser Class Reference

DDLParser is the main class of Detector Description Language Parser. More...

#include <DDLParser.h>

Public Types

typedef std::map< int,
std::pair< std::string,
std::string > > 
FileNameHolder
 
typedef
XERCES_CPP_NAMESPACE::SAX2XMLReader 
SAX2XMLReader
 

Public Member Functions

void clearFiles ()
 Clear the file list - see Warning! More...
 
 DDLParser (DDCompactView &cpv)
 Constructor MUST associate a DDCompactView storage. More...
 
std::string extractFileName (std::string fullname)
 
DDLSAX2FileHandlergetDDLSAX2FileHandler ()
 To get the parent this class allows access to the handler. More...
 
std::vector< std::string > getFileList ()
 Return list of files. More...
 
std::string getNameSpace (const std::string &fname)
 
SAX2XMLReadergetXMLParser ()
 Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc. More...
 
size_t isFound (const std::string &filename)
 Is the file already known by the DDLParser? Returns 0 if not found, and index if found. More...
 
bool isParsed (const std::string &filename)
 Is the file already parsed? More...
 
int parse (const DDLDocumentProvider &dp)
 Parse all files. Return is meaningless. More...
 
void parse (const std::vector< unsigned char > &ablob, unsigned int bsize)
 
bool parseOneFile (const std::string &filename)
 Process a single files. More...
 
 ~DDLParser ()
 Destructor terminates the XMLPlatformUtils (as required by Xerces) More...
 

Protected Member Functions

 DDLParser ()
 
void parseFile (const int &numtoproc)
 Parse File. Just to hold some common looking code. More...
 

Private Attributes

DDCompactViewcpv_
 reference to storage More...
 
std::string currFileName_
 Which file is currently being processed. More...
 
DDLSAX2HandlererrHandler_
 
DDLSAX2ExpressionHandlerexpHandler_
 
DDLSAX2FileHandlerfileHandler_
 
FileNameHolder fileNames_
 List of files to be processed, obtained from the DDLDocumentProvider. More...
 
int nFiles_
 Number of files + 1. More...
 
std::map< int, bool > parsed_
 Parse status of a given file. More...
 
SAX2XMLReaderSAX2Parser_
 SAX2XMLReader is one way of parsing. More...
 

Detailed Description

DDLParser is the main class of Detector Description Language Parser.

Author
Michael Case

DDLParser.h - description

begin: Mon Oct 22 2001 email: case@.nosp@m.ucdh.nosp@m.ep.uc.nosp@m.davi.nosp@m.s.edu

Singleton which controls the parsing of XML files (DDL). It guarantees that a given filename will only be parsed once regardless of its path. It now relies on a DDLDocumentProvider class which provides a list of file names and URLs to be parsed.

It uses the Xerces C++ Parser from the Apache Group straight-forwardly. One main thing to note is that only one DDLParser can ever be made. This allows for sub-components of the parser to easily find out information from the parser during run-time.

There is an interface to parse just one file. If one uses this method and does not use the default DDLDocumentProvider user is responsible for also setting the DDRootDef.

Modification: 2003-02-13: Michael Case, Stepan Wynhoff and Martin Liendl 2003-02-24: same. DDLParser will use DDLDocumentProvider (abstract). One of these and will be defaulted to DDLConfiguration. This will read the "configuration.xml" file provided and will be used by the Parser to "get" the files. 2005-11-13: Michael Case removed some of the un-necessary methods that were deprecated. 2010-01 to 2010-04 sometime: Michael Case removed singleton-ness. MUST have a DDCompactView to refer to and no more default constructor at the moment. 2010-07-29: removed DDLConfiguration; use FIPConfiguration, it is easier. for CMSSW Framework example see XMLIdealGeometryESSource (different DDLDocumentProvider completely

Definition at line 64 of file DDLParser.h.

Member Typedef Documentation

typedef std::map< int, std::pair<std::string, std::string> > DDLParser::FileNameHolder

Definition at line 70 of file DDLParser.h.

typedef XERCES_CPP_NAMESPACE::SAX2XMLReader DDLParser::SAX2XMLReader

Definition at line 68 of file DDLParser.h.

Constructor & Destructor Documentation

DDLParser::DDLParser ( DDCompactView cpv)

Constructor MUST associate a DDCompactView storage.

Definition at line 30 of file DDLParser.cc.

References DCOUT_V, errHandler_, expHandler_, fileHandler_, SAX2Parser_, and cms::concurrency::xercesInitialize().

31  : cpv_( cpv ),
32  nFiles_( 0 )
33 {
35  SAX2Parser_ = XMLReaderFactory::createXMLReader();
36 
37  SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation, false); // optional
38  SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces, false); // optional
39  // Specify other parser features, e.g.
40  // SAX2Parser_->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
41 
45  SAX2Parser_->setErrorHandler(errHandler_);
46  SAX2Parser_->setContentHandler(fileHandler_);
47 
48  DCOUT_V('P', "DDLParser::DDLParser(): new (and only) DDLParser");
49 }
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:163
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:161
void xercesInitialize()
Definition: Xerces.cc:17
DDLSAX2FileHandler is the SAX2 Handler for XML files found in the configuration file.
DDLSAX2ExpressionHandler is the first pass SAX2 Handler for XML files found in the configuration file...
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:164
DDLSAX2Handler * errHandler_
Definition: DDLParser.h:165
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
DDLSAX2Handler inherits from Xerces C++ DefaultHandler.
DDCompactView & cpv_
reference to storage
Definition: DDLParser.h:146
int nFiles_
Number of files + 1.
Definition: DDLParser.h:155
DDLParser::DDLParser ( )
protected
DDLParser::~DDLParser ( void  )

Destructor terminates the XMLPlatformUtils (as required by Xerces)

Definition at line 52 of file DDLParser.cc.

References DCOUT_V, errHandler_, expHandler_, fileHandler_, and cms::concurrency::xercesTerminate().

53 {
54  // clean up and leave
55  delete expHandler_;
56  delete fileHandler_;
57  delete errHandler_;
59  DCOUT_V('P', "DDLParser::~DDLParser(): destruct DDLParser");
60 }
void xercesTerminate()
Definition: Xerces.cc:22
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:163
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:164
DDLSAX2Handler * errHandler_
Definition: DDLParser.h:165
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54

Member Function Documentation

void DDLParser::clearFiles ( void  )

Clear the file list - see Warning!

This could result in mangled geometry if the Core has not been cleared.

Definition at line 373 of file DDLParser.cc.

References fileNames_, and parsed_.

Referenced by XMLIdealMagneticFieldGeometryESProducer::produce(), magneticfield::VolumeBasedMagneticFieldESProducerFromDB::produce(), and XMLIdealGeometryESProducer::produce().

374 {
375  fileNames_.clear();
376  parsed_.clear();
377 }
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:152
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:149
std::string DDLParser::extractFileName ( std::string  fullname)

Definition at line 380 of file DDLParser.cc.

References run_regression::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by parse(), and parseOneFile().

381 {
382  std::string ret = "";
383  size_t bit = fullname.rfind('/');
384  if ( bit < fullname.size() - 2 ) {
385  ret=fullname.substr(bit+1);
386  }
387  return ret;
388 }
DDLSAX2FileHandler * DDLParser::getDDLSAX2FileHandler ( void  )

To get the parent this class allows access to the handler.

In order to retrieve the name of the parent element from DDLSAX2Handlers.

Definition at line 73 of file DDLParser.cc.

References fileHandler_.

Referenced by XMLIdealGeometryESSource::produce(), XMLIdealMagneticFieldGeometryESProducer::produce(), magneticfield::VolumeBasedMagneticFieldESProducerFromDB::produce(), and XMLIdealGeometryESProducer::produce().

74 {
75  return fileHandler_;
76 }
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:163
std::vector< std::string > DDLParser::getFileList ( void  )

Return list of files.

Definition at line 193 of file DDLParser.cc.

References fileNames_.

194 {
195  std::vector<std::string> flist;
196  for (FileNameHolder::const_iterator fit = fileNames_.begin(); fit != fileNames_.end(); ++fit)
197  {
198  flist.push_back(fit->second.first); // was .second (mec: 2003:02:19
199  }
200  return flist;
201 }
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:149
std::string DDLParser::getNameSpace ( const std::string &  fname)

Definition at line 391 of file DDLParser.cc.

References j, run_regression::ret, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by parse(), and parseOneFile().

392 {
393  size_t j = 0;
394  std::string ret="";
395  while (j < fname.size() && fname[j] != '.')
396  ++j;
397  if (j < fname.size() && fname[j] == '.')
398  ret = fname.substr(0, j);
399  return ret;
400 }
int j
Definition: DBlmapReader.cc:9
string fname
main script
SAX2XMLReader * DDLParser::getXMLParser ( void  )

Get the SAX2Parser from the DDLParser. USE WITH CAUTION. Set your own handler, etc.

This method allows external "users" to use the current DDLParser on their own. by giving them access to the SAX2XMLReader. This may not be a good idea! The reason that I

Definition at line 67 of file DDLParser.cc.

References SAX2Parser_.

Referenced by FIPConfiguration::readConfig().

68 {
69  return SAX2Parser_;
70 }
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:161
size_t DDLParser::isFound ( const std::string &  filename)

Is the file already known by the DDLParser? Returns 0 if not found, and index if found.

Definition at line 79 of file DDLParser.cc.

References fileNames_, and i.

Referenced by isParsed(), parse(), and parseOneFile().

80 {
81  FileNameHolder::const_iterator it = fileNames_.begin();
82  size_t i = 1;
83  bool foundFile = false;
84  while( it != fileNames_.end() && !foundFile )
85  {
86  if( it->second.first == filename )
87  {
88  foundFile = true;
89  }
90  else ++i;
91  ++it;
92  }
93  if( foundFile )
94  return i;
95  return 0;
96 }
int i
Definition: DBlmapReader.cc:9
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:149
tuple filename
Definition: lut2db_cfg.py:20
bool DDLParser::isParsed ( const std::string &  filename)

Is the file already parsed?

Definition at line 99 of file DDLParser.cc.

References newFWLiteAna::found, isFound(), and parsed_.

100 {
101  size_t found = isFound(filename);
102  if (found)
103  return parsed_[found];
104  return false;
105 }
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:152
size_t isFound(const std::string &filename)
Is the file already known by the DDLParser? Returns 0 if not found, and index if found.
Definition: DDLParser.cc:79
tuple filename
Definition: lut2db_cfg.py:20
int DDLParser::parse ( const DDLDocumentProvider dp)

Parse all files. Return is meaningless.

Definition at line 204 of file DDLParser.cc.

References currFileName_, DCOUT, DDLSAX2FileHandler::dumpElementTypeCounter(), expHandler_, extractFileName(), fileHandler_, fileNames_, DDLDocumentProvider::getFileList(), getNameSpace(), DDLDocumentProvider::getURLList(), i, isFound(), LogDebug, nFiles_, parsed_, parseFile(), SAX2Parser_, DDLSAX2Handler::setNameSpace(), findQualityFiles::size, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by output(), XMLIdealGeometryESSource::produce(), XMLIdealMagneticFieldGeometryESProducer::produce(), magneticfield::VolumeBasedMagneticFieldESProducerFromDB::produce(), XMLIdealGeometryESProducer::produce(), and testParser().

205 {
206  // edm::LogInfo ("DDLParser") << "Start Parsing. Validation is set to " << dp.doValidation() << "." << std::endl;
207  edm::LogInfo ("DDLParser") << "Start Parsing. Validation is set off for the time being." << std::endl;
208  // prep for pass 1 through DDD XML
209  // // Since this block does nothing for CMSSW right now, I have taken it all out
210  // This clean-up involves interface changes such as the removal of doValidation() everywhere (OR NOT
211  // if I decide to keep it for other testing reasons.)
212  // if (dp.doValidation())
213  // {
214  // // DCOUT_V('P', "WARNING: PARSER VALIDATION IS TURNED OFF REGARDLESS OF <Schema... ELEMENT");
215  // SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation, true);
216  // SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces, true);
217  // // // SAX2Parser_->setFeature(XMLUni::fgXercesSchemaFullChecking, true);
218  // }
219  // else
220  // {
221  SAX2Parser_->setFeature(XMLUni::fgSAX2CoreValidation, false);
222  SAX2Parser_->setFeature(XMLUni::fgSAX2CoreNameSpaces, false);
223  // // SAX2Parser_->setFeature(XMLUni::fgXercesSchemaFullChecking, false);
224 
225  // }
226 
227  // This need be only done once, so might as well to it here.
228  size_t fileIndex = 0;
229  std::vector<std::string> fullFileName;
230 
231  for (; fileIndex < (dp.getFileList()).size(); ++fileIndex)
232  {
233  std::string ts = dp.getURLList()[fileIndex];
234  std::string tf = dp.getFileList()[fileIndex];
235  if ( ts.size() > 0 ) {
236  if ( ts[ts.size() - 1] == '/') {
237  fullFileName.push_back( ts + tf );
238  } else {
239  fullFileName.push_back( ts + "/" + tf );
240  }
241  } else {
242  fullFileName.push_back( tf );
243  }
244  }
245 
246  for (std::vector<std::string>::const_iterator fnit = fullFileName.begin();
247  fnit != fullFileName.end();
248  ++fnit)
249  {
250  size_t foundFile = isFound(extractFileName( *fnit ));
251 
252  if (!foundFile)
253  {
254  pair <std::string, std::string> pss;
255  pss.first = extractFileName( *fnit );
256  pss.second = *fnit;
257  fileNames_[nFiles_++] = pss;
258  parsed_[nFiles_ - 1]=false;
259  }
260  }
261 
262  // Start processing the files found in the config file.
263 
264  // PASS 1: This was added later (historically) to implement the DDD
265  // requirement for Expressions.
266  DCOUT('P', "DDLParser::parse(): PASS1: Just before setting Xerces content and error handlers... ");
267 
268 
269  // in cleaning up try-catch blocks 2007-06-26 I decided to remove
270  // this because of CMSSW rules. but keep the commented way I used to
271  // do it...
272  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! try
273  // {
274  SAX2Parser_->setContentHandler(expHandler_);
275  for (size_t i = 0; i < fileNames_.size(); ++i)
276  {
277  if (!parsed_[i])
278  {
279  currFileName_ = fileNames_[i].second;
280  // std::cout << "currFileName = " << currFileName_ << std::endl;
282  // std::cout << "2) namespace = " << getNameSpace(extractFileName(currFileName_)) << std::endl;
283  parseFile(i);
284  }
285  }
287  // }
288  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! catch (const XMLException& toCatch) {
289  // edm::LogInfo ("DDLParser") << "\nPASS1: XMLException while processing files... \n"
290  // << "Exception message is: \n"
291  // << StrX(toCatch.getMessage()) << "\n" ;
292  // cms::concurrency::xercesTerminate();
293  // // FIX use this after DEPRECATED stuff removed: throw(DDException("See XML Exception above"));
294  // return -1;
295  // }
296  // PASS 2:
297 
298  DCOUT('P', "DDLParser::parse(): PASS2: Just before setting Xerces content and error handlers... ");
299 
300  // in cleaning up try-catch blocks 2007-06-26 I decided to remove
301  // this because of CMSSW rules. but keep the commented way I used to
302  // do it...
303  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! try
304  // {
305  SAX2Parser_->setContentHandler(fileHandler_);
306 
307  // No need to validate (regardless of user's doValidation
308  // because the files have already been validated on the first pass.
309  // This optimization suggested by Martin Liendl.
310  // SAX2Parser_->setFeature(StrX("http://xml.org/sax/features/validation"), false); // optional
311  // SAX2Parser_->setFeature(StrX("http://xml.org/sax/features/namespaces"), false); // optional
312  // SAX2Parser_->setFeature(StrX("http://apache.org/xml/features/validation/dynamic"), false);
313 
314 
315  // Process files again.
316  for (size_t i = 0; i < fileNames_.size(); ++i)
317  {
318  // seal::SealTimer t("DDLParser: parsing all elements of file " +fileNames_[i].first);
319  if (!parsed_[i]) {
320  currFileName_ = fileNames_[i].second;
321  // std::cout << "currFileName = " << currFileName_ << std::endl;
323  // std::cout << "3) namespace = " << getNameSpace(extractFileName(currFileName_)) << std::endl;
324  parseFile(i);
325  parsed_[i] = true;
326  pair<std::string, std::string> namePair = fileNames_[i];
327  LogDebug ("DDLParser") << "Completed parsing file " << namePair.second << std::endl;
328  }
329  }
330  // }
331  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! catch (const XMLException& toCatch) {
332  // edm::LogError ("DDLParser") << "\nPASS2: XMLException while processing files... \n"
333  // << "Exception message is: \n"
334  // << StrX(toCatch.getMessage()) << "\n" ;
335  // cms::concurrency::xercesTerminate();
336  // return -1;
337  // }
338  return 0;
339 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:152
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
std::string getNameSpace(const std::string &fname)
Definition: DDLParser.cc:391
std::string extractFileName(std::string fullname)
Definition: DDLParser.cc:380
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:163
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:161
std::string currFileName_
Which file is currently being processed.
Definition: DDLParser.h:158
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:149
virtual const std::vector< std::string > & getFileList(void) const =0
Return a list of files as a vector of strings.
void dumpElementTypeCounter()
This dumps some statistics on elements encountered in the file.
size_t isFound(const std::string &filename)
Is the file already known by the DDLParser? Returns 0 if not found, and index if found.
Definition: DDLParser.cc:79
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:164
virtual const std::vector< std::string > & getURLList(void) const =0
Return a list of urls as a vector of strings.
void parseFile(const int &numtoproc)
Parse File. Just to hold some common looking code.
Definition: DDLParser.cc:342
virtual void setNameSpace(const std::string &nms)
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
tuple size
Write out results.
int nFiles_
Number of files + 1.
Definition: DDLParser.h:155
void DDLParser::parse ( const std::vector< unsigned char > &  ablob,
unsigned int  bsize 
)

Definition at line 185 of file DDLParser.cc.

References SAX2Parser_.

186 {
187  char* dummy(0);
188  MemBufInputSource mbis( &*ablob.begin(), bsize, dummy );
189  SAX2Parser_->parse(mbis);
190 }
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:161
void DDLParser::parseFile ( const int &  numtoproc)
protected

Parse File. Just to hold some common looking code.

Definition at line 342 of file DDLParser.cc.

References currFileName_, DCOUT, fileNames_, plotBeamSpotDB::first, alignmentValidation::fname, parsed_, SAX2Parser_, edm::second(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by parse(), and parseOneFile().

343 {
344  if (!parsed_[numtoproc])
345  {
346  const std::string & fname = fileNames_[numtoproc].second;
347 
348  // in cleaning up try-catch blocks 2007-06-26 I decided to remove
349  // this because of CMSSW rules. but keep the commented way I used to
350  // do it...
351  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! try
352  // {
354  SAX2Parser_->parse(currFileName_.c_str());
355  // }
356  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! catch (const XMLException& toCatch)
357  // {
358  // std::string e("\nWARNING: DDLParser::parseFile, File: '");
359  // e += currFileName_ + "'\n"
360  // + "Exception message is: \n"
361  // + std::string(StrX(toCatch.getMessage()).localForm()) + "\n";
362  // throw(DDException(e));
363  // }
364  }
365  else
366  {
367  DCOUT('P', "\nWARNING: File " + fileNames_[numtoproc].first
368  + " has already been processed as " + fileNames_[numtoproc].second);
369  }
370 }
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:152
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:161
std::string currFileName_
Which file is currently being processed.
Definition: DDLParser.h:158
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:149
U second(std::pair< T, U > const &p)
string fname
main script
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
bool DDLParser::parseOneFile ( const std::string &  filename)

Process a single files.

This method allows a user to add to an existing DDD by parsing a new XML file. Ideally, these would be in addition to an existing DDD configuration which was processed using Parse(...).

The idea is based on whether users decide that the configuration will only hold "standard geometry files" and that any ancillary parameter files, filters and so forth will be unknown to the main configuration file. For me, this seems to go against the principle of knowing what files are relevant because now, there is no central way to find out (externally) what XML files generate the DDD in memory.

On the other hand, if on any run, a dumpFileList is run, then the user will at least know what files were used from where in a given run.

2007-04-06: filename is now relative to src directory of checkout (or share). edm:FileInPath used internally.

Definition at line 110 of file DDLParser.cc.

References currFileName_, DCOUT, DCOUT_V, expHandler_, extractFileName(), fileHandler_, lut2db_cfg::filename, fileNames_, personalPlayback::fp, edm::FileInPath::fullPath(), getNameSpace(), isFound(), LogDebug, nFiles_, parsed_, parseFile(), SAX2Parser_, edm::second(), DDLSAX2Handler::setNameSpace(), and AlCaHLTBitMon_QueryRunRegistry::string.

111 {
112  // std::string filename = expHandler_->extractFileName(fullname);
114  // std::cout << "parseOneFile - fullname = " << fullname << std::endl;
115  // std::cout << "parseOneFile - filename = " << filename << std::endl;
116  edm::FileInPath fp(fullname);
117  std::string absoluteFileName = fp.fullPath();
118  size_t foundFile = isFound(filename);
119  if (!foundFile)
120  {
121  pair <std::string, std::string> pss;
122  pss.first = filename;
123  pss.second = absoluteFileName; //url+filename;
124  int fIndex = nFiles_;
126  ++nFiles_;
127  parsed_[fIndex]=false;
128 
129  currFileName_ = fileNames_[fIndex].second;
130 
131  // in cleaning up try-catch blocks 2007-06-26 I decided to remove
132  // this because of CMSSW rules. but keep the commented way I used to
133  // do it...
134  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! try
135  // {
136  SAX2Parser_->setContentHandler(expHandler_);
137  expHandler_->setNameSpace( getNameSpace(filename) );
138  // std::cout << "0) namespace = " << getNameSpace(filename) << std::endl;
139  LogDebug ("DDLParser") << "ParseOneFile() Parsing: " << fileNames_[fIndex].second << std::endl;
140  parseFile ( fIndex );
141 
142  // }
143  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! catch (const XMLException& toCatch) {
144  // edm::LogError ("DDLParser") << "\nDDLParser::ParseOneFile, PASS1: XMLException while processing files... \n"
145  // << "Exception message is: \n"
146  // << StrX(toCatch.getMessage()) << "\n" ;
147  // cms::concurrency::xercesTerminate();
148  // throw (DDException(" See XMLException above. "));
149  // }
150 
151  // PASS 2:
152 
153  DCOUT_V('P', "DDLParser::ParseOneFile(): PASS2: Just before setting Xerces content and error handlers... ");
154 
155  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! try
156  // {
157 
158  SAX2Parser_->setContentHandler(fileHandler_);
159  // std::cout << "currFileName = " << currFileName_ << std::endl;
161  // std::cout << "1) namespace = " << getNameSpace(currFileName_) << std::endl;
162  parseFile ( fIndex );
163  parsed_[fIndex] = true;
164 
165  // }
166  // DO NOT UNCOMMENT FOR ANY RELEASE; ONLY FOR DEBUGGING! catch (const XMLException& toCatch) {
167  // edm::LogError ("DDLParser") << "\nDDLParser::ParseOneFile, PASS2: XMLException while processing files... \n"
168  // << "Exception message is: \n"
169  // << StrX(toCatch.getMessage()) << "\n" ;
170  // cms::concurrency::xercesTerminate();
171  // throw (DDException(" See XMLException above."));
172  // }
173  }
174  else // was found and is parsed...
175  {
176  DCOUT('P', " WARNING: DDLParser::ParseOneFile() file " + filename
177  + " was already parsed as " + fileNames_[foundFile].second);
178  return true;
179  }
180  return false;
181 }
#define LogDebug(id)
std::map< int, bool > parsed_
Parse status of a given file.
Definition: DDLParser.h:152
std::pair< ALIstring, ALIstring > pss
Definition: Fit.h:27
std::string getNameSpace(const std::string &fname)
Definition: DDLParser.cc:391
std::string extractFileName(std::string fullname)
Definition: DDLParser.cc:380
DDLSAX2FileHandler * fileHandler_
Definition: DDLParser.h:163
SAX2XMLReader * SAX2Parser_
SAX2XMLReader is one way of parsing.
Definition: DDLParser.h:161
std::string currFileName_
Which file is currently being processed.
Definition: DDLParser.h:158
FileNameHolder fileNames_
List of files to be processed, obtained from the DDLDocumentProvider.
Definition: DDLParser.h:149
U second(std::pair< T, U > const &p)
size_t isFound(const std::string &filename)
Is the file already known by the DDLParser? Returns 0 if not found, and index if found.
Definition: DDLParser.cc:79
DDLSAX2ExpressionHandler * expHandler_
Definition: DDLParser.h:164
void parseFile(const int &numtoproc)
Parse File. Just to hold some common looking code.
Definition: DDLParser.cc:342
#define DCOUT_V(M_v_Y, M_v_S)
Definition: DDdebug.h:54
virtual void setNameSpace(const std::string &nms)
tuple filename
Definition: lut2db_cfg.py:20
#define DCOUT(M_v_Y, M_v_S)
Definition: DDdebug.h:53
int nFiles_
Number of files + 1.
Definition: DDLParser.h:155

Member Data Documentation

DDCompactView& DDLParser::cpv_
private

reference to storage

Definition at line 146 of file DDLParser.h.

std::string DDLParser::currFileName_
private

Which file is currently being processed.

Definition at line 158 of file DDLParser.h.

Referenced by parse(), parseFile(), and parseOneFile().

DDLSAX2Handler* DDLParser::errHandler_
private

Definition at line 165 of file DDLParser.h.

Referenced by DDLParser(), and ~DDLParser().

DDLSAX2ExpressionHandler* DDLParser::expHandler_
private

Definition at line 164 of file DDLParser.h.

Referenced by DDLParser(), parse(), parseOneFile(), and ~DDLParser().

DDLSAX2FileHandler* DDLParser::fileHandler_
private

Definition at line 163 of file DDLParser.h.

Referenced by DDLParser(), getDDLSAX2FileHandler(), parse(), parseOneFile(), and ~DDLParser().

FileNameHolder DDLParser::fileNames_
private

List of files to be processed, obtained from the DDLDocumentProvider.

Definition at line 149 of file DDLParser.h.

Referenced by clearFiles(), getFileList(), isFound(), parse(), parseFile(), and parseOneFile().

int DDLParser::nFiles_
private

Number of files + 1.

Definition at line 155 of file DDLParser.h.

Referenced by parse(), and parseOneFile().

std::map<int, bool> DDLParser::parsed_
private

Parse status of a given file.

Definition at line 152 of file DDLParser.h.

Referenced by clearFiles(), isParsed(), parse(), parseFile(), and parseOneFile().

SAX2XMLReader* DDLParser::SAX2Parser_
private

SAX2XMLReader is one way of parsing.

Definition at line 161 of file DDLParser.h.

Referenced by DDLParser(), getXMLParser(), parse(), parseFile(), and parseOneFile().