CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/FWCore/Framework/interface/SourceFactory.h

Go to the documentation of this file.
00001 #ifndef FWCore_Framework_SourceFactory_h
00002 #define FWCore_Framework_SourceFactory_h
00003 // -*- C++ -*-
00004 //
00005 // Package:     Framework
00006 // Class  :     SourceFactory
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 #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFillerPluginFactory.h"
00029 
00030 // forward declarations
00031 
00032 namespace edm {
00033    class EventSetupRecordIntervalFinder;
00034    class ParameterSet;
00035 
00036    namespace eventsetup {
00037       class DataProxyProvider;
00038       class EventSetupsController;
00039       
00040       template<class T>
00041          void addProviderTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent, const DataProxyProvider*) 
00042       {
00043             boost::shared_ptr<DataProxyProvider> pProvider(iComponent);
00044             ComponentDescription description = pProvider->description();
00045             description.isSource_=true;
00046             pProvider->setDescription(description);
00047             iProvider.add(pProvider);
00048       }
00049       template<class T>
00050          void addProviderTo(EventSetupProvider& /* iProvider */, boost::shared_ptr<T> /*iComponent*/, const void*) 
00051       {
00052             //do nothing
00053       }
00054       
00055       struct SourceMakerTraits {
00056          typedef EventSetupRecordIntervalFinder base_type;
00057          static std::string name();
00058          template<class T>
00059             static void addTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent)
00060             {
00061                //a source does not always have to be a provider
00062                addProviderTo(iProvider, iComponent, static_cast<const T*>(0));
00063                boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00064                iProvider.add(pFinder);
00065             }
00066                
00067          static boost::shared_ptr<base_type> const* getAlreadyMadeComponent(EventSetupsController const& esController,
00068                                                                        ParameterSet const& iConfiguration);
00069 
00070          static void putComponent(EventSetupsController& esController,
00071                                   ParameterSet const& iConfiguration,
00072                                   boost::shared_ptr<base_type> const& component);
00073       };
00074       template< class TType>
00075          struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits,TType> {};
00076       typedef  ComponentFactory<SourceMakerTraits> SourceFactory ;
00077       
00078       typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<edm::eventsetup::SourceMakerTraits>* ()> SourcePluginFactory;
00079    }
00080 }
00081 
00082 #define DEFINE_FWK_EVENTSETUP_SOURCE(type) \
00083 DEFINE_EDM_PLUGIN (edm::eventsetup::SourcePluginFactory,edm::eventsetup::SourceMaker<type>,#type); \
00084 DEFINE_DESC_FILLER_FOR_ESSOURCES(type)
00085 
00086 #endif