CMS 3D CMS Logo

SourceFactory.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_SourceFactory_h
2 #define FWCore_Framework_SourceFactory_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : SourceFactory
7 //
16 //
17 // Author: Chris Jones
18 // Created: Wed May 25 18:01:38 EDT 2005
19 //
20 
21 // system include files
22 #include <memory>
23 #include <string>
24 
25 // user include files
29 
30 // forward declarations
31 
32 namespace edm {
34  class ParameterSet;
35 
36  namespace eventsetup {
37  class ESProductResolverProvider;
38  class EventSetupsController;
39 
40  template <class T>
41  void addProviderTo(EventSetupProvider& iProvider, std::shared_ptr<T> iComponent, const ESProductResolverProvider*) {
42  std::shared_ptr<ESProductResolverProvider> pProvider(iComponent);
43  ComponentDescription description = pProvider->description();
44  description.isSource_ = true;
45  pProvider->setDescription(description);
46  iProvider.add(pProvider);
47  }
48  template <class T>
49  void addProviderTo(EventSetupProvider& /* iProvider */, std::shared_ptr<T> /*iComponent*/, const void*) {
50  //do nothing
51  }
52 
55  static std::string name();
56  static std::string const& baseType();
57  template <class T>
58  static void addTo(EventSetupProvider& iProvider,
59  std::shared_ptr<T> iComponent,
60  ParameterSet const& iConfiguration,
61  bool matchesPreceding) {
62  if (matchesPreceding) {
63  logInfoWhenSharing(iConfiguration);
64  }
65  //a source does not always have to be a provider
66  addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
67  std::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
68  iProvider.add(pFinder);
69  }
70  static void replaceExisting(EventSetupProvider& iProvider,
71  std::shared_ptr<EventSetupRecordIntervalFinder> iComponent);
72 
73  static std::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
74  ParameterSet const& iConfiguration);
75 
76  static void putComponent(EventSetupsController& esController,
77  ParameterSet const& iConfiguration,
78  std::shared_ptr<base_type> const& component);
79 
80  static void logInfoWhenSharing(ParameterSet const& iConfiguration);
81  };
82 
83  template <class TType>
84  struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits, TType> {};
86 
89  } // namespace eventsetup
90 } // namespace edm
91 
92 #define DEFINE_FWK_EVENTSETUP_SOURCE(type) \
93  DEFINE_EDM_PLUGIN(edm::eventsetup::SourcePluginFactory, edm::eventsetup::SourceMaker<type>, #type); \
94  DEFINE_DESC_FILLER_FOR_ESSOURCES(type)
95 
96 #endif
static std::string const & baseType()
void addProviderTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, const ESProductResolverProvider *)
Definition: SourceFactory.h:41
static void replaceExisting(EventSetupProvider &iProvider, std::shared_ptr< EventSetupRecordIntervalFinder > iComponent)
static void addTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, ParameterSet const &iConfiguration, bool matchesPreceding)
Definition: SourceFactory.h:58
ComponentFactory< SourceMakerTraits > SourceFactory
Definition: SourceFactory.h:85
EventSetupRecordIntervalFinder base_type
Definition: SourceFactory.h:54
static void logInfoWhenSharing(ParameterSet const &iConfiguration)
static std::shared_ptr< base_type > getComponentAndRegisterProcess(EventSetupsController &esController, ParameterSet const &iConfiguration)
HLT enums.
static void putComponent(EventSetupsController &esController, ParameterSet const &iConfiguration, std::shared_ptr< base_type > const &component)
void add(std::shared_ptr< ESProductResolverProvider >)