CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/src/FWCore/Framework/interface/LooperFactory.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_LooperFactory_h
00002 #define FWCore_Framework_LooperFactory_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     LooperFactory
00007 // 
00016 //
00017 // Author:      Chris Jones
00018 // Created:     Wed May 25 18:01:38 EDT 2005
00019 //
00020 
00021 // system include files
00022 #include <string>
00023 #include "boost/shared_ptr.hpp"
00024 
00025 // user include files
00026 #include "FWCore/Framework/interface/ComponentFactory.h"
00027 #include "FWCore/Framework/interface/EventSetupProvider.h"
00028 
00029 // forward declarations
00030 namespace edm {
00031    class EDLooperBase;
00032    class EventSetupRecordIntervalFinder;
00033 
00034    namespace eventsetup {
00035       class DataProxyProvider;
00036       namespace looper {
00037       template<class T>
00038          void addProviderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const DataProxyProvider*) 
00039       {
00040             boost::shared_ptr<DataProxyProvider> pProvider(iComponent);
00041             ComponentDescription description = pProvider->description();
00042             description.isSource_=true;
00043             description.isLooper_=true;
00044             if(description.label_ =="@main_looper") {
00045                //remove the 'hidden' label so that es_prefer statements will work
00046                description.label_ ="";
00047             }
00048             pProvider->setDescription(description);
00049             iProvider.add(pProvider);
00050       }
00051       template<class T>
00052          void addProviderTo(EventSetupProvider& /* iProvider */, boost::shared_ptr<T> /*iComponent*/, const void*) 
00053       {
00054             //do nothing
00055       }
00056 
00057       template<class T>
00058         void addFinderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const EventSetupRecordIntervalFinder*) 
00059       {
00060           boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00061 
00062           ComponentDescription description = pFinder->descriptionForFinder();
00063           description.isSource_=true;
00064           description.isLooper_=true;
00065           if(description.label_ =="@main_looper") {
00066             //remove the 'hidden' label so that es_prefer statements will work
00067             description.label_ ="";
00068           }
00069           pFinder->setDescriptionForFinder(description);
00070           
00071           iProvider.add(pFinder);
00072       }
00073       template<class T>
00074         void addFinderTo(EventSetupProvider& /* iProvider */, boost::shared_ptr<T> /*iComponent*/, const void*) 
00075       {
00076           //do nothing
00077       }
00078       }
00079       struct LooperMakerTraits {
00080          typedef EDLooperBase base_type;
00081          static std::string name();
00082          template<class T>
00083             static void addTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent)
00084             {
00085                //a looper does not always have to be a provider or a finder
00086                looper::addProviderTo(iProvider, iComponent, static_cast<const T*>(0));
00087                looper::addFinderTo(iProvider, iComponent, static_cast<const T*>(0));
00088             }
00089                
00090       };
00091       template< class TType>
00092          struct LooperMaker : public ComponentMaker<edm::eventsetup::LooperMakerTraits,TType> {};
00093       typedef  ComponentFactory<LooperMakerTraits> LooperFactory ;
00094       
00095       typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<LooperMakerTraits>* ()> LooperPluginFactory;
00096    }
00097 }
00098 
00099 #define DEFINE_FWK_LOOPER(type) \
00100 DEFINE_EDM_PLUGIN (edm::eventsetup::LooperPluginFactory,edm::eventsetup::LooperMaker<type>,#type)
00101 
00102 #endif