CMS 3D CMS Logo

ComponentMaker.h
Go to the documentation of this file.
1 #ifndef Framework_ComponentMaker_h
2 #define Framework_ComponentMaker_h
3 // -*- C++ -*-
4 //
5 // Package: Framework
6 // Class : ComponentMaker
7 //
16 //
17 // Author: Chris Jones
18 // Created: Wed May 25 16:56:05 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 {
33  namespace eventsetup {
34  class EventSetupProvider;
35  class EventSetupsController;
36  class DataProxyProvider;
37 
39  public:
41 
42  protected:
44  };
45 
46  template <class T>
48  public:
49  typedef typename T::base_type base_type;
50  virtual std::shared_ptr<base_type> addTo(EventSetupsController& esController,
51  EventSetupProvider& iProvider,
52  ParameterSet const& iConfiguration,
53  bool replaceExisting) const = 0;
54  };
55 
56  template <class T, class TComponent>
57  class ComponentMaker : public ComponentMakerBase<T> {
58  public:
60  ComponentMaker(const ComponentMaker&) = delete; // stop default
61  const ComponentMaker& operator=(const ComponentMaker&) = delete; // stop default
62  typedef typename T::base_type base_type;
63 
64  // ---------- const member functions ---------------------
65  std::shared_ptr<base_type> addTo(EventSetupsController& esController,
66  EventSetupProvider& iProvider,
67  ParameterSet const& iConfiguration,
68  bool replaceExisting) const override;
69 
70  // ---------- static member functions --------------------
71 
72  // ---------- member functions ---------------------------
73  private:
74  void setDescription(DataProxyProvider* iProv, const ComponentDescription& iDesc) const {
75  iProv->setDescription(iDesc);
76  }
78  iFinder->setDescriptionForFinder(iDesc);
79  }
80  void setPostConstruction(DataProxyProvider* iProv, const edm::ParameterSet& iPSet) const {
81  //The 'appendToDataLabel' parameter was added very late in the development cycle and since
82  // the ParameterSet is not sent to the base class we must set the value after construction
83  iProv->setAppendToDataLabel(iPSet);
84  }
85  void setDescription(void*, const ComponentDescription&) const {}
86  void setDescriptionForFinder(void*, const ComponentDescription&) const {}
87  void setPostConstruction(void*, const edm::ParameterSet&) const {}
88  // ---------- member data --------------------------------
89  };
90 
91  template <class T, class TComponent>
92  std::shared_ptr<typename ComponentMaker<T, TComponent>::base_type> ComponentMaker<T, TComponent>::addTo(
93  EventSetupsController& esController,
94  EventSetupProvider& iProvider,
95  ParameterSet const& iConfiguration,
96  bool replaceExisting) const {
97  // This adds components to the EventSetupProvider for the process. It might
98  // make a new component then add it or reuse a component from an earlier
99  // SubProcess or the top level process and add that.
100 
101  if (!replaceExisting) {
102  std::shared_ptr<typename T::base_type> alreadyMadeComponent =
103  T::getComponentAndRegisterProcess(esController, iConfiguration);
104 
105  if (alreadyMadeComponent) {
106  // This is for the case when a component is shared between
107  // a SubProcess and a previous SubProcess or the top level process
108  // because the component has an identical configuration to a component
109  // from the top level process or earlier SubProcess.
110  std::shared_ptr<TComponent> component(
111  std::static_pointer_cast<TComponent, typename T::base_type>(alreadyMadeComponent));
112  T::addTo(iProvider, component, iConfiguration, true);
113  return component;
114  }
115  }
116 
117  std::shared_ptr<TComponent> component = std::make_shared<TComponent>(iConfiguration);
118  ComponentDescription description = this->createComponentDescription(iConfiguration);
119 
120  this->setDescription(component.get(), description);
121  this->setDescriptionForFinder(component.get(), description);
122  this->setPostConstruction(component.get(), iConfiguration);
123 
124  if (replaceExisting) {
125  // This case is for ESProducers where in the first pass
126  // the algorithm thought the component could be shared
127  // across SubProcess's because there was an ESProducer
128  // from a previous process with an identical configuration.
129  // But in a later check it was determined that sharing was not
130  // possible because other components associated with the
131  // same record or records that record depends on had
132  // differing configurations.
133  T::replaceExisting(iProvider, component);
134  } else {
135  // This is for the case when a new component is being constructed.
136  // All components for the top level process fall in this category.
137  // Or it could be a SubProcess where neither the top level process
138  // nor any prior SubProcess had a component with exactly the same configuration.
139  T::addTo(iProvider, component, iConfiguration, false);
140  T::putComponent(esController, iConfiguration, component);
141  }
142  return component;
143  }
144  } // namespace eventsetup
145 } // namespace edm
146 #endif
edm::eventsetup::DataProxyProvider
Definition: DataProxyProvider.h:64
edm::eventsetup::ComponentMaker::operator=
const ComponentMaker & operator=(const ComponentMaker &)=delete
edm::eventsetup::ComponentMakerBase
Definition: ComponentMaker.h:47
edm::eventsetup::ComponentMaker::setPostConstruction
void setPostConstruction(DataProxyProvider *iProv, const edm::ParameterSet &iPSet) const
Definition: ComponentMaker.h:80
edm
HLT enums.
Definition: AlignableModifier.h:19
edmLumisInFiles.description
description
Definition: edmLumisInFiles.py:11
ComponentDescription.h
edm::eventsetup::ComponentMakerBaseHelper
Definition: ComponentMaker.h:38
edm::EventSetupRecordIntervalFinder
Definition: EventSetupRecordIntervalFinder.h:33
edm::EventSetupRecordIntervalFinder::setDescriptionForFinder
void setDescriptionForFinder(const eventsetup::ComponentDescription &iDescription)
Definition: EventSetupRecordIntervalFinder.h:61
edm::eventsetup::ComponentMaker
Definition: ComponentMaker.h:57
edm::eventsetup::ComponentMaker::setDescription
void setDescription(void *, const ComponentDescription &) const
Definition: ComponentMaker.h:85
DataProxyProvider.h
edm::eventsetup::DataProxyProvider::setAppendToDataLabel
void setAppendToDataLabel(const edm::ParameterSet &)
Definition: DataProxyProvider.cc:180
edm::eventsetup::EventSetupProvider
Definition: EventSetupProvider.h:49
edm::eventsetup::ComponentMaker::setDescriptionForFinder
void setDescriptionForFinder(void *, const ComponentDescription &) const
Definition: ComponentMaker.h:86
edm::eventsetup::ComponentMaker::setDescription
void setDescription(DataProxyProvider *iProv, const ComponentDescription &iDesc) const
Definition: ComponentMaker.h:74
edm::eventsetup::ComponentMaker::base_type
T::base_type base_type
Definition: ComponentMaker.h:62
EventSetupRecordIntervalFinder.h
edm::eventsetup::DataProxyProvider::setDescription
void setDescription(const ComponentDescription &iDescription)
Definition: DataProxyProvider.h:175
edm::eventsetup::ComponentDescription
Definition: ComponentDescription.h:30
edm::eventsetup::ComponentMaker::setPostConstruction
void setPostConstruction(void *, const edm::ParameterSet &) const
Definition: ComponentMaker.h:87
edm::eventsetup::ComponentMaker::ComponentMaker
ComponentMaker()
Definition: ComponentMaker.h:59
edm::ParameterSet
Definition: ParameterSet.h:47
edm::eventsetup::ComponentMakerBase::base_type
T::base_type base_type
Definition: ComponentMaker.h:49
edm::eventsetup::ComponentMaker::setDescriptionForFinder
void setDescriptionForFinder(EventSetupRecordIntervalFinder *iFinder, const ComponentDescription &iDesc) const
Definition: ComponentMaker.h:77
edm::eventsetup::ComponentMakerBase::addTo
virtual std::shared_ptr< base_type > addTo(EventSetupsController &esController, EventSetupProvider &iProvider, ParameterSet const &iConfiguration, bool replaceExisting) const =0
edm::eventsetup::ComponentMakerBaseHelper::~ComponentMakerBaseHelper
virtual ~ComponentMakerBaseHelper()
Definition: ComponentMaker.h:40
edm::eventsetup::EventSetupsController
Definition: EventSetupsController.h:79
edm::eventsetup::ComponentMakerBaseHelper::createComponentDescription
ComponentDescription createComponentDescription(ParameterSet const &iConfiguration) const
Definition: ComponentMaker.cc:9
edm::eventsetup::ComponentMaker::addTo
std::shared_ptr< base_type > addTo(EventSetupsController &esController, EventSetupProvider &iProvider, ParameterSet const &iConfiguration, bool replaceExisting) const override
Definition: ComponentMaker.h:92