CMS 3D CMS Logo

LooperFactory.h
Go to the documentation of this file.
1 #ifndef FWCore_Framework_LooperFactory_h
2 #define FWCore_Framework_LooperFactory_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : LooperFactory
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
28 
29 // forward declarations
30 namespace edm {
31  class EDLooperBase;
33  class ParameterSet;
34 
35  namespace eventsetup {
36 
37  class DataProxyProvider;
38  class EventSetupsController;
39 
40  namespace looper {
41  template <class T>
42  void addProviderTo(EventSetupProvider& iProvider, std::shared_ptr<T> iComponent, const DataProxyProvider*) {
43  std::shared_ptr<DataProxyProvider> pProvider(iComponent);
44  ComponentDescription description = pProvider->description();
45  description.isSource_ = true;
46  description.isLooper_ = true;
47  if (description.label_ == "@main_looper") {
48  //remove the 'hidden' label so that es_prefer statements will work
49  description.label_ = "";
50  }
51  pProvider->setDescription(description);
52  iProvider.add(pProvider);
53  }
54  template <class T>
55  void addProviderTo(EventSetupProvider& /* iProvider */, std::shared_ptr<T> /*iComponent*/, const void*) {
56  //do nothing
57  }
58 
59  template <class T>
61  std::shared_ptr<T> iComponent,
63  std::shared_ptr<EventSetupRecordIntervalFinder> pFinder(iComponent);
64 
65  ComponentDescription description = pFinder->descriptionForFinder();
66  description.isSource_ = true;
67  description.isLooper_ = true;
68  if (description.label_ == "@main_looper") {
69  //remove the 'hidden' label so that es_prefer statements will work
70  description.label_ = "";
71  }
72  pFinder->setDescriptionForFinder(description);
73 
74  iProvider.add(pFinder);
75  }
76  template <class T>
77  void addFinderTo(EventSetupProvider& /* iProvider */, std::shared_ptr<T> /*iComponent*/, const void*) {
78  //do nothing
79  }
80  } // namespace looper
83  static std::string name();
84  template <class T>
85  static void addTo(EventSetupProvider& iProvider, std::shared_ptr<T> iComponent, ParameterSet const&, bool) {
86  //a looper does not always have to be a provider or a finder
87  looper::addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
88  looper::addFinderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
89  }
90 
91  static void replaceExisting(EventSetupProvider& iProvider, std::shared_ptr<EDLooperBase> iComponent);
92 
93  static std::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
94  ParameterSet const& iConfiguration);
95  static void putComponent(EventSetupsController& esController,
96  ParameterSet const& iConfiguration,
97  std::shared_ptr<base_type> const& component);
98  };
99  template <class TType>
100  struct LooperMaker : public ComponentMaker<edm::eventsetup::LooperMakerTraits, TType> {};
102 
104  } // namespace eventsetup
105 } // namespace edm
106 
107 #define DEFINE_FWK_LOOPER(type) \
108  DEFINE_EDM_PLUGIN(edm::eventsetup::LooperPluginFactory, edm::eventsetup::LooperMaker<type>, #type)
109 
110 #endif
ComponentFactory< LooperMakerTraits > LooperFactory
Definition: looper.py:1
void add(std::shared_ptr< DataProxyProvider >)
static void addTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, ParameterSet const &, bool)
Definition: LooperFactory.h:85
void addProviderTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, const DataProxyProvider *)
Definition: LooperFactory.h:42
void addFinderTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, const EventSetupRecordIntervalFinder *)
Definition: LooperFactory.h:60
HLT enums.