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 DataProxyProvider;
38  class EventSetupsController;
39 
40  template <class T>
41  void addProviderTo(EventSetupProvider& iProvider, std::shared_ptr<T> iComponent, const DataProxyProvider*) {
42  std::shared_ptr<DataProxyProvider> 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  template <class T>
57  static void addTo(EventSetupProvider& iProvider,
58  std::shared_ptr<T> iComponent,
59  ParameterSet const& iConfiguration,
60  bool matchesPreceding) {
61  if (matchesPreceding) {
62  logInfoWhenSharing(iConfiguration);
63  }
64  //a source does not always have to be a provider
65  addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
66  std::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
67  iProvider.add(pFinder);
68  }
69  static void replaceExisting(EventSetupProvider& iProvider,
70  std::shared_ptr<EventSetupRecordIntervalFinder> iComponent);
71 
72  static std::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
73  ParameterSet const& iConfiguration);
74 
75  static void putComponent(EventSetupsController& esController,
76  ParameterSet const& iConfiguration,
77  std::shared_ptr<base_type> const& component);
78 
79  static void logInfoWhenSharing(ParameterSet const& iConfiguration);
80  };
81 
82  template <class TType>
83  struct SourceMaker : public ComponentMaker<edm::eventsetup::SourceMakerTraits, TType> {};
85 
88  } // namespace eventsetup
89 } // namespace edm
90 
91 #define DEFINE_FWK_EVENTSETUP_SOURCE(type) \
92  DEFINE_EDM_PLUGIN(edm::eventsetup::SourcePluginFactory, edm::eventsetup::SourceMaker<type>, #type); \
93  DEFINE_DESC_FILLER_FOR_ESSOURCES(type)
94 
95 #endif
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:57
ComponentFactory< SourceMakerTraits > SourceFactory
Definition: SourceFactory.h:84
void add(std::shared_ptr< DataProxyProvider >)
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 addProviderTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, const DataProxyProvider *)
Definition: SourceFactory.h:41