CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/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,
00088                            boost::shared_ptr<T> iComponent,
00089                            ParameterSet const&,
00090                            bool)
00091             {
00092                //a looper does not always have to be a provider or a finder
00093                looper::addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
00094                looper::addFinderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
00095             }
00096 
00097          static void replaceExisting(EventSetupProvider& iProvider, boost::shared_ptr<EDLooperBase> iComponent); 
00098 
00099          static boost::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
00100                                                                             ParameterSet const& iConfiguration);               
00101          static void putComponent(EventSetupsController& esController,
00102                                   ParameterSet const& iConfiguration,
00103                                   boost::shared_ptr<base_type> const& component);
00104       };
00105       template< class TType>
00106          struct LooperMaker : public ComponentMaker<edm::eventsetup::LooperMakerTraits,TType> {};
00107       typedef  ComponentFactory<LooperMakerTraits> LooperFactory ;
00108       
00109       typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<LooperMakerTraits>* ()> LooperPluginFactory;
00110    }
00111 }
00112 
00113 #define DEFINE_FWK_LOOPER(type) \
00114 DEFINE_EDM_PLUGIN (edm::eventsetup::LooperPluginFactory,edm::eventsetup::LooperMaker<type>,#type)
00115 
00116 #endif