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