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  //virtual ~ComponentMaker();
61  typedef typename T::base_type base_type;
62 
63  // ---------- const member functions ---------------------
64  std::shared_ptr<base_type> addTo(EventSetupsController& esController,
65  EventSetupProvider& iProvider,
66  ParameterSet const& iConfiguration,
67  bool replaceExisting) const override;
68 
69  // ---------- static member functions --------------------
70 
71  // ---------- member functions ---------------------------
72  private:
73  ComponentMaker(const ComponentMaker&) = delete; // stop default
74 
75  const ComponentMaker& operator=(const ComponentMaker&) = delete; // stop default
76 
77  void setDescription(DataProxyProvider* iProv, const ComponentDescription& iDesc) const {
78  iProv->setDescription(iDesc);
79  }
81  iFinder->setDescriptionForFinder(iDesc);
82  }
83  void setPostConstruction(DataProxyProvider* iProv, const edm::ParameterSet& iPSet) const {
84  //The 'appendToDataLabel' parameter was added very late in the development cycle and since
85  // the ParameterSet is not sent to the base class we must set the value after construction
86  iProv->setAppendToDataLabel(iPSet);
87  }
88  void setDescription(void*, const ComponentDescription&) const {}
89  void setDescriptionForFinder(void*, const ComponentDescription&) const {}
90  void setPostConstruction(void*, const edm::ParameterSet&) const {}
91  // ---------- member data --------------------------------
92  };
93 
94  template <class T, class TComponent>
95  std::shared_ptr<typename ComponentMaker<T, TComponent>::base_type> ComponentMaker<T, TComponent>::addTo(
96  EventSetupsController& esController,
97  EventSetupProvider& iProvider,
98  ParameterSet const& iConfiguration,
99  bool replaceExisting) const {
100  // This adds components to the EventSetupProvider for the process. It might
101  // make a new component then add it or reuse a component from an earlier
102  // SubProcess or the top level process and add that.
103 
104  if (!replaceExisting) {
105  std::shared_ptr<typename T::base_type> alreadyMadeComponent =
106  T::getComponentAndRegisterProcess(esController, iConfiguration);
107 
108  if (alreadyMadeComponent) {
109  // This is for the case when a component is shared between
110  // a SubProcess and a previous SubProcess or the top level process
111  // because the component has an identical configuration to a component
112  // from the top level process or earlier SubProcess.
113  std::shared_ptr<TComponent> component(
114  std::static_pointer_cast<TComponent, typename T::base_type>(alreadyMadeComponent));
115  T::addTo(iProvider, component, iConfiguration, true);
116  return component;
117  }
118  }
119 
120  std::shared_ptr<TComponent> component = std::make_shared<TComponent>(iConfiguration);
121  ComponentDescription description = this->createComponentDescription(iConfiguration);
122 
123  this->setDescription(component.get(), description);
124  this->setDescriptionForFinder(component.get(), description);
125  this->setPostConstruction(component.get(), iConfiguration);
126 
127  if (replaceExisting) {
128  // This case is for ESProducers where in the first pass
129  // the algorithm thought the component could be shared
130  // across SubProcess's because there was an ESProducer
131  // from a previous process with an identical configuration.
132  // But in a later check it was determined that sharing was not
133  // possible because other components associated with the
134  // same record or records that record depends on had
135  // differing configurations.
136  T::replaceExisting(iProvider, component);
137  } else {
138  // This is for the case when a new component is being constructed.
139  // All components for the top level process fall in this category.
140  // Or it could be a SubProcess where neither the top level process
141  // nor any prior SubProcess had a component with exactly the same configuration.
142  T::addTo(iProvider, component, iConfiguration, false);
143  T::putComponent(esController, iConfiguration, component);
144  }
145  return component;
146  }
147  } // namespace eventsetup
148 } // namespace edm
149 #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:83
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:88
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:89
edm::eventsetup::ComponentMaker::setDescription
void setDescription(DataProxyProvider *iProv, const ComponentDescription &iDesc) const
Definition: ComponentMaker.h:77
edm::eventsetup::ComponentMaker::base_type
T::base_type base_type
Definition: ComponentMaker.h:61
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:90
edm::eventsetup::ComponentMaker::ComponentMaker
ComponentMaker()
Definition: ComponentMaker.h:59
edm::ParameterSet
Definition: ParameterSet.h:36
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:80
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:95