00001 #ifndef Framework_ComponentMaker_h
00002 #define Framework_ComponentMaker_h
00003
00004
00005
00006
00007
00016
00017
00018
00019
00020
00021
00022
00023 #include <string>
00024 #include "boost/shared_ptr.hpp"
00025
00026
00027 #include "FWCore/Framework/interface/ComponentDescription.h"
00028 #include "FWCore/Framework/interface/DataProxyProvider.h"
00029 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00030 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00031
00032
00033
00034 namespace edm {
00035 namespace eventsetup {
00036 class EventSetupProvider;
00037 class DataProxyProvider;
00038
00039 template <class T>
00040 class ComponentMakerBase {
00041 public:
00042 virtual ~ComponentMakerBase() {}
00043 typedef typename T::base_type base_type;
00044 virtual boost::shared_ptr<base_type> addTo(EventSetupProvider& iProvider,
00045 ParameterSet const& iConfiguration,
00046 std::string const& iProcessName,
00047 ReleaseVersion const& iVersion,
00048 PassID const& iPass) const = 0;
00049 };
00050
00051 template <class T, class TComponent>
00052 class ComponentMaker : public ComponentMakerBase<T>
00053 {
00054
00055 public:
00056 ComponentMaker() {}
00057
00058 typedef typename T::base_type base_type;
00059
00060
00061 virtual boost::shared_ptr<base_type> addTo(EventSetupProvider& iProvider,
00062 ParameterSet const& iConfiguration,
00063 std::string const& iProcessName,
00064 ReleaseVersion const& iVersion,
00065 PassID const& iPass) const;
00066
00067
00068
00069
00070
00071 private:
00072 ComponentMaker(const ComponentMaker&);
00073
00074 const ComponentMaker& operator=(const ComponentMaker&);
00075
00076 void setDescription(DataProxyProvider* iProv, const ComponentDescription& iDesc) const {
00077 iProv->setDescription(iDesc);
00078 }
00079 void setDescriptionForFinder(EventSetupRecordIntervalFinder* iFinder, const ComponentDescription& iDesc) const {
00080 iFinder->setDescriptionForFinder(iDesc);
00081 }
00082 void setPostConstruction(DataProxyProvider* iProv, const edm::ParameterSet& iPSet) const {
00083
00084
00085 iProv->setAppendToDataLabel(iPSet);
00086 }
00087 void setDescription(void*, const ComponentDescription&) const {
00088 }
00089 void setDescriptionForFinder(void*, const ComponentDescription&) const {
00090 }
00091 void setPostConstruction(void*, const edm::ParameterSet&) const {
00092 }
00093
00094
00095 };
00096
00097 template< class T, class TComponent>
00098 boost::shared_ptr<typename ComponentMaker<T,TComponent>::base_type>
00099 ComponentMaker<T,TComponent>:: addTo(EventSetupProvider& iProvider,
00100 ParameterSet const& iConfiguration,
00101 std::string const& iProcessName,
00102 ReleaseVersion const& iVersion,
00103 PassID const& iPass) const
00104 {
00105 boost::shared_ptr<TComponent> component(new TComponent(iConfiguration));
00106
00107 ComponentDescription description;
00108 description.type_ = iConfiguration.template getParameter<std::string>("@module_type");
00109 description.label_ = iConfiguration.template getParameter<std::string>("@module_label");
00110
00111 description.releaseVersion_ = iVersion;
00112 description.pid_ = iConfiguration.id();
00113 description.processName_ = iProcessName;
00114 description.passID_ = iPass;
00115
00116 this->setDescription(component.get(),description);
00117 this->setDescriptionForFinder(component.get(),description);
00118 this->setPostConstruction(component.get(),iConfiguration);
00119 T::addTo(iProvider, component);
00120 return component;
00121 }
00122 }
00123 }
00124 #endif