Belle II Software development
EvtGenModelRegister.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <list>
12#include <vector>
13
14class EvtDecayBase;
15
16namespace Belle2 {
24 public:
26 typedef EvtDecayBase* ModelFactory();
27
29 template<class MODEL> class Factory {
30 public:
33 {
35 }
37 static EvtDecayBase* factory()
38 {
39 return new MODEL();
40 }
41 };
42
44 static void registerModel(ModelFactory* factory)
45 {
46 getInstance().m_models.push_back(factory);
47 }
48
52 static std::list<EvtDecayBase*> getModels();
53
54 private:
55
58
63
69
71 std::vector<ModelFactory*> m_models;
72 };
73
75#define B2_EVTGEN_REGISTER_MODEL(classname) namespace {\
76 Belle2::EvtGenModelRegister::Factory<classname> EvtGenModelFactory_##classname; \
77 }
78
80} //Belle2 namespace
Helper Class to easily register new EvtDecayBases for Belle2.
static EvtDecayBase * factory()
Create a new instance of the EvtDecayBase and return the pointer.
Factory()
Constructor to register a model with a given name.
Class to keep a register of all Belle2 EvtDecayBases.
static void registerModel(ModelFactory *factory)
Register a new Model, called by the EvtGenModelRegister::Factory class.
EvtDecayBase * ModelFactory()
Callback type to return a new model instance.
std::vector< ModelFactory * > m_models
List of all registered EvtGenModels.
EvtGenModelRegister & operator=(const EvtGenModelRegister &)=delete
Singleton: private assignment operator.
EvtGenModelRegister(const EvtGenModelRegister &other)=delete
Singleton: private copy constructor.
EvtGenModelRegister()
Singleton: private constructor.
static EvtGenModelRegister & getInstance()
Return reference to the instance.
static std::list< EvtDecayBase * > getModels()
Return a list of models.
Abstract base class for different kinds of events.