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="")
std::unique_ptr< XMLCoreNodeparse (const std::string &file_name)
std::unique_ptr< XMLCoreNodeparse_string (const std::string &text)
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 69 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 369 of file XMLCoreParser.cxx.

369 {
370 m_level -= 1;
371}

◆ find_factory()

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

Definition at line 353 of file XMLCoreParser.cxx.

353 {
354 FactoryMap::iterator it = m_factories.find (name);
355 if (it != m_factories.end ()) {
356 return (*it).second.get();
357 }
358 return m_default_factory.get();
359}
std::unique_ptr< XMLCoreFactory > m_default_factory
FactoryMap m_factories

◆ level()

int XMLCoreParser::level ( ) const
inherited

Definition at line 375 of file XMLCoreParser.cxx.

375 {
376 return m_level;
377}

◆ 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]

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

Definition at line 216 of file XMLCoreParser.cxx.

216 {
217 m_level = 0;
218 std::unique_ptr<XMLCoreNode> doc = ExpatCoreParser::parse (file_name);
219 if (XMLCoreParserDebugger::debug ()){
220 if (doc != nullptr) doc->print ("============ ALL =============");
221 }
222 if (not doc){
223 throw std::runtime_error("XMLCoreParser: no such file ["+file_name+"]");
224 }
225 return doc;
226}
static std::unique_ptr< XMLCoreNode > parse(const std::string &file_name)

◆ parse_string()

std::unique_ptr< XMLCoreNode > XMLCoreParser::parse_string ( const std::string & text)
inherited

Definition at line 229 of file XMLCoreParser.cxx.

229 {
230 m_level = 0;
231 std::unique_ptr<XMLCoreNode> doc = ExpatCoreParser::parse_string (text);
232 if (XMLCoreParserDebugger::debug ()){
233 if (doc != nullptr) doc->print ("============ ALL =============");
234 }
235 if (not doc){
236 throw std::runtime_error("XMLCoreParser: cannot parse string");
237 }
238 return doc;
239}
static std::unique_ptr< XMLCoreNode > parse_string(const std::string &text)

◆ register_default_factory()

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

Definition at line 319 of file XMLCoreParser.cxx.

319 {
320 m_default_factory = std::move (factory);
321}

◆ register_external_entity()

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

Definition at line 334 of file XMLCoreParser.cxx.

334 {
335 if (XMLCoreParserDebugger::debug ()){
336 std::cout << "XMLCoreParser::register_external_entity> name=" << name
337 << " file_name=" << file_name << std::endl;
338 }
340}
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 324 of file XMLCoreParser.cxx.

325 {
326 if (XMLCoreParserDebugger::debug ()){
327 std::cout << "XMLCoreFactory::register_factory> name=" << name
328 << " factory=" << factory.get() << std::endl;
329 }
330 m_factories[name] = std::move (factory);
331}

◆ register_text_entity()

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

Definition at line 343 of file XMLCoreParser.cxx.

343 {
344 if (XMLCoreParserDebugger::debug ()){
345 std::cout << "XMLCoreParser::register_text_entity> name=" << name
346 << std::endl;
347 }
349}
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 363 of file XMLCoreParser.cxx.

363 {
364 m_level += 1;
365}

◆ visit() [1/2]

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

Definition at line 242 of file XMLCoreParser.cxx.

242 {
243 if (XMLCoreParserDebugger::debug ()){
244 std::cout << "XMLCoreParser::visit file_name "
245 << file_name << std::endl;
246 }
247 std::unique_ptr<XMLCoreNode> n = parse (file_name);
248 if (XMLCoreParserDebugger::debug ()){
249 std::cout << "XMLCoreParser::visit node=" << n.get() << std::endl;
250 }
251 visit (*n);
252}
std::unique_ptr< XMLCoreNode > parse(const std::string &file_name)

◆ visit() [2/2]

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

Definition at line 255 of file XMLCoreParser.cxx.

255 {
256 // Get the name and value out for convenience
257 const std::string& nodeName = node.get_name();
258 const std::string& nodeValue = node.get_value();
259 if (XMLCoreParserDebugger::debug ()){
260 std::cout << "XMLCoreParser::visit node(" << &node << ") " << nodeName << std::endl;
261 }
262 XMLCoreFactory* factory = find_factory (nodeName);
263 if (XMLCoreParserDebugger::debug ()){
264 std::cout << "XMLCoreParser::visit factory " << factory << std::endl;
265 }
266
267 switch (node.get_type()) {
269 std::vector<const XMLCoreNode*> children = node.get_children();
270 for (const XMLCoreNode* child : children) {
271 visit (*child);
272 }
273 break;
274 }
276 if (XMLCoreParserDebugger::debug ()){
277 std::cout << "XMLCoreParser::visit ELEMENT_NODE "
278 << " factory=" << factory
279 << std::endl;
280 }
281 if (factory != 0){
282 factory->start (*this, node);
283 } else {
284 std::cerr << "XMLCoreParser> Cannot find factory for element "
285 << nodeName << std::endl;
286 register_factory (nodeName, std::make_unique<DummyFactory>());
287 }
288 std::vector<const XMLCoreNode*> children = node.get_children();
289 for (const XMLCoreNode* child : children) {
290 visit (*child);
291 }
292 if (factory != 0) factory->end (*this, node);
293 break;
294 }
296 if (factory != 0) factory->comment (*this, nodeValue);
297 break;
298 }
300 std::cout << "ENTITY_NODE " << nodeValue << std::endl;
301 break;
302 }
304 std::cout << "ENTITY_REFERENCE_NODE " << nodeValue << std::endl;
305 break;
306 }
308 break;
309 default:
310 std::cerr << "Unrecognized node type = " << (long) node.get_type() << std::endl;
311 break;
312 }
313 if (XMLCoreParserDebugger::debug ()){
314 std::cout << "XMLCoreParser::visit-2" << std::endl;
315 }
316}
void end(XMLCoreParser &parser, const XMLCoreNode &node)
void comment(XMLCoreParser &parser, const std::string &comment)
void start(XMLCoreParser &parser, const XMLCoreNode &node)
@ ENTITY_REFERENCE_NODE
Definition XMLCoreNode.h:57
std::vector< const XMLCoreNode * > get_children(const std::string &path="*") const
Return all children matching a pattern.
NodeType get_type() const
Return the type of this node.
const std::string & get_value() const
Return the value of this node, or an empty string if no value.
const std::string & get_name() const
Return the name of this node, or an empty string if no name.
XMLCoreFactory * find_factory(const std::string &name)

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 71 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 70 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 72 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: