00001 #ifndef Framework_LooperFactory_h
00002 #define Framework_LooperFactory_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 namespace edm {
00032 class EDLooper;
00033 class EventSetupRecordIntervalFinder;
00034
00035 namespace eventsetup {
00036 class DataProxyProvider;
00037 namespace looper {
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 description.isLooper_=true;
00045 if(description.label_ =="@main_looper") {
00046
00047 description.label_ ="";
00048 }
00049 pProvider->setDescription(description);
00050 iProvider.add(pProvider);
00051 }
00052 template<class T>
00053 void addProviderTo(EventSetupProvider& , boost::shared_ptr<T> , const void*)
00054 {
00055
00056 }
00057
00058 template<class T>
00059 void addFinderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const EventSetupRecordIntervalFinder*)
00060 {
00061 boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00062
00063 ComponentDescription description = pFinder->descriptionForFinder();
00064 description.isSource_=true;
00065 description.isLooper_=true;
00066 if(description.label_ =="@main_looper") {
00067
00068 description.label_ ="";
00069 }
00070 pFinder->setDescriptionForFinder(description);
00071
00072 iProvider.add(pFinder);
00073 }
00074 template<class T>
00075 void addFinderTo(EventSetupProvider& , boost::shared_ptr<T> , const void*)
00076 {
00077
00078 }
00079 }
00080 struct LooperMakerTraits {
00081 typedef EDLooper base_type;
00082 static std::string name();
00083 template<class T>
00084 static void addTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent)
00085 {
00086
00087 looper::addProviderTo(iProvider, iComponent, static_cast<const T*>(0));
00088 looper::addFinderTo(iProvider, iComponent, static_cast<const T*>(0));
00089 }
00090
00091 };
00092 template< class TType>
00093 struct LooperMaker : public ComponentMaker<edm::eventsetup::LooperMakerTraits,TType> {};
00094 typedef ComponentFactory<LooperMakerTraits> LooperFactory ;
00095
00096 typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<LooperMakerTraits>* ()> LooperPluginFactory;
00097 }
00098 }
00099
00100 #define DEFINE_FWK_LOOPER(type) \
00101 DEFINE_EDM_PLUGIN (edm::eventsetup::LooperPluginFactory,edm::eventsetup::LooperMaker<type>,#type)
00102
00103 #define DEFINE_ANOTHER_FWK_LOOPER(type) \
00104 DEFINE_EDM_PLUGIN (edm::eventsetup::LooperPluginFactory,edm::eventsetup::LooperMaker<type>,#type)
00105
00106 #endif