ATLAS Offline Software
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
XMLCoreParser Class Reference

#include <XMLCoreParser.h>

Inheritance diagram for XMLCoreParser:
Collaboration diagram for XMLCoreParser:

Public Member Functions

XMLCoreNode parse (const std::string &file_name)
 
void visit (const std::string &file_name)
 
void register_default_factory (std::unique_ptr< XMLCoreFactory > factory)
 
void register_factory (const std::string &name, std::unique_ptr< XMLCoreFactory > factory)
 
void register_external_entity (const std::string &name, const std::string &file_name)
 
void register_text_entity (const std::string &name, const std::string &text)
 
void up ()
 
void down ()
 
int level () const
 

Private Types

typedef std::map< std::string, std::unique_ptr< XMLCoreFactory > > FactoryMap
 

Private Member Functions

void visit (const XMLCoreNode &node)
 
void terminate ()
 
XMLCoreFactoryfind_factory (const std::string &name)
 

Private Attributes

FactoryMap m_factories
 
std::unique_ptr< XMLCoreFactorym_default_factory
 
int m_level = 0
 

Detailed Description

Definition at line 97 of file XMLCoreParser.h.

Member Typedef Documentation

◆ FactoryMap

typedef std::map<std::string, std::unique_ptr<XMLCoreFactory> > XMLCoreParser::FactoryMap
private

Definition at line 120 of file XMLCoreParser.h.

Member Function Documentation

◆ down()

void XMLCoreParser::down ( )

Definition at line 421 of file XMLCoreParser.cxx.

421  {
422  m_level -= 1;
423 }

◆ find_factory()

XMLCoreFactory * XMLCoreParser::find_factory ( const std::string &  name)
private

Definition at line 405 of file XMLCoreParser.cxx.

405  {
407  if (it != m_factories.end ()) {
408  return (*it).second.get();
409  }
410  return m_default_factory.get();
411 }

◆ level()

int XMLCoreParser::level ( ) const

Definition at line 427 of file XMLCoreParser.cxx.

427  {
428  return m_level;
429 }

◆ parse()

XMLCoreNode XMLCoreParser::parse ( const std::string &  file_name)

Definition at line 276 of file XMLCoreParser.cxx.

276  {
277  m_level = 0;
278  std::unique_ptr<CoreParser::DOMNode> doc = ExpatCoreParser::parse (file_name);
280  if (doc != nullptr) doc->print ("============ ALL =============");
281  }
282  if (not doc){
283  throw std::runtime_error("XMLCoreParser: no such file ["+file_name+"]");
284  }
285  return XMLCoreNode (std::move (doc));
286 }

◆ register_default_factory()

void XMLCoreParser::register_default_factory ( std::unique_ptr< XMLCoreFactory factory)

Definition at line 371 of file XMLCoreParser.cxx.

371  {
372  m_default_factory = std::move (factory);
373 }

◆ register_external_entity()

void XMLCoreParser::register_external_entity ( const std::string &  name,
const std::string &  file_name 
)

Definition at line 386 of file XMLCoreParser.cxx.

386  {
388  std::cout << "XMLCoreParser::register_external_entity> name=" << name
389  << " file_name=" << file_name << std::endl;
390  }
392 }

◆ register_factory()

void XMLCoreParser::register_factory ( const std::string &  name,
std::unique_ptr< XMLCoreFactory factory 
)

Definition at line 376 of file XMLCoreParser.cxx.

377  {
379  std::cout << "XMLCoreFactory::register_factory> name=" << name
380  << " factory=" << factory.get() << std::endl;
381  }
382  m_factories[name] = std::move (factory);
383 }

◆ register_text_entity()

void XMLCoreParser::register_text_entity ( const std::string &  name,
const std::string &  text 
)

Definition at line 395 of file XMLCoreParser.cxx.

395  {
397  std::cout << "XMLCoreParser::register_text_entity> name=" << name
398  << std::endl;
399  }
401 }

◆ terminate()

void XMLCoreParser::terminate ( )
private

◆ up()

void XMLCoreParser::up ( )

Definition at line 415 of file XMLCoreParser.cxx.

415  {
416  m_level += 1;
417 }

◆ visit() [1/2]

void XMLCoreParser::visit ( const std::string &  file_name)

Definition at line 289 of file XMLCoreParser.cxx.

289  {
291  std::cout << "XMLCoreParser::visit file_name "
292  << file_name << std::endl;
293  }
296  const CoreParser::DOMNode& node = n.get_node();
297  const CoreParser::DOMNode* nptr = &node;
298  std::cout << "XMLCoreParser::visit node=" << nptr << std::endl;
299  }
300  visit (n);
301 }

◆ visit() [2/2]

void XMLCoreParser::visit ( const XMLCoreNode node)
private

Definition at line 304 of file XMLCoreParser.cxx.

304  {
305  // Get the name and value out for convenience
306  const CoreParser::DOMNode& node = core_node.get_node ();
307  const CoreParser::DOMNode* nptr = &node;
308  const std::string& nodeName = node.get_name();
309  const std::string& nodeValue = node.get_value();
311  std::cout << "XMLCoreParser::visit node(" << nptr << ") " << nodeName << std::endl;
312  }
313  XMLCoreFactory* factory = find_factory (nodeName);
315  std::cout << "XMLCoreParser::visit factory " << factory << std::endl;
316  }
317 
318  switch (node.get_type()) {
320  const CoreParser::DOMSiblings& siblings = node.get_siblings ();
321  for (const CoreParser::DOMNode* child : siblings) {
322  XMLCoreNode n (child);
323  visit (n);
324  }
325  break;
326  }
329  std::cout << "XMLCoreParser::visit ELEMENT_NODE "
330  << " factory=" << factory
331  << std::endl;
332  }
333  if (factory != 0){
334  factory->start (*this, core_node);
335  } else {
336  std::cerr << "XMLCoreParser> Cannot find factory for element "
337  << nodeName << std::endl;
338  register_factory (nodeName, std::make_unique<DummyFactory>());
339  }
340  const CoreParser::DOMSiblings& siblings = node.get_siblings ();
341  for (const CoreParser::DOMNode* child : siblings) {
342  XMLCoreNode n (child);
343  visit (n);
344  }
345  if (factory != 0) factory->end (*this, core_node);
346  break;
347  }
349  if (factory != 0) factory->comment (*this, nodeValue);
350  break;
351  }
353  std::cout << "ENTITY_NODE " << nodeValue << std::endl;
354  break;
355  }
357  std::cout << "ENTITY_REFERENCE_NODE " << nodeValue << std::endl;
358  break;
359  }
360  default: {
361  std::cerr << "Unrecognized node type = " << (long) node.get_type() << std::endl;
362  break;
363  }
364  }
366  std::cout << "XMLCoreParser::visit-2" << std::endl;
367  }
368 }

Member Data Documentation

◆ m_default_factory

std::unique_ptr<XMLCoreFactory> XMLCoreParser::m_default_factory
private

Definition at line 122 of file XMLCoreParser.h.

◆ m_factories

FactoryMap XMLCoreParser::m_factories
private

Definition at line 121 of file XMLCoreParser.h.

◆ m_level

int XMLCoreParser::m_level = 0
private

Definition at line 123 of file XMLCoreParser.h.


The documentation for this class was generated from the following files:
XMLCoreParser::find_factory
XMLCoreFactory * find_factory(const std::string &name)
Definition: XMLCoreParser.cxx:405
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
XMLCoreParser::parse
XMLCoreNode parse(const std::string &file_name)
Definition: XMLCoreParser.cxx:276
CoreParser::DOMSiblings
std::vector< DOMNode * > DOMSiblings
Definition: DOMNode.h:18
XMLCoreFactory::start
void start(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:66
skel.it
it
Definition: skel.GENtoEVGEN.py:396
CoreParser::DOMNode
Definition: DOMNode.h:21
CoreParser::DOMNode::ENTITY_NODE
@ ENTITY_NODE
Definition: DOMNode.h:28
XMLCoreNode
Definition: XMLCoreParser.h:19
XMLCoreParser::m_level
int m_level
Definition: XMLCoreParser.h:123
CoreParser::DOMNode::DOCUMENT_NODE
@ DOCUMENT_NODE
Definition: DOMNode.h:25
physics_parameters.file_name
string file_name
Definition: physics_parameters.py:32
XMLCoreParser::m_default_factory
std::unique_ptr< XMLCoreFactory > m_default_factory
Definition: XMLCoreParser.h:122
CoreParser::DOMNode::COMMENT_NODE
@ COMMENT_NODE
Definition: DOMNode.h:27
ExpatCoreParser::register_text_entity
static void register_text_entity(const std::string &name, const std::string &text)
Definition: ExpatCoreParser.cxx:92
beamspotman.n
n
Definition: beamspotman.py:731
CoreParser::DOMNode::ELEMENT_NODE
@ ELEMENT_NODE
Definition: DOMNode.h:26
XMLCoreParser::register_factory
void register_factory(const std::string &name, std::unique_ptr< XMLCoreFactory > factory)
Definition: XMLCoreParser.cxx:376
XMLCoreFactory::end
void end(XMLCoreParser &parser, const XMLCoreNode &node)
Definition: XMLCoreParser.cxx:74
XMLCoreFactory
Definition: XMLCoreParser.h:62
PyPoolBrowser.node
node
Definition: PyPoolBrowser.py:131
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
debug
const bool debug
Definition: MakeUncertaintyPlots.cxx:53
CoreParser::DOMNode::ENTITY_REFERENCE_NODE
@ ENTITY_REFERENCE_NODE
Definition: DOMNode.h:29
XMLCoreParser::m_factories
FactoryMap m_factories
Definition: XMLCoreParser.h:121
ExpatCoreParser::parse
static std::unique_ptr< CoreParser::DOMNode > parse(const std::string &file_name)
Definition: ExpatCoreParser.cxx:417
makeTransCanvas.text
text
Definition: makeTransCanvas.py:11
ExpatCoreParser::register_external_entity
static void register_external_entity(const std::string &name, const std::string &file_name)
Definition: ExpatCoreParser.cxx:82
XMLCoreFactory::comment
void comment(XMLCoreParser &parser, const std::string &comment)
Definition: XMLCoreParser.cxx:82
XMLCoreParser::visit
void visit(const std::string &file_name)
Definition: XMLCoreParser.cxx:289
node
Definition: memory_hooks-stdcmalloc.h:74