00001 #ifndef Framework_SourceFactory_h
00002 #define Framework_SourceFactory_h
00003
00004
00005
00006
00007
00016
00017
00018
00019
00020
00021
00022
00023 #include <string>
00024 #include "boost/shared_ptr.hpp"
00025
00026
00027 #include "FWCore/Framework/interface/ComponentFactory.h"
00028 #include "FWCore/Framework/interface/EventSetupProvider.h"
00029
00030
00031
00032 namespace edm {
00033 class EventSetupRecordIntervalFinder;
00034
00035 namespace eventsetup {
00036 class DataProxyProvider;
00037
00038 template<class T>
00039 void addProviderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const DataProxyProvider*)
00040 {
00041 boost::shared_ptr<DataProxyProvider> pProvider(iComponent);
00042 ComponentDescription description = pProvider->description();
00043 description.isSource_=true;
00044 pProvider->setDescription(description);
00045 iProvider.add(pProvider);
00046 }
00047 template<class T>
00048 void addProviderTo(EventSetupProvider& , boost::shared_ptr<T> , const void*)
00049 {
00050
00051 }
00052
00053 struct SourceMakerTraits {
00054 typedef EventSetupRecordIntervalFinder base_type;
00055 static std::string name();
00056 template<class T>
00057 static void addTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent)
00058 {
00059
00060 addProviderTo(iProvider, iComponent, static_cast<const T*>(0));
00061 boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00062 iProvider.add(pFinder);
00063 }
00064
00065 };
00066 template< class TType>
00067 struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits,TType> {};
00068 typedef ComponentFactory<SourceMakerTraits> SourceFactory ;
00069
00070 typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<edm::eventsetup::SourceMakerTraits>* ()> SourcePluginFactory;
00071 }
00072 }
00073
00074 #define DEFINE_FWK_EVENTSETUP_SOURCE(type) \
00075 DEFINE_EDM_PLUGIN (edm::eventsetup::SourcePluginFactory,edm::eventsetup::SourceMaker<type>,#type)
00076
00077 #define DEFINE_ANOTHER_FWK_EVENTSETUP_SOURCE(type) \
00078 DEFINE_EDM_PLUGIN (edm::eventsetup::SourcePluginFactory,edm::eventsetup::SourceMaker<type>,#type)
00079
00080 #endif