CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/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    class ParameterSet;
00034 
00035    namespace eventsetup {
00036 
00037       class DataProxyProvider;
00038       class EventSetupsController;
00039 
00040       namespace looper {
00041       template<class T>
00042          void addProviderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const DataProxyProvider*) 
00043       {
00044             boost::shared_ptr<DataProxyProvider> pProvider(iComponent);
00045             ComponentDescription description = pProvider->description();
00046             description.isSource_=true;
00047             description.isLooper_=true;
00048             if(description.label_ =="@main_looper") {
00049                //remove the 'hidden' label so that es_prefer statements will work
00050                description.label_ ="";
00051             }
00052             pProvider->setDescription(description);
00053             iProvider.add(pProvider);
00054       }
00055       template<class T>
00056          void addProviderTo(EventSetupProvider& /* iProvider */, boost::shared_ptr<T> /*iComponent*/, const void*) 
00057       {
00058             //do nothing
00059       }
00060 
00061       template<class T>
00062         void addFinderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const EventSetupRecordIntervalFinder*) 
00063       {
00064           boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00065 
00066           ComponentDescription description = pFinder->descriptionForFinder();
00067           description.isSource_=true;
00068           description.isLooper_=true;
00069           if(description.label_ =="@main_looper") {
00070             //remove the 'hidden' label so that es_prefer statements will work
00071             description.label_ ="";
00072           }
00073           pFinder->setDescriptionForFinder(description);
00074           
00075           iProvider.add(pFinder);
00076       }
00077       template<class T>
00078         void addFinderTo(EventSetupProvider& /* iProvider */, boost::shared_ptr<T> /*iComponent*/, const void*) 
00079       {
00080           //do nothing
00081       }
00082       }
00083       struct LooperMakerTraits {
00084          typedef EDLooperBase base_type;
00085          static std::string name();
00086          template<class T>
00087             static void addTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent)
00088             {
00089                //a looper does not always have to be a provider or a finder
00090                looper::addProviderTo(iProvider, iComponent, static_cast<const T*>(0));
00091                looper::addFinderTo(iProvider, iComponent, static_cast<const T*>(0));
00092             }
00093 
00094          static boost::shared_ptr<base_type> const* getAlreadyMadeComponent(EventSetupsController const& esController,
00095                                                                        ParameterSet const& iConfiguration);               
00096          static void putComponent(EventSetupsController& esController,
00097                                   ParameterSet const& iConfiguration,
00098                                   boost::shared_ptr<base_type> const& component);
00099       };
00100       template< class TType>
00101          struct LooperMaker : public ComponentMaker<edm::eventsetup::LooperMakerTraits,TType> {};
00102       typedef  ComponentFactory<LooperMakerTraits> LooperFactory ;
00103       
00104       typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<LooperMakerTraits>* ()> LooperPluginFactory;
00105    }
00106 }
00107 
00108 #define DEFINE_FWK_LOOPER(type) \
00109 DEFINE_EDM_PLUGIN (edm::eventsetup::LooperPluginFactory,edm::eventsetup::LooperMaker<type>,#type)
00110 
00111 #endif