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  static std::string const& baseType();
86  template <class T>
87  static void addTo(EventSetupProvider& iProvider, std::shared_ptr<T> iComponent, ParameterSet const&, bool) {
88  //a looper does not always have to be a provider or a finder
89  looper::addProviderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
90  looper::addFinderTo(iProvider, iComponent, static_cast<const T*>(nullptr));
91  }
92 
93  static void replaceExisting(EventSetupProvider& iProvider, std::shared_ptr<EDLooperBase> iComponent);
94 
95  static std::shared_ptr<base_type> getComponentAndRegisterProcess(EventSetupsController& esController,
96  ParameterSet const& iConfiguration);
97  static void putComponent(EventSetupsController& esController,
98  ParameterSet const& iConfiguration,
99  std::shared_ptr<base_type> const& component);
100  };
101  template <class TType>
102  struct LooperMaker : public ComponentMaker<edm::eventsetup::LooperMakerTraits, TType> {};
104 
106  } // namespace eventsetup
107 } // namespace edm
108 
109 #define DEFINE_FWK_LOOPER(type) \
110  DEFINE_EDM_PLUGIN(edm::eventsetup::LooperPluginFactory, edm::eventsetup::LooperMaker<type>, #type); \
111  DEFINE_DESC_FILLER_FOR_EDLOOPERS(type)
112 
113 #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:87
void addProviderTo(EventSetupProvider &iProvider, std::shared_ptr< T > iComponent, const DataProxyProvider *)
Definition: LooperFactory.h:43
static std::string const & baseType()
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 >)