CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/Framework/interface/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 //
00020 
00021 // system include files
00022 #include <string>
00023 #include "boost/shared_ptr.hpp"
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/ComponentDescription.h"
00027 #include "FWCore/Framework/interface/DataProxyProvider.h"
00028 #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
00029 
00030 // forward declarations
00031 
00032 namespace edm {
00033    namespace eventsetup {
00034       class EventSetupProvider;
00035       class DataProxyProvider;
00036     
00037       class ComponentMakerBaseHelper
00038       {
00039       public:
00040         virtual ~ComponentMakerBaseHelper() {}
00041       protected:
00042         ComponentDescription createComponentDescription(ParameterSet const& iConfiguration,
00043                                                        std::string const& iProcessName,
00044                                                        ReleaseVersion const& iVersion,
00045                                                        PassID const& iPass) const;
00046       };
00047  
00048       template <class T>
00049       class ComponentMakerBase : private ComponentMakerBaseHelper {
00050       public:
00051          typedef typename T::base_type base_type;
00052          virtual boost::shared_ptr<base_type> addTo(EventSetupProvider& iProvider,
00053                      ParameterSet const& iConfiguration,
00054                      std::string const& iProcessName,
00055                      ReleaseVersion const& iVersion,
00056                      PassID const& iPass) const = 0;
00057       protected:
00058         using ComponentMakerBaseHelper::createComponentDescription;
00059       };
00060       
00061    template <class T, class TComponent>
00062    class ComponentMaker : public ComponentMakerBase<T>
00063    {
00064 
00065    public:
00066    ComponentMaker() {}
00067       //virtual ~ComponentMaker();
00068    typedef typename T::base_type base_type;
00069 
00070       // ---------- const member functions ---------------------
00071    virtual boost::shared_ptr<base_type> addTo(EventSetupProvider& iProvider,
00072                        ParameterSet const& iConfiguration,
00073                        std::string const& iProcessName,
00074                        ReleaseVersion const& iVersion,
00075                        PassID const& iPass) const;
00076    
00077       // ---------- static member functions --------------------
00078 
00079       // ---------- member functions ---------------------------
00080    private:
00081       ComponentMaker(const ComponentMaker&); // stop default
00082 
00083       const ComponentMaker& operator=(const ComponentMaker&); // stop default
00084 
00085       void setDescription(DataProxyProvider* iProv, const ComponentDescription& iDesc) const {
00086         iProv->setDescription(iDesc);
00087       }
00088       void setDescriptionForFinder(EventSetupRecordIntervalFinder* iFinder, const ComponentDescription& iDesc) const {
00089         iFinder->setDescriptionForFinder(iDesc);
00090       }
00091       void setPostConstruction(DataProxyProvider* iProv, const edm::ParameterSet& iPSet) const {
00092         //The 'appendToDataLabel' parameter was added very late in the development cycle and since
00093         // the ParameterSet is not sent to the base class we must set the value after construction
00094         iProv->setAppendToDataLabel(iPSet);
00095       }
00096       void setDescription(void*, const ComponentDescription&) const {
00097       }
00098       void setDescriptionForFinder(void*, const ComponentDescription&) const {
00099       }
00100       void setPostConstruction(void*, const edm::ParameterSet&) const {
00101       }
00102       // ---------- member data --------------------------------
00103 
00104 };
00105 
00106 template< class T, class TComponent>
00107 boost::shared_ptr<typename ComponentMaker<T,TComponent>::base_type>
00108 ComponentMaker<T,TComponent>::addTo(EventSetupProvider& iProvider,
00109                                         ParameterSet const& iConfiguration,
00110                                         std::string const& iProcessName,
00111                                         ReleaseVersion const& iVersion,
00112                                         PassID const& iPass) const
00113 {
00114    boost::shared_ptr<TComponent> component(new TComponent(iConfiguration));
00115    ComponentDescription description =
00116        this->createComponentDescription(iConfiguration,
00117                                         iProcessName,
00118                                         iVersion,
00119                                         iPass);
00120       
00121    this->setDescription(component.get(),description);
00122    this->setDescriptionForFinder(component.get(),description);
00123    this->setPostConstruction(component.get(),iConfiguration);
00124    T::addTo(iProvider, component);
00125    return component;
00126 }
00127    }
00128 }
00129 #endif