CMS 3D CMS Logo

SourceFactory.h

Go to the documentation of this file.
00001 #ifndef Framework_SourceFactory_h
00002 #define 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 // $Id: SourceFactory.h,v 1.18 2007/04/09 23:13:18 chrjones Exp $
00020 //
00021 
00022 // system include files
00023 #include <string>
00024 #include "boost/shared_ptr.hpp"
00025 
00026 // user include files
00027 #include "FWCore/Framework/interface/ComponentFactory.h"
00028 #include "FWCore/Framework/interface/EventSetupProvider.h"
00029 
00030 // forward declarations
00031 
00032 namespace edm {
00033    class EventSetupRecordIntervalFinder;
00034 
00035    namespace eventsetup {
00036       class DataProxyProvider;
00037       
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             pProvider->setDescription(description);
00045             iProvider.add(pProvider);
00046       }
00047       template<class T>
00048          void addProviderTo(EventSetupProvider& /* iProvider */, boost::shared_ptr<T> /*iComponent*/, const void*) 
00049       {
00050             //do nothing
00051       }
00052       
00053       struct SourceMakerTraits {
00054          typedef EventSetupRecordIntervalFinder base_type;
00055          static std::string name();
00056          template<class T>
00057             static void addTo(EventSetupProvider& iProvider, boost::shared_ptr<T> iComponent)
00058             {
00059                //a source does not always have to be a provider
00060                addProviderTo(iProvider, iComponent, static_cast<const T*>(0));
00061                boost::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
00062                iProvider.add(pFinder);
00063             }
00064                
00065       };
00066       template< class TType>
00067          struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits,TType> {};
00068       typedef  ComponentFactory<SourceMakerTraits> SourceFactory ;
00069       
00070       typedef edmplugin::PluginFactory<edm::eventsetup::ComponentMakerBase<edm::eventsetup::SourceMakerTraits>* ()> SourcePluginFactory;
00071    }
00072 }
00073 
00074 #define DEFINE_FWK_EVENTSETUP_SOURCE(type) \
00075 DEFINE_EDM_PLUGIN (edm::eventsetup::SourcePluginFactory,edm::eventsetup::SourceMaker<type>,#type)
00076 
00077 #define DEFINE_ANOTHER_FWK_EVENTSETUP_SOURCE(type) \
00078 DEFINE_EDM_PLUGIN (edm::eventsetup::SourcePluginFactory,edm::eventsetup::SourceMaker<type>,#type)
00079 
00080 #endif

Generated on Tue Jun 9 17:35:52 2009 for CMSSW by  doxygen 1.5.4