All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
larsim/larsim/EventWeight/Base/WeightCalcCreator.h
Go to the documentation of this file.
1 #ifndef _WEIGHTCALCCREATOR_H_
2 #define _WEIGHTCALCCREATOR_H_
3 
4 #include <iostream>
5 #include <string>
6 
7 namespace evwgh {
8  class WeightCalc;
9 
11  {
12  public:
13  WeightCalcCreator(const std::string& classname);
14  virtual ~WeightCalcCreator() = default;
15 
16  virtual WeightCalc* Create() = 0;
17  };
18 
19  template <class T>
21  {
22  public:
23  WeightCalcImpl<T>(const std::string& classname) : WeightCalcCreator(classname) {std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;}
24  virtual ~WeightCalcImpl<T>() {}
25  virtual WeightCalc* Create() { return new T; }
26  };
27 
28 #define DECLARE_WEIGHTCALC(wghcalc) \
29  private: \
30  static const WeightCalcImpl<wghcalc> creator;
31 
32 #define REGISTER_WEIGHTCALC(wghcalc) \
33  const WeightCalcImpl<wghcalc> wghcalc::creator(#wghcalc);
34 }
35 
36 #endif // _WEIGHTCALCFACTORY_H_
virtual WeightCalc * Create()=0
virtual ~WeightCalcCreator()=default
BEGIN_PROLOG could also be cout