Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:49

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       template <class T>
0057       static void addTo(EventSetupProvider& iProvider,
0058                         std::shared_ptr<T> iComponent,
0059                         ParameterSet const& iConfiguration,
0060                         bool matchesPreceding) {
0061         if (matchesPreceding) {
0062           logInfoWhenSharing(iConfiguration);
0063         }
0064         //a source does not always have to be a provider
0065         addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
0066         std::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
0067         iProvider.add(pFinder);
0068       }
0069       static void replaceExisting(EventSetupProvider& iProvider,
0070                                   std::shared_ptr<EventSetupRecordIntervalFinder> iComponent);
0071 
0072       static std::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
0073                                                                        ParameterSet const& iConfiguration);
0074 
0075       static void putComponent(EventSetupsController& esController,
0076                                ParameterSet const& iConfiguration,
0077                                std::shared_ptr<base_type> const& component);
0078 
0079       static void logInfoWhenSharing(ParameterSet const& iConfiguration);
0080     };
0081 
0082     template <class TType>
0083     struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits, TType> {};
0084     typedef ComponentFactory<SourceMakerTraits> SourceFactory;
0085 
0086     typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<edm::eventsetup::SourceMakerTraits>*()>
0087         SourcePluginFactory;
0088   }  // namespace eventsetup
0089 }  // namespace edm
0090 
0091 #define DEFINE_FWK_EVENTSETUP_SOURCE(type)                                                            \
0092   DEFINE_EDM_PLUGIN(edm::eventsetup::SourcePluginFactory, edm::eventsetup::SourceMaker<type>, #type); \
0093   DEFINE_DESC_FILLER_FOR_ESSOURCES(type)
0094 
0095 #endif