ATLAS Offline Software
Loading...
Searching...
No Matches
UserProcessFactory.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef GENERATOR_PYTHIA8_USER_PROCESS_FACTORY_H
6#define GENERATOR_PYTHIA8_USER_PROCESS_FACTORY_H
7
8#include "Pythia8/SigmaProcess.h"
9
10
11#include <map>
12#include <string>
13
15
16 using Pythia8::Sigma2Process;
17
18
20
21 public:
22
23 static std::shared_ptr<Sigma2Process> create(const std::string &procName);
24
25 private:
26
28
29 class ICreator{
30 public:
31 virtual std::shared_ptr<Sigma2Process> create() const = 0;
32 virtual ~ICreator(){};
33 };
34
35 public:
36
37 template <class T>
38 class Creator: public ICreator{
39
40 public:
41 Creator(const std::string &name) :
42 m_name(name){
43 UserProcessFactory::s_creators()[name] = this;
44 }
45
47 if(s_creators()[m_name] == this){
48 s_creators().erase(m_name);
49 }
50 }
51
52 std::shared_ptr<Sigma2Process> create()const{
53 return std::make_shared<T>();
54 }
55
56 private:
57
58 std::string m_name;
59
60 };
61
62 private:
63 static std::map<std::string, const ICreator*> &s_creators();
64
65 };
66}
67#endif
std::shared_ptr< Sigma2Process > create() const
virtual std::shared_ptr< Sigma2Process > create() const =0
static std::map< std::string, const ICreator * > & s_creators()
static function to instantiate map of string name Vs. creator object on first use
static std::shared_ptr< Sigma2Process > create(const std::string &procName)