ThinSliceDriverRegistry.cxx
Go to the documentation of this file.
2 #include "ThinSliceDriver.h"
4 
5 #include <iostream>
6 #include <stdexcept>
7 
9 
11  if(!fInstance) {
12  static protoana::ThinSliceDriverRegistry * manager_ptr = 0 ;
13  if (!manager_ptr) {
14  manager_ptr = new protoana::ThinSliceDriverRegistry;
15  }
16  protoana::ThinSliceDriverRegistry & manager = * manager_ptr;
17  fInstance = & manager;
18  }
19  return fInstance;
20 }
21 
23 
25  //Clean();
26 }
27 
29  std::cout << "####ThinSliceDriverRegistry####" << std::endl;
30  std::cout << "Available Drivers:" << std::endl;
31  for (auto it = fFactories.begin(); it != fFactories.end(); ++it) {
32  std::cout << "Driver: " << it->first << std::endl;
33  }
34  std::cout << "###############################" << std::endl << std::endl;
35 }
36 
39  fFactories[name] = factory;
40 }
41 
43  const std::string & name,
44  const fhicl::ParameterSet & extra_options) {
45  if (fFactories.find(name) == fFactories.end()) {
46  std::string message = "Could not find ThinSliceDriver of type: " +
47  name;
48  throw std::runtime_error(message);
49  }
50  else {
51  return fFactories[name]->Instantiate(extra_options);
52  }
53 }
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
void AddFactory(std::string name, BaseThinSliceDriverFactory *factory)
static ThinSliceDriverRegistry * Instance()
std::map< std::string, BaseThinSliceDriverFactory * > fFactories
static ThinSliceDriverRegistry * fInstance
ThinSliceDriver * GetDriver(const std::string &name, const fhicl::ParameterSet &extra_options)
QTextStream & endl(QTextStream &s)