Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-10-10 03:58:37

0001 #ifndef FWCore_Framework_SourceFactory_h
0002 #define FWCore_Framework_SourceFactory_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Framework
0006 // Class  :     SourceFactory
0007 //
0008 /**\class SourceFactory SourceFactory.h FWCore/Framework/interface/SourceFactory.h
0009 
0010  Description: <one line class summary>
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Author:      Chris Jones
0018 // Created:     Wed May 25 18:01:38 EDT 2005
0019 //
0020 
0021 // system include files
0022 #include <memory>
0023 #include <string>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/ComponentFactory.h"
0027 #include "FWCore/Framework/interface/EventSetupProvider.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFillerPluginFactory.h"
0029 
0030 // forward declarations
0031 
0032 namespace edm {
0033   class EventSetupRecordIntervalFinder;
0034   class ParameterSet;
0035 
0036   namespace eventsetup {
0037     class DataProxyProvider;
0038     class EventSetupsController;
0039 
0040     template <class T>
0041     void addProviderTo(EventSetupProvider& iProvider, std::shared_ptr<T> iComponent, const DataProxyProvider*) {
0042       std::shared_ptr<DataProxyProvider> pProvider(iComponent);
0043       ComponentDescription description = pProvider->description();
0044       description.isSource_ = true;
0045       pProvider->setDescription(description);
0046       iProvider.add(pProvider);
0047     }
0048     template <class T>
0049     void addProviderTo(EventSetupProvider& /* iProvider */, std::shared_ptr<T> /*iComponent*/, const void*) {
0050       //do nothing
0051     }
0052 
0053     struct SourceMakerTraits {
0054       typedef EventSetupRecordIntervalFinder base_type;
0055       static std::string name();
0056       static std::string const& baseType();
0057       template <class T>
0058       static void addTo(EventSetupProvider& iProvider,
0059                         std::shared_ptr<T> iComponent,
0060                         ParameterSet const& iConfiguration,
0061                         bool matchesPreceding) {
0062         if (matchesPreceding) {
0063           logInfoWhenSharing(iConfiguration);
0064         }
0065         //a source does not always have to be a provider
0066         addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
0067         std::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
0068         iProvider.add(pFinder);
0069       }
0070       static void replaceExisting(EventSetupProvider& iProvider,
0071                                   std::shared_ptr<EventSetupRecordIntervalFinder> iComponent);
0072 
0073       static std::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
0074                                                                        ParameterSet const& iConfiguration);
0075 
0076       static void putComponent(EventSetupsController& esController,
0077                                ParameterSet const& iConfiguration,
0078                                std::shared_ptr<base_type> const& component);
0079 
0080       static void logInfoWhenSharing(ParameterSet const& iConfiguration);
0081     };
0082 
0083     template <class TType>
0084     struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits, TType> {};
0085     typedef ComponentFactory<SourceMakerTraits> SourceFactory;
0086 
0087     typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<edm::eventsetup::SourceMakerTraits>*()>
0088         SourcePluginFactory;
0089   }  // namespace eventsetup
0090 }  // namespace edm
0091 
0092 #define DEFINE_FWK_EVENTSETUP_SOURCE(type)                                                            \
0093   DEFINE_EDM_PLUGIN(edm::eventsetup::SourcePluginFactory, edm::eventsetup::SourceMaker<type>, #type); \
0094   DEFINE_DESC_FILLER_FOR_ESSOURCES(type)
0095 
0096 #endif