All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/SBNEventWeight/Base/WeightCalcCreator.h
Go to the documentation of this file.
1 #ifndef _SBN_WEIGHTCALCCREATOR_H_
2 #define _SBN_WEIGHTCALCCREATOR_H_
3 
4 // Imported from LArSoft's larsim EventWeight
5 
6 #include <iostream>
7 #include <string>
8 
9 namespace sbn {
10  namespace evwgh {
11 
12 class WeightCalc;
13 
15 public:
16  WeightCalcCreator(const std::string& classname);
17 
18  virtual ~WeightCalcCreator() = default;
19 
20  virtual WeightCalc* Create() = 0;
21 };
22 
23 
24 template <class T>
26 public:
27  WeightCalcImpl<T>(const std::string& classname)
28  : WeightCalcCreator(classname) {}
29 
30  virtual ~WeightCalcImpl<T>() {}
31 
32  virtual WeightCalc* Create() { return new T; }
33 };
34 
35  } // namespace evwgh
36 } // namespace sbn
37 
38 
39 #define DECLARE_WEIGHTCALC(wghcalc) \
40 private: \
41  static const sbn::evwgh::WeightCalcImpl<wghcalc> creator;
42 
43 #define REGISTER_WEIGHTCALC(wghcalc) \
44 const sbn::evwgh::WeightCalcImpl<wghcalc> wghcalc::creator(#wghcalc);
45 
46 #endif // _SBN_WEIGHTCALCFACTORY_H_
47 
virtual ~WeightCalcCreator()=default
virtual WeightCalc * Create()=0