LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
WeightCalcCreator.h
Go to the documentation of this file.
1 #ifndef _WEIGHTCALCCREATOR_H_
2 #define _WEIGHTCALCCREATOR_H_
3 
4 #include "WeightCalc.h"
5 
6 namespace evwgh {
8  {
9  public:
10  WeightCalcCreator(const std::string& classname);
11  virtual ~WeightCalcCreator() {};
12 
13  virtual WeightCalc* Create() = 0;
14  };
15 
16  template <class T>
18  {
19  public:
20  WeightCalcImpl<T>(const std::string& classname) : WeightCalcCreator(classname) {std::cout << __PRETTY_FUNCTION__ << " called." << std::endl;}
21  virtual ~WeightCalcImpl<T>() {}
22  virtual WeightCalc* Create() { return new T; }
23  };
24 
25 #define DECLARE_WEIGHTCALC(wghcalc) \
26  private: \
27  static const WeightCalcImpl<wghcalc> creator;
28 
29 #define REGISTER_WEIGHTCALC(wghcalc) \
30  const WeightCalcImpl<wghcalc> wghcalc::creator(#wghcalc);
31 }
32 
33 #endif // _WEIGHTCALCFACTORY_H_
virtual WeightCalc * Create()=0
virtual WeightCalc * Create()
WeightCalcCreator(const std::string &classname)