From c038f3302f5cba0fc49c83e4c54916c916c49fa3 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 23 Sep 2021 15:00:14 -0500 Subject: [PATCH 1/3] Add macro to conditionally apply [[deprecated]] This allows SCRAM to control under what circumstances the messages should be emitted. --- FWCore/Utilities/interface/deprecated_macro.h | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 FWCore/Utilities/interface/deprecated_macro.h diff --git a/FWCore/Utilities/interface/deprecated_macro.h b/FWCore/Utilities/interface/deprecated_macro.h new file mode 100644 index 0000000000000..530e6c7557022 --- /dev/null +++ b/FWCore/Utilities/interface/deprecated_macro.h @@ -0,0 +1,8 @@ +#ifndef FWCore_Utilites_deprecated_macro_h +#define FWCore_Utilites_deprecated_macro_h +#if !defined USE_CMS_DEPRECATED +#define CMS_DEPRECATED +#else +#define CMS_DEPRECATED [[deprecated]] +#endif +#endif From 37c3e5d117e82541258abd03a10bd677ab019066 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Thu, 23 Sep 2021 15:01:29 -0500 Subject: [PATCH 2/3] deprecated non esConsumes EventSetup get calls --- FWCore/Framework/interface/EventSetup.h | 10 ++-- FWCore/Framework/interface/EventSetupRecord.h | 50 +++++++++++-------- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/FWCore/Framework/interface/EventSetup.h b/FWCore/Framework/interface/EventSetup.h index b0a1eb656f398..7b2e4b902e7b4 100644 --- a/FWCore/Framework/interface/EventSetup.h +++ b/FWCore/Framework/interface/EventSetup.h @@ -38,6 +38,7 @@ #include "FWCore/Framework/interface/data_default_record_trait.h" #include "FWCore/Utilities/interface/Transition.h" #include "FWCore/Utilities/interface/ESIndices.h" +#include "FWCore/Utilities/interface/deprecated_macro.h" // forward declarations @@ -124,18 +125,19 @@ namespace edm { /** can directly access data if data_default_record_trait<> is defined for this data type **/ template - bool getData(T& iHolder) const { - return getData(std::string{}, iHolder); + CMS_DEPRECATED bool getData(T& iHolder) const { + auto const& rec = this->get>(); + return rec.get(std::string{}, iHolder); } template - bool getData(const std::string& iLabel, T& iHolder) const { + CMS_DEPRECATED bool getData(const std::string& iLabel, T& iHolder) const { auto const& rec = this->get>(); return rec.get(iLabel, iHolder); } template - bool getData(const ESInputTag& iTag, T& iHolder) const { + CMS_DEPRECATED bool getData(const ESInputTag& iTag, T& iHolder) const { auto const& rec = this->get>(); return rec.get(iTag, iHolder); } diff --git a/FWCore/Framework/interface/EventSetupRecord.h b/FWCore/Framework/interface/EventSetupRecord.h index 3e3ef03952369..d2153b4455aa2 100644 --- a/FWCore/Framework/interface/EventSetupRecord.h +++ b/FWCore/Framework/interface/EventSetupRecord.h @@ -49,6 +49,7 @@ #include "FWCore/Utilities/interface/ESInputTag.h" #include "FWCore/Utilities/interface/ESIndices.h" #include "FWCore/Utilities/interface/Likely.h" +#include "FWCore/Utilities/interface/deprecated_macro.h" // system include files #include @@ -108,37 +109,22 @@ namespace edm { } template - bool get(HolderT& iHolder) const { - return get("", iHolder); + CMS_DEPRECATED bool get(HolderT& iHolder) const { + return deprecated_get("", iHolder); } template - bool get(char const* iName, HolderT& iHolder) const { - if UNLIKELY (requireTokens_) { - throwCalledGetWithoutToken(heterocontainer::className(), iName); - } - typename HolderT::value_type const* value = nullptr; - ComponentDescription const* desc = nullptr; - std::shared_ptr whyFailedFactory; - impl_->getImplementation( - value, iName, desc, iHolder.transientAccessOnly, whyFailedFactory, *context_, eventSetupImpl_); - - if (value) { - iHolder = HolderT(value, desc); - return true; - } else { - iHolder = HolderT(std::move(whyFailedFactory)); - return false; - } + CMS_DEPRECATED bool get(char const* iName, HolderT& iHolder) const { + return deprecated_get(iName, iHolder); } template - bool get(std::string const& iName, HolderT& iHolder) const { - return get(iName.c_str(), iHolder); + CMS_DEPRECATED bool get(std::string const& iName, HolderT& iHolder) const { + return deprecated_get(iName.c_str(), iHolder); } template - bool get(ESInputTag const& iTag, HolderT& iHolder) const { + CMS_DEPRECATED bool get(ESInputTag const& iTag, HolderT& iHolder) const { if UNLIKELY (requireTokens_) { throwCalledGetWithoutToken(heterocontainer::className(), iTag.data().c_str()); } @@ -258,6 +244,26 @@ namespace edm { bool requireTokens() const { return requireTokens_; } private: + template + bool deprecated_get(char const* iName, HolderT& iHolder) const { + if UNLIKELY (requireTokens_) { + throwCalledGetWithoutToken(heterocontainer::className(), iName); + } + typename HolderT::value_type const* value = nullptr; + ComponentDescription const* desc = nullptr; + std::shared_ptr whyFailedFactory; + impl_->getImplementation( + value, iName, desc, iHolder.transientAccessOnly, whyFailedFactory, *context_, eventSetupImpl_); + + if (value) { + iHolder = HolderT(value, desc); + return true; + } else { + iHolder = HolderT(std::move(whyFailedFactory)); + return false; + } + } + template