CMS 3D CMS Logo

ComponentMaker.h

Go to the documentation of this file.
00001 #ifndef Framework_ComponentMaker_h
00002 #define Framework_ComponentMaker_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     ComponentMaker
00007 // 
00016 //
00017 // Author:      Chris Jones
00018 // Created:     Wed May 25 16:56:05 EDT 2005
00019 // $Id: ComponentMaker.h,v 1.18 2008/01/17 01:05:20 wmtan Exp $
00020 //
00021 
00022 // system include files
00023 #include <string>
00024 #include "boost/shared_ptr.hpp"
00025 
00026 // user include files
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 // forward declarations
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       //virtual ~ComponentMaker();
00058    typedef typename T::base_type base_type;
00059 
00060       // ---------- const member functions ---------------------
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       // ---------- static member functions --------------------
00068 
00069       // ---------- member functions ---------------------------
00070 
00071    private:
00072       ComponentMaker(const ComponentMaker&); // stop default
00073 
00074       const ComponentMaker& operator=(const ComponentMaker&); // stop default
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         //The 'appendToDataLabel' parameter was added very late in the development cycle and since
00084         // the ParameterSet is not sent to the base class we must set the value after construction
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       // ---------- member data --------------------------------
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

Generated on Tue Jun 9 17:35:20 2009 for CMSSW by  doxygen 1.5.4