ATLAS Offline Software
Loading...
Searching...
No Matches
IdDictParser Class Reference

#include <IdDictParser.h>

Inheritance diagram for IdDictParser:
Collaboration diagram for IdDictParser:

Public Member Functions

 IdDictParser ()
 ~IdDictParser ()
IdDictMgrparse (const std::string &file_name, const std::string &tag="")
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

Public Attributes

IdDictMgr m_idd
std::unique_ptr< IdDictDictionarym_dictionary
std::unique_ptr< IdDictFieldm_field
std::unique_ptr< IdDictRegionm_region
std::unique_ptr< IdDictAltRegionsm_altregions
std::unique_ptr< IdDictSubRegionm_subregion
std::unique_ptr< IdDictRegionEntrym_regionentry

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 18 of file IdDictParser.h.

Member Typedef Documentation

◆ FactoryMap

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

Definition at line 120 of file XMLCoreParser.h.

Constructor & Destructor Documentation

◆ IdDictParser()

IdDictParser::IdDictParser ( )

Definition at line 116 of file IdDictParser.cxx.

116 : XMLCoreParser () {
117 register_factory ("IdDict", std::make_unique<IdDictMgrFactory>());
118 register_factory ("IdDictionary", std::make_unique<DictionaryFactory>());
119 register_factory ("field", std::make_unique<FieldFactory>());
120 register_factory ("label", std::make_unique<LabelFactory>());
121 register_factory ("alternate_regions", std::make_unique<AltRegionsFactory>());
122 register_factory ("region", std::make_unique<RegionFactory>());
123 register_factory ("subregion", std::make_unique<SubRegionFactory>());
124 register_factory ("range", std::make_unique<RangeFactory>());
125 register_factory ("reference", std::make_unique<ReferenceFactory>());
126 register_factory ("dictionary", std::make_unique<DictionaryRefFactory>());
127}
void register_factory(const std::string &name, std::unique_ptr< XMLCoreFactory > factory)

◆ ~IdDictParser()

IdDictParser::~IdDictParser ( )
default

Member Function Documentation

◆ down()

void XMLCoreParser::down ( )
inherited

Definition at line 417 of file XMLCoreParser.cxx.

417 {
418 m_level -= 1;
419}

◆ find_factory()

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

Definition at line 401 of file XMLCoreParser.cxx.

401 {
402 FactoryMap::iterator it = m_factories.find (name);
403 if (it != m_factories.end ()) {
404 return (*it).second.get();
405 }
406 return m_default_factory.get();
407}
std::unique_ptr< XMLCoreFactory > m_default_factory
FactoryMap m_factories

◆ level()

int XMLCoreParser::level ( ) const
inherited

Definition at line 423 of file XMLCoreParser.cxx.

423 {
424 return m_level;
425}

◆ parse() [1/2]

IdDictMgr & IdDictParser::parse ( const std::string & file_name,
const std::string & tag = "" )

Definition at line 132 of file IdDictParser.cxx.

132 {
133 m_idd.clear ();
134 XMLCoreParser::visit (file_name);
135 if (Debugger::debug ()) {
136 std::cout << "IdDictParser::parse1>" << std::endl;
137 }
138 m_idd.resolve_references ();
139 if (Debugger::debug ()) {
140 std::cout << "IdDictParser::parse2>" << std::endl;
141 }
142 m_idd.generate_implementation (tag);
143 if (Debugger::debug ()) {
144 std::cout << "IdDictParser::parse3>" << std::endl;
145 }
146 return (m_idd);
147}
static bool debug()
Definition Debugger.h:18
IdDictMgr m_idd
void visit(const std::string &file_name)

◆ parse() [2/2]

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

Definition at line 272 of file XMLCoreParser.cxx.

272 {
273 m_level = 0;
274 std::unique_ptr<CoreParser::DOMNode> doc = ExpatCoreParser::parse (file_name);
275 if (XMLCoreParserDebugger::debug ()){
276 if (doc != nullptr) doc->print ("============ ALL =============");
277 }
278 if (not doc){
279 throw std::runtime_error("XMLCoreParser: no such file ["+file_name+"]");
280 }
281 return XMLCoreNode (std::move (doc));
282}
static std::unique_ptr< CoreParser::DOMNode > parse(const std::string &file_name)

◆ register_default_factory()

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

Definition at line 367 of file XMLCoreParser.cxx.

367 {
368 m_default_factory = std::move (factory);
369}

◆ register_external_entity()

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

Definition at line 382 of file XMLCoreParser.cxx.

382 {
383 if (XMLCoreParserDebugger::debug ()){
384 std::cout << "XMLCoreParser::register_external_entity> name=" << name
385 << " file_name=" << file_name << std::endl;
386 }
388}
static void register_external_entity(const std::string &name, const std::string &file_name)

◆ register_factory()

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

Definition at line 372 of file XMLCoreParser.cxx.

373 {
374 if (XMLCoreParserDebugger::debug ()){
375 std::cout << "XMLCoreFactory::register_factory> name=" << name
376 << " factory=" << factory.get() << std::endl;
377 }
378 m_factories[name] = std::move (factory);
379}

◆ register_text_entity()

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

Definition at line 391 of file XMLCoreParser.cxx.

391 {
392 if (XMLCoreParserDebugger::debug ()){
393 std::cout << "XMLCoreParser::register_text_entity> name=" << name
394 << std::endl;
395 }
397}
static void register_text_entity(const std::string &name, const std::string &text)

◆ terminate()

void XMLCoreParser::terminate ( )
privateinherited

◆ up()

void XMLCoreParser::up ( )
inherited

Definition at line 411 of file XMLCoreParser.cxx.

411 {
412 m_level += 1;
413}

◆ visit() [1/2]

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

Definition at line 285 of file XMLCoreParser.cxx.

285 {
286 if (XMLCoreParserDebugger::debug ()){
287 std::cout << "XMLCoreParser::visit file_name "
288 << file_name << std::endl;
289 }
290 XMLCoreNode n = parse (file_name);
291 if (XMLCoreParserDebugger::debug ()){
292 const CoreParser::DOMNode& node = n.get_node();
293 const CoreParser::DOMNode* nptr = &node;
294 std::cout << "XMLCoreParser::visit node=" << nptr << std::endl;
295 }
296 visit (n);
297}
XMLCoreNode parse(const std::string &file_name)

◆ visit() [2/2]

void XMLCoreParser::visit ( const XMLCoreNode & node)
privateinherited

Definition at line 300 of file XMLCoreParser.cxx.

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

Member Data Documentation

◆ m_altregions

std::unique_ptr<IdDictAltRegions> IdDictParser::m_altregions

Definition at line 29 of file IdDictParser.h.

◆ m_default_factory

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

Definition at line 122 of file XMLCoreParser.h.

◆ m_dictionary

std::unique_ptr<IdDictDictionary> IdDictParser::m_dictionary

Definition at line 26 of file IdDictParser.h.

◆ m_factories

FactoryMap XMLCoreParser::m_factories
privateinherited

Definition at line 121 of file XMLCoreParser.h.

◆ m_field

std::unique_ptr<IdDictField> IdDictParser::m_field

Definition at line 27 of file IdDictParser.h.

◆ m_idd

IdDictMgr IdDictParser::m_idd

Definition at line 25 of file IdDictParser.h.

◆ m_level

int XMLCoreParser::m_level = 0
privateinherited

Definition at line 123 of file XMLCoreParser.h.

◆ m_region

std::unique_ptr<IdDictRegion> IdDictParser::m_region

Definition at line 28 of file IdDictParser.h.

◆ m_regionentry

std::unique_ptr<IdDictRegionEntry> IdDictParser::m_regionentry

Definition at line 31 of file IdDictParser.h.

◆ m_subregion

std::unique_ptr<IdDictSubRegion> IdDictParser::m_subregion

Definition at line 30 of file IdDictParser.h.


The documentation for this class was generated from the following files: