LDMX Software
ParserFactory.cxx
1
2#include "SimCore/Geo/ParserFactory.h"
3
4//---< Framework >---//
5#include "Framework/Exception/Exception.h"
6
7//---< SimCore >---//
8#include "SimCore/Geo/GDMLParser.h"
9#include "SimCore/Geo/Parser.h"
10
11namespace simcore {
12namespace geo {
13
15 static ParserFactory instance;
16 return instance;
17}
18
20
21void ParserFactory::registerParser(const std::string &name, createFunc create) {
22 parser_map[name] = create;
23}
24
25Parser *ParserFactory::createParser(const std::string &name,
28 auto it{parser_map.find(name)};
29 if (it == parser_map.end())
30 EXCEPTION_RAISE("ParserNotFound", "The parser " + name + " was not found.");
31
32 return it->second(parameters, ci);
33}
34
35} // namespace geo
36} // namespace simcore
Class encapsulating parameters for configuring a processor.
Definition Parameters.h:27
Handle to the conditions system, provided at construction to classes which require it.
static Parser * create(framework::config::Parameters &parameters, simcore::ConditionsInterface &ci)
Create an instance of this parser.
Definition GDMLParser.h:66
void registerParser(const std::string &name, createFunc create)
Register the parser with this factory.
Parser * createParser(const std::string &name, framework::config::Parameters &parameters, simcore::ConditionsInterface &ci)
Create an instance of the parser of the given type.
static ParserFactory & getInstance()
Get the instance to this factory.
ParserFactory()
Default constructor.
Interface for a parser used to load a geometry into Geant4.
Definition Parser.h:25