LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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  public:
12  WeightCalcCreator(const std::string& classname);
13  virtual ~WeightCalcCreator() = default;
14 
15  virtual WeightCalc* Create() = 0;
16  };
17 
18  template <class T>
20  public:
21  WeightCalcImpl<T>(const std::string& classname) : WeightCalcCreator(classname)
22  {
23  std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;
24  }
25  virtual ~WeightCalcImpl<T>() {}
26  virtual WeightCalc* Create() { return new T; }
27  };
28 
29 #define DECLARE_WEIGHTCALC(wghcalc) \
30 private: \
31  static const WeightCalcImpl<wghcalc> creator;
32 
33 #define REGISTER_WEIGHTCALC(wghcalc) const WeightCalcImpl<wghcalc> wghcalc::creator(#wghcalc);
34 }
35 
36 #endif // _WEIGHTCALCFACTORY_H_
virtual WeightCalc * Create()=0
virtual WeightCalc * Create()
WeightCalcCreator(const std::string &classname)
virtual ~WeightCalcCreator()=default