Go to the documentation of this file.00001 #ifndef FWCore_Framework_SourceFactory_h
00002 #define FWCore_Framework_SourceFactory_h
00003
00004
00005
00006
00007
00016
00017
00018
00019
00020
00021
00022 #include <string>
00023 #include "boost/shared_ptr.hpp"
00024
00025
00026 #include "FWCore/Framework/interface/ComponentFactory.h"
00027 #include "FWCore/Framework/interface/EventSetupProvider.h"
00028 #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFillerPluginFactory.h"
00029
00030
00031
00032 namespace edm {
00033 class EventSetupRecordIntervalFinder;
00034 class ParameterSet;
00035
00036 namespace eventsetup {
00037 class DataProxyProvider;
00038 class EventSetupsController;
00039
00040 template<class T>
00041 void addProviderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const DataProxyProvider*)
00042 {
00043 boost::shared_ptr<DataProxyProvider> pProvider(iComponent);
00044 ComponentDescription description = pProvider->description();
00045 description.isSource_=true;
00046 pProvider->setDescription(description);
00047 iProvider.add(pProvider);
00048 }
00049 template<class T>
00050 void addProviderTo(EventSetupProvider& , boost::shared_ptr<T> , const void*)
00051 {
00052
00053 }
00054
00055 struct SourceMakerTraits {
00056 typedef EventSetupRecordIntervalFinder base_type;
00057 static std::string name();
00058 template<class T>
00059 static void addTo(EventSetupProvider& iProvider,
00060 boost::shared_ptr<T> iComponent,
00061 ParameterSet const& iConfiguration,
00062 bool matchesPreceding)
00063 {
00064 if (matchesPreceding) {
00065 logInfoWhenSharing(iConfiguration);
00066 }
00067
00068 addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
00069 boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00070 iProvider.add(pFinder);
00071 }
00072 static void replaceExisting(EventSetupProvider& iProvider, boost::shared_ptr<EventSetupRecordIntervalFinder> iComponent);
00073
00074 static boost::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
00075 ParameterSet const& iConfiguration);
00076
00077 static void putComponent(EventSetupsController& esController,
00078 ParameterSet const& iConfiguration,
00079 boost::shared_ptr<base_type> const& component);
00080
00081 static void logInfoWhenSharing(ParameterSet const& iConfiguration);
00082 };
00083
00084 template< class TType>
00085 struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits,TType> {};
00086 typedef ComponentFactory<SourceMakerTraits> SourceFactory ;
00087
00088 typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<edm::eventsetup::SourceMakerTraits>* ()> SourcePluginFactory;
00089 }
00090 }
00091
00092 #define DEFINE_FWK_EVENTSETUP_SOURCE(type) \
00093 DEFINE_EDM_PLUGIN (edm::eventsetup::SourcePluginFactory,edm::eventsetup::SourceMaker<type>,#type); \
00094 DEFINE_DESC_FILLER_FOR_ESSOURCES(type)
00095
00096 #endif