CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions
edm::Maker Class Referenceabstract

#include <WorkerMaker.h>

Inheritance diagram for edm::Maker:
edm::WorkerMaker< T >

Public Member Functions

std::shared_ptr< maker::ModuleHoldermakeModule (MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
 
std::shared_ptr< maker::ModuleHoldermakeReplacementModule (edm::ParameterSet const &p) const
 
std::unique_ptr< WorkermakeWorker (ExceptionToActionTable const *, maker::ModuleHolder const *) const
 
virtual ~Maker ()
 

Protected Member Functions

ModuleDescription createModuleDescription (MakeModuleParams const &p) const
 
void throwConfigurationException (ModuleDescription const &md, cms::Exception &iException) const
 
void throwValidationException (MakeModuleParams const &p, cms::Exception &iException) const
 
void validateEDMType (std::string const &edmType, MakeModuleParams const &p) const
 

Private Member Functions

virtual const std::string & baseType () const =0
 
virtual void fillDescriptions (ConfigurationDescriptions &iDesc) const =0
 
virtual std::shared_ptr< maker::ModuleHoldermakeModule (edm::ParameterSet const &p) const =0
 
virtual std::unique_ptr< WorkermakeWorker (ExceptionToActionTable const *actions, ModuleDescription const &md, maker::ModuleHolder const *mod) const =0
 

Detailed Description

Definition at line 22 of file WorkerMaker.h.

Constructor & Destructor Documentation

◆ ~Maker()

edm::Maker::~Maker ( )
virtual

Definition at line 16 of file WorkerMaker.cc.

16 {}

Member Function Documentation

◆ baseType()

virtual const std::string& edm::Maker::baseType ( ) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

Referenced by makeModule().

◆ createModuleDescription()

ModuleDescription edm::Maker::createModuleDescription ( MakeModuleParams const &  p) const
protected

Definition at line 18 of file WorkerMaker.cc.

18  {
19  ParameterSet const& conf = *p.pset_;
20  ModuleDescription md(conf.id(),
21  conf.getParameter<std::string>("@module_type"),
22  conf.getParameter<std::string>("@module_label"),
23  p.processConfiguration_.get(),
25  return md;
26  }

References edm::ParameterSet::getParameter(), edm::ModuleDescription::getUniqueID(), edm::ParameterSet::id(), AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

◆ fillDescriptions()

virtual void edm::Maker::fillDescriptions ( ConfigurationDescriptions iDesc) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

Referenced by makeModule().

◆ makeModule() [1/2]

virtual std::shared_ptr<maker::ModuleHolder> edm::Maker::makeModule ( edm::ParameterSet const &  p) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

◆ makeModule() [2/2]

std::shared_ptr< maker::ModuleHolder > edm::Maker::makeModule ( MakeModuleParams const &  p,
signalslot::Signal< void(ModuleDescription const &)> &  iPre,
signalslot::Signal< void(ModuleDescription const &)> &  iPost 
) const

Definition at line 57 of file WorkerMaker.cc.

60  {
61  // Add process_name for SwitchProducer
62  if (p.pset_->getParameter<std::string>("@module_type") == "SwitchProducer") {
63  p.pset_->addUntrackedParameter("@process_name", p.processConfiguration_->processName());
64  }
65 
66  ConfigurationDescriptions descriptions(baseType(), p.pset_->getParameter<std::string>("@module_type"));
67  fillDescriptions(descriptions);
68  try {
70  descriptions.validate(*p.pset_, p.pset_->getParameter<std::string>("@module_label"));
72  });
73  } catch (cms::Exception& iException) {
74  throwValidationException(p, iException);
75  }
76  p.pset_->registerIt();
77  //Need to be certain top level untracked parameters are stored in
78  // the registry even if another PSet already exists in the
79  // registry from a previous process
80  //NOTE: a better implementation would be to change ParameterSet::registerIt
81  // but that would require rebuilding much more code so will be done at
82  // a later date.
83  edm::pset::Registry::instance()->insertMapped(*(p.pset_), true);
84 
85  ModuleDescription md = createModuleDescription(p);
86  std::shared_ptr<maker::ModuleHolder> module;
87  bool postCalled = false;
88  try {
90  pre(md);
91  module = makeModule(*(p.pset_));
92  module->setModuleDescription(md);
93  module->preallocate(*(p.preallocate_));
94  module->registerProductsAndCallbacks(p.reg_);
95  // if exception then post will be called in the catch block
96  postCalled = true;
97  post(md);
98  });
99  } catch (cms::Exception& iException) {
100  if (!postCalled) {
101  CMS_SA_ALLOW try { post(md); } catch (...) {
102  // If post throws an exception ignore it because we are already handling another exception
103  }
104  }
105  throwConfigurationException(md, iException);
106  }
107  return module;
108  }

References baseType(), CMS_SA_ALLOW, createModuleDescription(), fillDescriptions(), edm::pset::Registry::insertMapped(), edm::pset::Registry::instance(), AlCaHLTBitMon_ParallelJobs::p, AlCaHLTBitMon_QueryRunRegistry::string, throwConfigurationException(), throwValidationException(), edm::ConfigurationDescriptions::validate(), validateEDMType(), and edm::convertException::wrap().

Referenced by makeReplacementModule().

◆ makeReplacementModule()

std::shared_ptr<maker::ModuleHolder> edm::Maker::makeReplacementModule ( edm::ParameterSet const &  p) const
inline

Definition at line 30 of file WorkerMaker.h.

30  {
31  return makeModule(p);
32  }

References makeModule(), and AlCaHLTBitMon_ParallelJobs::p.

◆ makeWorker() [1/2]

std::unique_ptr< Worker > edm::Maker::makeWorker ( ExceptionToActionTable const *  actions,
maker::ModuleHolder const *  mod 
) const

Definition at line 110 of file WorkerMaker.cc.

111  {
112  return makeWorker(actions, mod->moduleDescription(), mod);
113  }

References actions, and mod().

Referenced by edm::maker::ModuleHolder::makeWorker().

◆ makeWorker() [2/2]

virtual std::unique_ptr<Worker> edm::Maker::makeWorker ( ExceptionToActionTable const *  actions,
ModuleDescription const &  md,
maker::ModuleHolder const *  mod 
) const
privatepure virtual

Implemented in edm::WorkerMaker< T >.

◆ throwConfigurationException()

void edm::Maker::throwConfigurationException ( ModuleDescription const &  md,
cms::Exception iException 
) const
protected

Definition at line 39 of file WorkerMaker.cc.

39  {
40  std::ostringstream ost;
41  ost << "Constructing module: class=" << md.moduleName() << " label='" << md.moduleLabel() << "'";
42  iException.addContext(ost.str());
43  throw;
44  }

References cms::Exception::addContext(), edm::ModuleDescription::moduleLabel(), and edm::ModuleDescription::moduleName().

Referenced by makeModule().

◆ throwValidationException()

void edm::Maker::throwValidationException ( MakeModuleParams const &  p,
cms::Exception iException 
) const
protected

Definition at line 28 of file WorkerMaker.cc.

28  {
29  ParameterSet const& conf = *p.pset_;
30  std::string moduleName = conf.getParameter<std::string>("@module_type");
31  std::string moduleLabel = conf.getParameter<std::string>("@module_label");
32 
33  std::ostringstream ost;
34  ost << "Validating configuration of module: class=" << moduleName << " label='" << moduleLabel << "'";
35  iException.addContext(ost.str());
36  throw;
37  }

References cms::Exception::addContext(), edm::ParameterSet::getParameter(), HerwigMaxPtPartonFilter_cfi::moduleLabel, edm::moduleName(), AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

◆ validateEDMType()

void edm::Maker::validateEDMType ( std::string const &  edmType,
MakeModuleParams const &  p 
) const
protected

Definition at line 46 of file WorkerMaker.cc.

46  {
47  std::string expected = p.pset_->getParameter<std::string>("@module_edm_type");
48  if (edmType != expected) {
50  << "The base type in the python configuration is " << expected << ", but the base type\n"
51  << "for the module's C++ class is " << edmType << ". "
52  << "Please fix the configuration.\n"
53  << "It must use the same base type as the C++ class.\n";
54  }
55  }

References edm::errors::Configuration, Exception, AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by makeModule().

edm::pset::Registry::instance
static Registry * instance()
Definition: Registry.cc:12
edm::Maker::throwConfigurationException
void throwConfigurationException(ModuleDescription const &md, cms::Exception &iException) const
Definition: WorkerMaker.cc:39
edm::Maker::fillDescriptions
virtual void fillDescriptions(ConfigurationDescriptions &iDesc) const =0
cms::Exception::addContext
void addContext(std::string const &context)
Definition: Exception.cc:165
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
edm::moduleName
std::string moduleName(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:27
edm::ModuleDescription::getUniqueID
static unsigned int getUniqueID()
Returns a unique id each time called. Intended to be passed to ModuleDescription's constructor's modI...
Definition: ModuleDescription.cc:87
CMS_SA_ALLOW
#define CMS_SA_ALLOW
Definition: thread_safety_macros.h:5
edm::convertException::wrap
auto wrap(F iFunc) -> decltype(iFunc())
Definition: ConvertException.h:19
edm::Maker::createModuleDescription
ModuleDescription createModuleDescription(MakeModuleParams const &p) const
Definition: WorkerMaker.cc:18
edm::Maker::makeWorker
std::unique_ptr< Worker > makeWorker(ExceptionToActionTable const *, maker::ModuleHolder const *) const
Definition: WorkerMaker.cc:110
edm::Maker::makeModule
std::shared_ptr< maker::ModuleHolder > makeModule(MakeModuleParams const &, signalslot::Signal< void(ModuleDescription const &)> &iPre, signalslot::Signal< void(ModuleDescription const &)> &iPost) const
Definition: WorkerMaker.cc:57
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ParameterSet
Definition: Functions.h:16
edm::pset::Registry::insertMapped
bool insertMapped(value_type const &v, bool forceUpdate=false)
Definition: Registry.cc:32
ConfigurationDescriptions
edm::Maker::baseType
virtual const std::string & baseType() const =0
edm::Maker::validateEDMType
void validateEDMType(std::string const &edmType, MakeModuleParams const &p) const
Definition: WorkerMaker.cc:46
Exception
Definition: hltDiff.cc:245
edm::Maker::throwValidationException
void throwValidationException(MakeModuleParams const &p, cms::Exception &iException) const
Definition: WorkerMaker.cc:28
actions
roAction_t actions[nactions]
Definition: GenABIO.cc:181
cms::Exception
Definition: Exception.h:70
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
edm::errors::Configuration
Definition: EDMException.h:36