LDMX Software
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
simcore::geo::ParserFactory Class Reference

Public Member Functions

 ~ParserFactory ()=default
 Default constructor.
 
ParsercreateParser (const std::string &name, framework::config::Parameters &parameters, simcore::ConditionsInterface &ci)
 Create an instance of the parser of the given type.
 
 ParserFactory (ParserFactory const &)=delete
 
void operator= (ParserFactory const &)=delete
 

Static Public Member Functions

static ParserFactorygetInstance ()
 Get the instance to this factory.
 

Private Member Functions

 ParserFactory ()
 Default constructor.
 
void registerParser (const std::string &name, createFunc create)
 Register the parser with this factory.
 

Private Attributes

std::map< std::string, createFunc > parser_map
 

Detailed Description

Definition at line 19 of file ParserFactory.h.

Constructor & Destructor Documentation

◆ ParserFactory()

simcore::geo::ParserFactory::ParserFactory ( )
private

Default constructor.

Definition at line 19 of file ParserFactory.cxx.

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.

References simcore::geo::GDMLParser::create(), and registerParser().

Member Function Documentation

◆ createParser()

Parser * simcore::geo::ParserFactory::createParser ( const std::string &  name,
framework::config::Parameters parameters,
simcore::ConditionsInterface ci 
)

Create an instance of the parser of the given type.

Parameters
[in]typeString type of the perser that needs to be created.
[in]ciInterface to conditions system.

Definition at line 25 of file ParserFactory.cxx.

27 {
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}

◆ getInstance()

ParserFactory & simcore::geo::ParserFactory::getInstance ( )
static

Get the instance to this factory.

Definition at line 14 of file ParserFactory.cxx.

14 {
15 static ParserFactory instance;
16 return instance;
17}
ParserFactory()
Default constructor.

◆ registerParser()

void simcore::geo::ParserFactory::registerParser ( const std::string &  name,
createFunc  create 
)
private

Register the parser with this factory.

This is used to map the name of the parser to the function used to create it.

Parameters
[in]nameName of the parser being registered.
[in]crateFunction used to create this function.

Definition at line 21 of file ParserFactory.cxx.

21 {
22 parser_map[name] = create;
23}

Referenced by ParserFactory().

Member Data Documentation

◆ parser_map

std::map<std::string, createFunc> simcore::geo::ParserFactory::parser_map
private

Definition at line 57 of file ParserFactory.h.


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