All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
sbncode/sbncode/SBNEventWeight/Base/WeightCalcFactory.cxx
Go to the documentation of this file.
1 #include "WeightCalcFactory.h"
2 #include "WeightCalcCreator.h"
3 
4 namespace sbn {
5  namespace evwgh {
6 
7 WeightCalc* WeightCalcFactory::Create(const std::string& wghcalcname) {
8  std::map<std::string, WeightCalcCreator*>::iterator i;
9  i = GetTable().find(wghcalcname);
10 
11  if (i != GetTable().end()) {
12  return i->second->Create();
13  }
14  else {
15  return (WeightCalc*) NULL;
16  }
17 }
18 
19 
21  const std::string& wghcalcname,
22  WeightCalcCreator* creator) {
23  GetTable()[wghcalcname] = creator;
24 }
25 
26 
27 std::map<std::string, WeightCalcCreator*>& WeightCalcFactory::GetTable() {
28  static std::map<std::string, WeightCalcCreator*> table;
29  return table;
30 }
31 
32  } // namespace evwgh
33 } // namespace sbn
34 
static void Register(const std::string &wghcalcname, WeightCalcCreator *creator)
auto end(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:585
static std::map< std::string, WeightCalcCreator * > & GetTable()
static WeightCalc * Create(const std::string &classname)