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 <string>
23 #include "boost/shared_ptr.hpp"
24 
25 // user include files
29 
30 // forward declarations
31 
32 namespace edm {
33  namespace eventsetup {
34  class EventSetupProvider;
36  class DataProxyProvider;
37 
39  {
40  public:
42  protected:
43  void logInfoWhenSharing(ParameterSet const& iConfiguration) const;
45  };
46 
47  template <class T>
49  public:
50  typedef typename T::base_type base_type;
51  virtual boost::shared_ptr<base_type> addTo(EventSetupsController& esController,
52  EventSetupProvider& iProvider,
53  ParameterSet const& iConfiguration) 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 boost::shared_ptr<base_type> addTo(EventSetupsController& esController,
67  EventSetupProvider& iProvider,
68  ParameterSet const& iConfiguration) const;
69 
70  // ---------- static member functions --------------------
71 
72  // ---------- member functions ---------------------------
73  private:
74  ComponentMaker(const ComponentMaker&); // stop default
75 
76  const ComponentMaker& operator=(const ComponentMaker&); // stop default
77 
78  void setDescription(DataProxyProvider* iProv, const ComponentDescription& iDesc) const {
79  iProv->setDescription(iDesc);
80  }
82  iFinder->setDescriptionForFinder(iDesc);
83  }
84  void setPostConstruction(DataProxyProvider* iProv, const edm::ParameterSet& iPSet) const {
85  //The 'appendToDataLabel' parameter was added very late in the development cycle and since
86  // the ParameterSet is not sent to the base class we must set the value after construction
87  iProv->setAppendToDataLabel(iPSet);
88  }
89  void setDescription(void*, const ComponentDescription&) const {
90  }
91  void setDescriptionForFinder(void*, const ComponentDescription&) const {
92  }
93  void setPostConstruction(void*, const edm::ParameterSet&) const {
94  }
95  // ---------- member data --------------------------------
96 
97 };
98 
99 template< class T, class TComponent>
100 boost::shared_ptr<typename ComponentMaker<T,TComponent>::base_type>
102  EventSetupProvider& iProvider,
103  ParameterSet const& iConfiguration) const
104 {
105  boost::shared_ptr<typename T::base_type> const* alreadyMadeComponent = T::getAlreadyMadeComponent(esController, iConfiguration);
106 
107  if (alreadyMadeComponent) {
108  this->logInfoWhenSharing(iConfiguration);
109  boost::shared_ptr<TComponent> component(boost::static_pointer_cast<TComponent, typename T::base_type>(*alreadyMadeComponent));
110  T::addTo(iProvider, component);
111  return component;
112  }
113 
114  boost::shared_ptr<TComponent> component(new TComponent(iConfiguration));
116  this->createComponentDescription(iConfiguration);
117 
118  this->setDescription(component.get(),description);
119  this->setDescriptionForFinder(component.get(),description);
120  this->setPostConstruction(component.get(),iConfiguration);
121  T::addTo(iProvider, component);
122  T::putComponent(esController, iConfiguration, component);
123 
124  return component;
125 }
126  }
127 }
128 #endif
void setDescription(const ComponentDescription &iDescription)
const ComponentMaker & operator=(const ComponentMaker &)
void setPostConstruction(DataProxyProvider *iProv, const edm::ParameterSet &iPSet) const
void setDescriptionForFinder(const eventsetup::ComponentDescription &iDescription)
tuple description
Definition: idDealer.py:66
void logInfoWhenSharing(ParameterSet const &iConfiguration) const
void setPostConstruction(void *, const edm::ParameterSet &) const
void setAppendToDataLabel(const edm::ParameterSet &)
void setDescription(DataProxyProvider *iProv, const ComponentDescription &iDesc) const
virtual boost::shared_ptr< base_type > addTo(EventSetupsController &esController, EventSetupProvider &iProvider, ParameterSet const &iConfiguration) const =0
virtual boost::shared_ptr< base_type > addTo(EventSetupsController &esController, EventSetupProvider &iProvider, ParameterSet const &iConfiguration) 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