ThinSliceDriverFactory.h
Go to the documentation of this file.
1 #ifndef THINSLICEDRIVERFACTORY_H
2 #define THINSLICEDRIVERFACTORY_H
3 
5 #include "ThinSliceDriver.h"
6 
7 #include <string>
8 
9 namespace protoana {
11  public:
12  virtual ThinSliceDriver * Instantiate(
13  const fhicl::ParameterSet & extra_options) = 0;
14 };
15 
16 template <typename T> class ThinSliceDriverFactory
18  public:
19 
22  }
23 
25  const fhicl::ParameterSet & extra_options) {
26  return new T(extra_options);
27  }
28 };
29 }
30 
31 #define DECLARE_THINSLICEDRIVER_FACTORY(driver) \
32  const ThinSliceDriverFactory<driver>& driver##Factory = ThinSliceDriverFactory<driver>(#driver)
33 
34 // support for drivers defined within a namespace
35 // a bit tricky due to cpp macro expansion and the use of "::"
36 // use DECLARE_THINSLICEDRIVER_FACTORY_NS( myns::MyDriver, myns, driverbase ) // without trailing ";"
37 #define DECLARE_THINSLICEDRIVER_FACTORY_NS( driver, nsname, driverbase ) \
38  namespace nsname { \
39  const ThinSliceDriverFactory<driver>& driverbase##Factory = ThinSliceDriverFactory<driver>(#driver); \
40  }
41 
42 #endif
static QCString name
Definition: declinfo.cpp:673
std::string string
Definition: nybbler.cc:12
void AddFactory(std::string name, BaseThinSliceDriverFactory *factory)
ThinSliceDriverFactory(const std::string name)
static ThinSliceDriverRegistry * Instance()
virtual ThinSliceDriver * Instantiate(const fhicl::ParameterSet &extra_options)
virtual ThinSliceDriver * Instantiate(const fhicl::ParameterSet &extra_options)=0