/
githubmirror
/
cmssw
Обзор
Документация
Войти
/
githubmirror
/
cmssw
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
FWCore/Framework/interface/ComponentMaker.h
126 строк
5 KB
Chris Jones
Constructing an ES module no longer depends on EventSetupProvider
08 июл 2026, 17:47
08 июл 2026, 17:47
a062af5
Код
Авторство
О чём код?
// -*- C++ -*- #ifndef Framework_ComponentMaker_h #define Framework_ComponentMaker_h // // Package: Framework // Class : ComponentMaker // /**\class edm::eventsetup::ComponentMaker Description: <one line class summary> Usage: <usage> */ // // Author: Chris Jones // Created: Wed May 25 16:56:05 EDT 2005 // // system include files #include <memory> #include <string> #include <format> // user include files #include "FWCore/Framework/interface/ComponentDescription.h" #include "FWCore/Framework/interface/ESProductResolverProvider.h" #include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h" #include "FWCore/Framework/interface/ComponentConstructionSentry.h" #include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescriptionFiller.h" #include "FWCore/Utilities/interface/ConvertException.h" #include "FWCore/Utilities/interface/Exception.h" namespace edm { namespace eventsetup { // forward declarations class ComponentInterfaceHolder; class ComponentMakerBaseHelper { public: virtual ~ComponentMakerBaseHelper() {} protected: ComponentDescription createComponentDescription(ParameterSet const& iConfiguration) const; }; template <class T> class ComponentMakerBase : public ComponentMakerBaseHelper { public: typedef typename T::base_type base_type; virtual std::shared_ptr<base_type> addTo(ComponentInterfaceHolder& iProvider, ParameterSet& iConfiguration) const = 0; }; template <class T, class TComponent> class ComponentMaker : public ComponentMakerBase<T> { public: ComponentMaker() {} ComponentMaker(const ComponentMaker&) = delete; // stop default const ComponentMaker& operator=(const ComponentMaker&) = delete; // stop default typedef typename T::base_type base_type; std::shared_ptr<base_type> addTo(ComponentInterfaceHolder& iInterfaceHolder, ParameterSet& iConfiguration) const override; private: void setDescription(ESProductResolverProvider* iProv, const ComponentDescription& iDesc) const { iProv->setDescription(iDesc); } void setDescriptionForFinder(EventSetupRecordIntervalFinder* iFinder, const ComponentDescription& iDesc) const { iFinder->setDescriptionForFinder(iDesc); } void setPostConstruction(ESProductResolverProvider* iProv, const edm::ParameterSet& iPSet) const { //The 'appendToDataLabel' parameter was added very late in the development cycle and since // the ParameterSet is not sent to the base class we must set the value after construction iProv->setAppendToDataLabel(iPSet); } void setDescription(void*, const ComponentDescription&) const {} void setDescriptionForFinder(void*, const ComponentDescription&) const {} void setPostConstruction(void*, const edm::ParameterSet&) const {} }; template <class T, class TComponent> std::shared_ptr<typename ComponentMaker<T, TComponent>::base_type> ComponentMaker<T, TComponent>::addTo( ComponentInterfaceHolder& iInterfaceHolder, ParameterSet& iConfiguration) const { { auto modtype = iConfiguration.getParameter<std::string>("@module_type"); auto moduleLabel = iConfiguration.getParameter<std::string>("@module_label"); try { edm::convertException::wrap([&]() { ConfigurationDescriptions descriptions(T::baseType(), modtype); fillDetails::fillIfExists<TComponent>(descriptions); fillDetails::prevalidateIfExists<TComponent>(descriptions); descriptions.validate(iConfiguration, moduleLabel); iConfiguration.registerIt(); }); } catch (cms::Exception& iException) { iException.addContext(std::format( "Validating configuration of {} of type {} with label: '{}'", T::baseType(), modtype, moduleLabel)); throw; } } const ComponentDescription description = this->createComponentDescription(iConfiguration); std::shared_ptr<TComponent> component; { ComponentConstructionSentry sentry(iInterfaceHolder, description); component = std::make_shared<TComponent>(iConfiguration); sentry.succeeded(); } this->setDescription(component.get(), description); this->setDescriptionForFinder(component.get(), description); this->setPostConstruction(component.get(), iConfiguration); T::addTo(iInterfaceHolder, component); return component; } } // namespace eventsetup } // namespace edm #endif