test
CMS 3D CMS Logo

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