diff --git a/FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h b/FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h index 02c8a2ed41d34..ec213963b5aa5 100644 --- a/FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h +++ b/FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h @@ -32,16 +32,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool hasNestedContent_() const override; diff --git a/FWCore/ParameterSet/interface/EmptyGroupDescription.h b/FWCore/ParameterSet/interface/EmptyGroupDescription.h index 5b00acad11961..31ee30b243449 100644 --- a/FWCore/ParameterSet/interface/EmptyGroupDescription.h +++ b/FWCore/ParameterSet/interface/EmptyGroupDescription.h @@ -23,16 +23,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool exists_(ParameterSet const& pset) const override; diff --git a/FWCore/ParameterSet/interface/IfExistsDescription.h b/FWCore/ParameterSet/interface/IfExistsDescription.h index 7b404339c43e4..7be0e6cca8566 100644 --- a/FWCore/ParameterSet/interface/IfExistsDescription.h +++ b/FWCore/ParameterSet/interface/IfExistsDescription.h @@ -35,16 +35,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool hasNestedContent_() const override { return true; } diff --git a/FWCore/ParameterSet/interface/ParameterDescription.h b/FWCore/ParameterSet/interface/ParameterDescription.h index b1f55782149c3..224e17038ca2d 100644 --- a/FWCore/ParameterSet/interface/ParameterDescription.h +++ b/FWCore/ParameterSet/interface/ParameterDescription.h @@ -217,7 +217,7 @@ namespace edm { ParameterDescriptionNode* clone() const override { return new ParameterDescription(*this); } private: - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const override; @@ -274,7 +274,7 @@ namespace edm { void setPartOfDefaultOfVPSet(bool value) { partOfDefaultOfVPSet_ = value; } private: - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const override; diff --git a/FWCore/ParameterSet/interface/ParameterDescriptionBase.h b/FWCore/ParameterSet/interface/ParameterDescriptionBase.h index 5915450dd4d84..d6a546aaadff1 100644 --- a/FWCore/ParameterSet/interface/ParameterDescriptionBase.h +++ b/FWCore/ParameterSet/interface/ParameterDescriptionBase.h @@ -58,10 +58,10 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, @@ -75,7 +75,7 @@ namespace edm { bool& wroteSomething) const; void writeFullCfi(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, @@ -89,7 +89,7 @@ namespace edm { virtual void writeDoc_(std::ostream& os, int indentation) const = 0; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; virtual void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const; diff --git a/FWCore/ParameterSet/interface/ParameterDescriptionNode.h b/FWCore/ParameterSet/interface/ParameterDescriptionNode.h index 95a9151da09b7..d0217a874b598 100644 --- a/FWCore/ParameterSet/interface/ParameterDescriptionNode.h +++ b/FWCore/ParameterSet/interface/ParameterDescriptionNode.h @@ -70,6 +70,11 @@ namespace edm { std::string parameterTypeEnumToString(ParameterTypes iType); + enum class ParameterModifier : unsigned char { kNone, kOptional, kObsolete }; + inline ParameterModifier modifierIsOptional(bool iOptional) { + return iOptional ? ParameterModifier::kOptional : ParameterModifier::kNone; + } + namespace cfi { struct Paths { //This is the 'path' through the cms.PSet hierarchy. @@ -204,6 +209,8 @@ namespace edm { class ParameterDescriptionNode { public: + using Modifier = ParameterModifier; + ParameterDescriptionNode() {} explicit ParameterDescriptionNode(Comment const& iComment) : comment_(iComment.comment()) {} @@ -219,11 +226,11 @@ namespace edm { // The validate function should do one of three things, find that the // node "exists", make the node "exist" by inserting missing parameters // or throw. The only exception to this rule occurs when the argument - // named "optional" is true, which should only be possible for the + // named "modifier" is kOptional or kObsolete, which should only be possible for the // top level nodes of a ParameterSetDescription. When a parameter is // found or inserted its label is added into the list of validatedLabels. - void validate(ParameterSet& pset, std::set& validatedLabels, bool optional) const { - validate_(pset, validatedLabels, optional); + void validate(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const { + validate_(pset, validatedLabels, modifier); } // As long as it has default values, this will attempt to write @@ -237,16 +244,16 @@ namespace edm { // a valid cfi, in some cases the description can be so pathological // that it is impossible to write a cfi that will pass validation. void writeCfi(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const { - writeCfi_(os, optional, startWithComma, indentation, options, wroteSomething); + writeCfi_(os, modifier, startWithComma, indentation, options, wroteSomething); } // Print out the description in human readable format - void print(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const; + void print(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const; bool hasNestedContent() const { return hasNestedContent_(); } @@ -346,16 +353,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const = 0; - virtual void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const = 0; + virtual void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const = 0; virtual void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const = 0; - virtual void print_(std::ostream&, bool /*optional*/, bool /*writeToCfi*/, DocFormatHelper&) const {} + virtual void print_(std::ostream&, Modifier /*modifier*/, bool /*writeToCfi*/, DocFormatHelper&) const {} virtual bool hasNestedContent_() const { return false; } diff --git a/FWCore/ParameterSet/interface/ParameterSetDescription.h b/FWCore/ParameterSet/interface/ParameterSetDescription.h index 79bacc2bf71ae..f56e80beaa57d 100644 --- a/FWCore/ParameterSet/interface/ParameterSetDescription.h +++ b/FWCore/ParameterSet/interface/ParameterSetDescription.h @@ -51,12 +51,16 @@ namespace edm { class ParameterSetDescription { public: + using Modifier = ParameterModifier; class SetDescriptionEntry { public: - bool optional() const { return optional_; } + bool optional() const { return modifier_ == Modifier::kOptional; } + bool obsolete() const { return modifier_ == Modifier::kObsolete; } + Modifier modifier() const { return modifier_; } bool writeToCfi() const { return writeToCfi_; } edm::value_ptr const& node() const { return node_; } - void setOptional(bool value) { optional_ = value; } + + void setModifier(Modifier value) { modifier_ = value; } void setWriteToCfi(bool value) { writeToCfi_ = value; } ParameterDescriptionNode* setNode(std::unique_ptr node) { node_ = std::move(node); @@ -64,7 +68,7 @@ namespace edm { } private: - bool optional_; + Modifier modifier_; bool writeToCfi_; edm::value_ptr node_; }; @@ -93,22 +97,22 @@ namespace edm { template ParameterDescriptionBase* add(U const& iLabel, T const& value) { - return add(iLabel, value, true, false, true); + return add(iLabel, value, true, Modifier::kNone, true); } template ParameterDescriptionBase* addUntracked(U const& iLabel, T const& value) { - return add(iLabel, value, false, false, true); + return add(iLabel, value, false, Modifier::kNone, true); } template ParameterDescriptionBase* addOptional(U const& iLabel, T const& value) { - return add(iLabel, value, true, true, true); + return add(iLabel, value, true, Modifier::kOptional, true); } template ParameterDescriptionBase* addOptionalUntracked(U const& iLabel, T const& value) { - return add(iLabel, value, false, true, true); + return add(iLabel, value, false, Modifier::kOptional, true); } // For the next 4 functions, there is no default so they will not get injected @@ -116,22 +120,40 @@ namespace edm { template ParameterDescriptionBase* add(U const& iLabel) { - return add(iLabel, true, false, true); + return add(iLabel, true, Modifier::kNone, true); } template ParameterDescriptionBase* addUntracked(U const& iLabel) { - return add(iLabel, false, false, true); + return add(iLabel, false, Modifier::kNone, true); } template ParameterDescriptionBase* addOptional(U const& iLabel) { - return add(iLabel, true, true, true); + return add(iLabel, true, Modifier::kOptional, true); } template ParameterDescriptionBase* addOptionalUntracked(U const& iLabel) { - return add(iLabel, false, true, true); + return add(iLabel, false, Modifier::kOptional, true); + } + + template + ParameterDescriptionBase* addObsolete(U const& iLabel) { + if constexpr (std::is_same_v) { + return add(iLabel, T(), true, Modifier::kObsolete, true); + } else { + return add(iLabel, true, Modifier::kObsolete, true); + } + } + + template + ParameterDescriptionBase* addObsoleteUntracked(U const& iLabel) { + if constexpr (std::is_same_v) { + return add(iLabel, T(), false, Modifier::kObsolete, true); + } else { + return add(iLabel, false, Modifier::kObsolete, true); + } } // ***** Use these 8 functions for parameters of type vector ***** @@ -149,48 +171,59 @@ namespace edm { ParameterDescriptionBase* addVPSet(U const& iLabel, ParameterSetDescription const& validator, std::vector const& defaults) { - return addVPSet(iLabel, validator, defaults, true, false, true); + return addVPSet(iLabel, validator, defaults, true, Modifier::kNone, true); } template ParameterDescriptionBase* addVPSetUntracked(U const& iLabel, ParameterSetDescription const& validator, std::vector const& defaults) { - return addVPSet(iLabel, validator, defaults, false, false, true); + return addVPSet(iLabel, validator, defaults, false, Modifier::kNone, true); } template ParameterDescriptionBase* addVPSetOptional(U const& iLabel, ParameterSetDescription const& validator, std::vector const& defaults) { - return addVPSet(iLabel, validator, defaults, true, true, true); + return addVPSet(iLabel, validator, defaults, true, Modifier::kOptional, true); } template ParameterDescriptionBase* addVPSetOptionalUntracked(U const& iLabel, ParameterSetDescription const& validator, std::vector const& defaults) { - return addVPSet(iLabel, validator, defaults, false, true, true); + return addVPSet(iLabel, validator, defaults, false, Modifier::kOptional, true); } template ParameterDescriptionBase* addVPSet(U const& iLabel, ParameterSetDescription const& validator) { - return addVPSet(iLabel, validator, true, false, true); + return addVPSet(iLabel, validator, true, Modifier::kNone, true); } template ParameterDescriptionBase* addVPSetUntracked(U const& iLabel, ParameterSetDescription const& validator) { - return addVPSet(iLabel, validator, false, false, true); + return addVPSet(iLabel, validator, false, Modifier::kNone, true); } template ParameterDescriptionBase* addVPSetOptional(U const& iLabel, ParameterSetDescription const& validator) { - return addVPSet(iLabel, validator, true, true, true); + return addVPSet(iLabel, validator, true, Modifier::kOptional, true); } template ParameterDescriptionBase* addVPSetOptionalUntracked(U const& iLabel, ParameterSetDescription const& validator) { - return addVPSet(iLabel, validator, false, true, true); + return addVPSet(iLabel, validator, false, Modifier::kOptional, true); + } + + template + ParameterDescriptionBase* addVPSetObsolete(U const& iLabel) { + ParameterSetDescription validator; + return addVPSet(iLabel, validator, true, Modifier::kObsolete, true); + } + template + ParameterDescriptionBase* addVPSetObsoleteUntracked(U const& iLabel) { + ParameterSetDescription validator; + return addVPSet(iLabel, validator, false, Modifier::kObsolete, true); } // ********* Wildcards ********* @@ -219,46 +252,46 @@ namespace edm { template ParameterDescriptionNode* ifValue(ParameterDescription const& switchParameter, std::unique_ptr> cases) { - return ifValue(switchParameter, std::move(cases), false, true); + return ifValue(switchParameter, std::move(cases), Modifier::kNone, true); } template ParameterDescriptionNode* ifValueOptional(ParameterDescription const& switchParameter, std::unique_ptr> cases, bool writeToCfi) { - return ifValue(switchParameter, std::move(cases), true, writeToCfi); + return ifValue(switchParameter, std::move(cases), Modifier::kOptional, writeToCfi); } // ********* if exists ************ ParameterDescriptionNode* ifExists(ParameterDescriptionNode const& node1, ParameterDescriptionNode const& node2) { - return ifExists(node1, node2, false, true); + return ifExists(node1, node2, Modifier::kNone, true); } ParameterDescriptionNode* ifExistsOptional(ParameterDescriptionNode const& node1, ParameterDescriptionNode const& node2, bool writeToCfi) { - return ifExists(node1, node2, true, writeToCfi); + return ifExists(node1, node2, Modifier::kOptional, writeToCfi); } // ********* for parameters that are a list of allowed labels ********* template ParameterDescriptionNode* labelsFrom(U const& iLabel) { - return labelsFrom(iLabel, true, false, true); + return labelsFrom(iLabel, true, Modifier::kNone, true); } template ParameterDescriptionNode* labelsFromUntracked(U const& iLabel) { - return labelsFrom(iLabel, false, false, true); + return labelsFrom(iLabel, false, Modifier::kNone, true); } template ParameterDescriptionNode* labelsFromOptional(U const& iLabel, bool writeToCfi) { - return labelsFrom(iLabel, true, true, writeToCfi); + return labelsFrom(iLabel, true, Modifier::kOptional, writeToCfi); } template ParameterDescriptionNode* labelsFromOptionalUntracked(U const& iLabel, bool writeToCfi) { - return labelsFrom(iLabel, false, true, writeToCfi); + return labelsFrom(iLabel, false, Modifier::kOptional, writeToCfi); } // These next four functions only work when the template @@ -271,22 +304,22 @@ namespace edm { // T must be explicitly specified by the calling function. template ParameterDescriptionNode* labelsFrom(U const& iLabel, V const& desc) { - return labelsFrom(iLabel, true, false, true, desc); + return labelsFrom(iLabel, true, Modifier::kNone, true, desc); } template ParameterDescriptionNode* labelsFromUntracked(U const& iLabel, V const& desc) { - return labelsFrom(iLabel, false, false, true, desc); + return labelsFrom(iLabel, false, Modifier::kNone, true, desc); } template ParameterDescriptionNode* labelsFromOptional(U const& iLabel, bool writeToCfi, V const& desc) { - return labelsFrom(iLabel, true, true, writeToCfi, desc); + return labelsFrom(iLabel, true, Modifier::kOptional, writeToCfi, desc); } template ParameterDescriptionNode* labelsFromOptionalUntracked(U const& iLabel, bool writeToCfi, V const& desc) { - return labelsFrom(iLabel, false, true, writeToCfi, desc); + return labelsFrom(iLabel, false, Modifier::kOptional, writeToCfi, desc); } bool anythingAllowed() const { return anythingAllowed_; } @@ -311,44 +344,47 @@ namespace edm { private: template - ParameterDescriptionBase* add(U const& iLabel, T const& value, bool isTracked, bool isOptional, bool writeToCfi); + ParameterDescriptionBase* add(U const& iLabel, T const& value, bool isTracked, Modifier modifier, bool writeToCfi); template - ParameterDescriptionBase* add(U const& iLabel, bool isTracked, bool isOptional, bool writeToCfi); + ParameterDescriptionBase* add(U const& iLabel, bool isTracked, Modifier modifier, bool writeToCfi); template ParameterDescriptionBase* addVPSet(U const& iLabel, ParameterSetDescription const& validator, std::vector const& defaults, bool isTracked, - bool isOptional, + Modifier modifier, bool writeToCfi); template ParameterDescriptionBase* addVPSet( - U const& iLabel, ParameterSetDescription const& validator, bool isTracked, bool isOptional, bool writeToCfi); + U const& iLabel, ParameterSetDescription const& validator, bool isTracked, Modifier modifier, bool writeToCfi); template ParameterWildcardBase* addWildcard(U const& pattern, bool isTracked); - ParameterDescriptionNode* addNode(std::unique_ptr node, bool optional, bool writeToCfi); + ParameterDescriptionNode* addNode(std::unique_ptr node, + Modifier modifier, + bool writeToCfi); template ParameterDescriptionNode* ifValue(ParameterDescription const& switchParameter, std::unique_ptr> cases, - bool optional, + Modifier modifier, bool writeToCfi); ParameterDescriptionNode* ifExists(ParameterDescriptionNode const& node1, ParameterDescriptionNode const& node2, - bool optional, + Modifier modifier, bool writeToCfi); template - ParameterDescriptionNode* labelsFrom(U const& iLabel, bool isTracked, bool optional, bool writeToCfi); + ParameterDescriptionNode* labelsFrom(U const& iLabel, bool isTracked, Modifier modifier, bool writeToCfi); template - ParameterDescriptionNode* labelsFrom(U const& iLabel, bool isTracked, bool optional, bool writeToCfi, V const& desc); + ParameterDescriptionNode* labelsFrom( + U const& iLabel, bool isTracked, Modifier modifier, bool writeToCfi, V const& desc); static void validateNode(SetDescriptionEntry const& entry, ParameterSet& pset, @@ -390,20 +426,20 @@ namespace edm { template ParameterDescriptionBase* ParameterSetDescription::add( - U const& iLabel, T const& value, bool isTracked, bool isOptional, bool writeToCfi) { + U const& iLabel, T const& value, bool isTracked, Modifier modifier, bool writeToCfi) { std::unique_ptr node = std::make_unique>(iLabel, value, isTracked); - ParameterDescriptionNode* pnode = addNode(std::move(node), isOptional, writeToCfi); + ParameterDescriptionNode* pnode = addNode(std::move(node), modifier, writeToCfi); return static_cast(pnode); } template ParameterDescriptionBase* ParameterSetDescription::add(U const& iLabel, bool isTracked, - bool isOptional, + Modifier modifier, bool writeToCfi) { std::unique_ptr node = std::make_unique>(iLabel, isTracked); - ParameterDescriptionNode* pnode = addNode(std::move(node), isOptional, writeToCfi); + ParameterDescriptionNode* pnode = addNode(std::move(node), modifier, writeToCfi); return static_cast(pnode); } @@ -412,20 +448,20 @@ namespace edm { ParameterSetDescription const& validator, std::vector const& defaults, bool isTracked, - bool isOptional, + Modifier modifier, bool writeToCfi) { std::unique_ptr node = std::make_unique>>(iLabel, validator, isTracked, defaults); - ParameterDescriptionNode* pnode = addNode(std::move(node), isOptional, writeToCfi); + ParameterDescriptionNode* pnode = addNode(std::move(node), modifier, writeToCfi); return static_cast(pnode); } template ParameterDescriptionBase* ParameterSetDescription::addVPSet( - U const& iLabel, ParameterSetDescription const& validator, bool isTracked, bool isOptional, bool writeToCfi) { + U const& iLabel, ParameterSetDescription const& validator, bool isTracked, Modifier modifier, bool writeToCfi) { std::unique_ptr node = std::make_unique>>(iLabel, validator, isTracked); - ParameterDescriptionNode* pnode = addNode(std::move(node), isOptional, writeToCfi); + ParameterDescriptionNode* pnode = addNode(std::move(node), modifier, writeToCfi); return static_cast(pnode); } @@ -433,35 +469,35 @@ namespace edm { ParameterWildcardBase* ParameterSetDescription::addWildcard(U const& pattern, bool isTracked) { std::unique_ptr node = std::make_unique>(pattern, RequireZeroOrMore, isTracked); - ParameterDescriptionNode* pnode = addNode(std::move(node), true, true); + ParameterDescriptionNode* pnode = addNode(std::move(node), Modifier::kOptional, true); return static_cast(pnode); } template ParameterDescriptionNode* ParameterSetDescription::ifValue(ParameterDescription const& switchParameter, std::unique_ptr> cases, - bool optional, + Modifier modifier, bool writeToCfi) { std::unique_ptr pdswitch = std::make_unique>(switchParameter, std::move(cases)); - return addNode(std::move(pdswitch), optional, writeToCfi); + return addNode(std::move(pdswitch), modifier, writeToCfi); } template ParameterDescriptionNode* ParameterSetDescription::labelsFrom(U const& iLabel, bool isTracked, - bool optional, + Modifier modifier, bool writeToCfi) { std::unique_ptr pd = std::make_unique>(iLabel, isTracked); - return addNode(std::move(pd), optional, writeToCfi); + return addNode(std::move(pd), modifier, writeToCfi); } template ParameterDescriptionNode* ParameterSetDescription::labelsFrom( - U const& iLabel, bool isTracked, bool optional, bool writeToCfi, V const& desc) { + U const& iLabel, bool isTracked, Modifier modifier, bool writeToCfi, V const& desc) { std::unique_ptr pd = std::make_unique>(iLabel, desc, isTracked); - return addNode(std::move(pd), optional, writeToCfi); + return addNode(std::move(pd), modifier, writeToCfi); } } // namespace edm diff --git a/FWCore/ParameterSet/interface/ParameterSwitch.h b/FWCore/ParameterSet/interface/ParameterSwitch.h index fffc62bbecebf..9463b73719b57 100644 --- a/FWCore/ParameterSet/interface/ParameterSwitch.h +++ b/FWCore/ParameterSet/interface/ParameterSwitch.h @@ -60,8 +60,8 @@ namespace edm { } } - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override { - switch_.validate(pset, validatedLabels, optional); + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override { + switch_.validate(pset, validatedLabels, modifier); if (switch_.exists(pset)) { T switchValue; if (switch_.isTracked()) { @@ -71,7 +71,7 @@ namespace edm { } typename CaseMap::const_iterator selectedCase = cases_.find(switchValue); if (selectedCase != cases_.end()) { - selectedCase->second->validate(pset, validatedLabels, false); + selectedCase->second->validate(pset, validatedLabels, Modifier::kNone); } else { std::stringstream ss; ss << "The switch parameter with label \"" << switch_.label() << "\" has been assigned an illegal value.\n" @@ -87,12 +87,12 @@ namespace edm { } void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const override { - switch_.writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + switch_.writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); if (std::holds_alternative(options)) { std::set labels; @@ -108,13 +108,13 @@ namespace edm { typename CaseMap::const_iterator selectedCase = cases_.find(switch_.getDefaultValue()); if (selectedCase != cases_.end()) { - selectedCase->second->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + selectedCase->second->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); } } - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override { + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override { printBase(os, - optional, + modifier, writeToCfi, dfh, switch_.label(), @@ -126,7 +126,7 @@ namespace edm { DocFormatHelper new_dfh(dfh); printNestedContentBase(os, dfh, new_dfh, switch_.label()); - switch_.print(os, optional, true, new_dfh); + switch_.print(os, modifierIsOptional(optional), true, new_dfh); for_all(cases_, std::bind(&ParameterSwitchBase::printCaseT, std::placeholders::_1, @@ -140,7 +140,7 @@ namespace edm { new_dfh.indent(os); os << "switch:\n"; - switch_.print(os, optional, true, new_dfh); + switch_.print(os, modifierIsOptional(optional), true, new_dfh); for_all(cases_, std::bind(&ParameterSwitchBase::printCaseT, std::placeholders::_1, diff --git a/FWCore/ParameterSet/interface/ParameterSwitchBase.h b/FWCore/ParameterSet/interface/ParameterSwitchBase.h index 7f8df8a2b0f69..5845a50b74337 100644 --- a/FWCore/ParameterSet/interface/ParameterSwitchBase.h +++ b/FWCore/ParameterSet/interface/ParameterSwitchBase.h @@ -35,7 +35,7 @@ namespace edm { void throwNoCaseForSwitchValue(std::string const& message) const; void printBase(std::ostream& os, - bool optional, + Modifier modifier, bool writeToCfi, DocFormatHelper& dfh, std::string const& switchLabel, diff --git a/FWCore/ParameterSet/interface/ParameterWildcard.h b/FWCore/ParameterSet/interface/ParameterWildcard.h index ac893fe5a9157..c33f5885cff4c 100644 --- a/FWCore/ParameterSet/interface/ParameterWildcard.h +++ b/FWCore/ParameterSet/interface/ParameterWildcard.h @@ -37,9 +37,9 @@ namespace edm { ParameterDescriptionNode* clone() const override { return new ParameterWildcard(*this); } private: - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override { + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override { std::vector parameterNames = pset.getParameterNamesForType(isTracked()); - validateMatchingNames(parameterNames, validatedLabels, optional); + validateMatchingNames(parameterNames, validatedLabels, modifier != Modifier::kNone); } bool exists_(ParameterSet const& pset) const override { @@ -77,7 +77,7 @@ namespace edm { private: void writeTemplate(std::ostream& os, int indentation, CfiOptions&) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; bool hasNestedContent_() const override; @@ -110,7 +110,7 @@ namespace edm { ParameterDescriptionNode* clone() const override; private: - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; bool hasNestedContent_() const override; diff --git a/FWCore/ParameterSet/interface/ParameterWildcardBase.h b/FWCore/ParameterSet/interface/ParameterWildcardBase.h index 71fc78448a2ef..35d5fab6f77fe 100644 --- a/FWCore/ParameterSet/interface/ParameterWildcardBase.h +++ b/FWCore/ParameterSet/interface/ParameterWildcardBase.h @@ -42,13 +42,13 @@ namespace edm { std::set& wildcardTypes) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool partiallyExists_(ParameterSet const& pset) const override; diff --git a/FWCore/ParameterSet/interface/ParameterWildcardWithSpecifics.h b/FWCore/ParameterSet/interface/ParameterWildcardWithSpecifics.h index 77075c07466dd..289a3d5166256 100644 --- a/FWCore/ParameterSet/interface/ParameterWildcardWithSpecifics.h +++ b/FWCore/ParameterSet/interface/ParameterWildcardWithSpecifics.h @@ -23,7 +23,7 @@ namespace edm { ParameterDescriptionNode* clone() const override; private: - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; bool hasNestedContent_() const override; diff --git a/FWCore/ParameterSet/interface/PluginDescription.h b/FWCore/ParameterSet/interface/PluginDescription.h index 0386caa03305b..6773745437687 100644 --- a/FWCore/ParameterSet/interface/PluginDescription.h +++ b/FWCore/ParameterSet/interface/PluginDescription.h @@ -124,7 +124,7 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const final {} - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const final { + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const final { loadDescription(findType(pset)).validate(pset); //all names are good auto n = pset.getParameterNames(); @@ -132,7 +132,7 @@ namespace edm { } void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, diff --git a/FWCore/ParameterSet/src/ANDGroupDescription.cc b/FWCore/ParameterSet/src/ANDGroupDescription.cc index 9832492b3e227..e8cc1ecb86428 100644 --- a/FWCore/ParameterSet/src/ANDGroupDescription.cc +++ b/FWCore/ParameterSet/src/ANDGroupDescription.cc @@ -53,28 +53,30 @@ namespace edm { wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end()); } - void ANDGroupDescription::validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const { - if (partiallyExists(pset) || !optional) { - node_left_->validate(pset, validatedLabels, false); - node_right_->validate(pset, validatedLabels, false); + void ANDGroupDescription::validate_(ParameterSet& pset, + std::set& validatedLabels, + Modifier modifier) const { + if (partiallyExists(pset) || modifier == Modifier::kNone) { + node_left_->validate(pset, validatedLabels, Modifier::kNone); + node_right_->validate(pset, validatedLabels, Modifier::kNone); } } void ANDGroupDescription::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const { - node_left_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); - node_right_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + node_left_->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); + node_right_->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); } - void ANDGroupDescription::print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const { + void ANDGroupDescription::print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const { if (dfh.parent() == DocFormatHelper::AND) { dfh.decrementCounter(); - node_left_->print(os, false, true, dfh); - node_right_->print(os, false, true, dfh); + node_left_->print(os, Modifier::kNone, true, dfh); + node_right_->print(os, Modifier::kNone, true, dfh); return; } @@ -82,9 +84,13 @@ namespace edm { dfh.indent(os); os << "AND group:"; + bool const optional = (modifier == Modifier::kOptional); + bool const obsolete = (modifier == Modifier::kObsolete); if (dfh.brief()) { if (optional) os << " optional"; + if (obsolete) + os << " obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; @@ -98,6 +104,8 @@ namespace edm { if (optional) os << "optional"; + if (obsolete) + os << " obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; if (optional || !writeToCfi) { @@ -149,14 +157,14 @@ namespace edm { new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent()); new_dfh.setParent(DocFormatHelper::AND); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(1); new_dfh.setCounter(0); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(2); new_dfh.setCounter(0); diff --git a/FWCore/ParameterSet/src/ANDGroupDescription.h b/FWCore/ParameterSet/src/ANDGroupDescription.h index f97c6e9b835ec..9b0ccc8646dc7 100644 --- a/FWCore/ParameterSet/src/ANDGroupDescription.h +++ b/FWCore/ParameterSet/src/ANDGroupDescription.h @@ -35,16 +35,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool hasNestedContent_() const override { return true; } diff --git a/FWCore/ParameterSet/src/AllowedLabelsDescriptionBase.cc b/FWCore/ParameterSet/src/AllowedLabelsDescriptionBase.cc index 5d38577f040b1..4a2126febd3ed 100644 --- a/FWCore/ParameterSet/src/AllowedLabelsDescriptionBase.cc +++ b/FWCore/ParameterSet/src/AllowedLabelsDescriptionBase.cc @@ -28,8 +28,8 @@ namespace edm { void AllowedLabelsDescriptionBase::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { - parameterHoldingLabels_.validate(pset, validatedLabels, optional); + Modifier modifier) const { + parameterHoldingLabels_.validate(pset, validatedLabels, modifier); if (parameterHoldingLabels_.exists(pset)) { std::vector allowedLabels; if (isTracked()) { @@ -47,16 +47,16 @@ namespace edm { } void AllowedLabelsDescriptionBase::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const { - parameterHoldingLabels_.writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + parameterHoldingLabels_.writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); } void AllowedLabelsDescriptionBase::print_(std::ostream& os, - bool optional, + Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const { if (dfh.pass() == 1) { @@ -64,9 +64,12 @@ namespace edm { os << parameterHoldingLabels_.label() << " (list of allowed labels)"; if (dfh.brief()) { - if (optional) + if (modifier == Modifier::kOptional) os << " optional"; + if (modifier == Modifier::kObsolete) + os << " obsolete"; + if (!writeToCfi) os << " (do not write to cfi)"; @@ -77,11 +80,13 @@ namespace edm { os << "\n"; dfh.indent2(os); - if (optional) + if (modifier == Modifier::kOptional) os << "optional"; + if (modifier == Modifier::kObsolete) + os << "obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; - if (optional || !writeToCfi) { + if (modifier == Modifier::kOptional || !writeToCfi) { os << "\n"; dfh.indent2(os); } @@ -125,7 +130,7 @@ namespace edm { DocFormatHelper new_dfh(dfh); new_dfh.init(); new_dfh.setPass(1); - parameterHoldingLabels_.print(os, optional, true, new_dfh); + parameterHoldingLabels_.print(os, modifierIsOptional(optional), true, new_dfh); dfh.indent(os); os << "type of allowed parameters:"; if (dfh.brief()) diff --git a/FWCore/ParameterSet/src/EmptyGroupDescription.cc b/FWCore/ParameterSet/src/EmptyGroupDescription.cc index ed6f744003783..e73fcdf6bbb8e 100644 --- a/FWCore/ParameterSet/src/EmptyGroupDescription.cc +++ b/FWCore/ParameterSet/src/EmptyGroupDescription.cc @@ -14,17 +14,17 @@ namespace edm { void EmptyGroupDescription::validate_(ParameterSet&, std::set& /*validatedLabels*/, - bool /*optional*/) const {} + Modifier /*optional*/) const {} void EmptyGroupDescription::writeCfi_(std::ostream&, - bool /*optional*/, + Modifier /*optional*/, bool& /*startWithComma*/, int /*indentation*/, CfiOptions&, bool& /*wroteSomething*/) const {} void EmptyGroupDescription::print_(std::ostream& os, - bool /*optional*/, + Modifier /*optional*/, bool /*writeToCfi*/, DocFormatHelper& dfh) const { if (dfh.pass() == 1) { diff --git a/FWCore/ParameterSet/src/IfExistsDescription.cc b/FWCore/ParameterSet/src/IfExistsDescription.cc index e60a9c38406f3..075582ee82be0 100644 --- a/FWCore/ParameterSet/src/IfExistsDescription.cc +++ b/FWCore/ParameterSet/src/IfExistsDescription.cc @@ -53,44 +53,50 @@ namespace edm { wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end()); } - void IfExistsDescription::validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const { + void IfExistsDescription::validate_(ParameterSet& pset, + std::set& validatedLabels, + Modifier modifier) const { bool leftExists = node_left_->exists(pset); bool rightExists = node_right_->exists(pset); if (!leftExists && !rightExists) { return; } else if (leftExists && rightExists) { - node_left_->validate(pset, validatedLabels, false); - node_right_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); + node_right_->validate(pset, validatedLabels, Modifier::kNone); } else if (leftExists && !rightExists) { - node_left_->validate(pset, validatedLabels, false); - if (!optional) - node_right_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); + if (modifier == Modifier::kNone) + node_right_->validate(pset, validatedLabels, Modifier::kNone); } else if (!leftExists && rightExists) { - node_left_->validate(pset, validatedLabels, false); - node_right_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); + node_right_->validate(pset, validatedLabels, Modifier::kNone); } } void IfExistsDescription::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const { - node_left_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); - node_right_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + node_left_->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); + node_right_->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); parameterMustBeTyped(options); } - void IfExistsDescription::print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const { + void IfExistsDescription::print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const { if (dfh.pass() == 1) { dfh.indent(os); os << "IfExists pair:"; + const bool optional = (modifier == Modifier::kOptional); + const bool obsolete = (modifier == Modifier::kObsolete); if (dfh.brief()) { if (optional) os << " optional"; + if (obsolete) + os << " obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; @@ -104,6 +110,8 @@ namespace edm { if (optional) os << "optional"; + if (obsolete) + os << " obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; if (optional || !writeToCfi) { @@ -151,14 +159,14 @@ namespace edm { new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent()); new_dfh.setParent(DocFormatHelper::OTHER); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(1); new_dfh.setCounter(0); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(2); new_dfh.setCounter(0); diff --git a/FWCore/ParameterSet/src/ORGroupDescription.cc b/FWCore/ParameterSet/src/ORGroupDescription.cc index 8c9d6d2e4da3b..6d9f23d90ed68 100644 --- a/FWCore/ParameterSet/src/ORGroupDescription.cc +++ b/FWCore/ParameterSet/src/ORGroupDescription.cc @@ -53,41 +53,45 @@ namespace edm { wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end()); } - void ORGroupDescription::validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const { + void ORGroupDescription::validate_(ParameterSet& pset, + std::set& validatedLabels, + Modifier modifier) const { bool leftExists = node_left_->exists(pset); bool rightExists = node_right_->exists(pset); if (leftExists || rightExists) { if (leftExists) - node_left_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); if (rightExists) - node_right_->validate(pset, validatedLabels, false); + node_right_->validate(pset, validatedLabels, Modifier::kNone); return; } - if (optional) + if (modifier != Modifier::kNone) return; - node_left_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); } void ORGroupDescription::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const { - node_left_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + node_left_->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); } - void ORGroupDescription::print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const { + void ORGroupDescription::print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const { if (dfh.parent() == DocFormatHelper::OR) { dfh.decrementCounter(); - node_left_->print(os, false, true, dfh); - node_right_->print(os, false, true, dfh); + node_left_->print(os, Modifier::kNone, true, dfh); + node_right_->print(os, Modifier::kNone, true, dfh); return; } + const bool optional = (modifier == Modifier::kOptional); + const bool obsolete = (modifier == Modifier::kObsolete); if (dfh.pass() == 1) { dfh.indent(os); os << "OR group:"; @@ -95,6 +99,8 @@ namespace edm { if (dfh.brief()) { if (optional) os << " optional"; + if (obsolete) + os << " obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; @@ -108,6 +114,8 @@ namespace edm { if (optional) os << "optional"; + if (obsolete) + os << " obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; if (optional || !writeToCfi) { @@ -162,14 +170,14 @@ namespace edm { new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent()); new_dfh.setParent(DocFormatHelper::OR); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(1); new_dfh.setCounter(0); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(2); new_dfh.setCounter(0); diff --git a/FWCore/ParameterSet/src/ORGroupDescription.h b/FWCore/ParameterSet/src/ORGroupDescription.h index 5c2cb6ff0cbe6..b9a9327c35751 100644 --- a/FWCore/ParameterSet/src/ORGroupDescription.h +++ b/FWCore/ParameterSet/src/ORGroupDescription.h @@ -33,16 +33,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool hasNestedContent_() const override { return true; } diff --git a/FWCore/ParameterSet/src/ParameterDescription.cc b/FWCore/ParameterSet/src/ParameterDescription.cc index 6e83f8173a33c..e9bf70d5aaa91 100644 --- a/FWCore/ParameterSet/src/ParameterDescription.cc +++ b/FWCore/ParameterSet/src/ParameterDescription.cc @@ -10,6 +10,7 @@ #include "FWCore/ParameterSet/src/FillDescriptionFromPSet.h" #include "FWCore/ParameterSet/interface/ParameterSetDescription.h" #include "FWCore/ParameterSet/interface/VParameterSetEntry.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/Algorithms.h" #include "FWCore/Utilities/interface/EDMException.h" #include "FWCore/Utilities/interface/InputTag.h" @@ -43,7 +44,7 @@ namespace edm { void ParameterDescription::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { + Modifier modifier) const { bool exists = pset.existsAs(label(), isTracked()); if (exists) { @@ -54,7 +55,7 @@ namespace edm { throwParameterWrongType(); } - if (!optional && !exists) { + if (modifier == Modifier::kNone && !exists) { if (isTracked()) { pset.addParameter(label(), ParameterSet()); } else { @@ -66,6 +67,10 @@ namespace edm { exists = pset.existsAs(label(), isTracked()); if (exists) { + if (modifier == Modifier::kObsolete) { + edm::LogWarning("Configuration") << "ignoring obsolete parameter '" << label() << "'"; + return; + } if (pset.isRegistered()) { pset.invalidateRegistration(""); } @@ -196,7 +201,7 @@ namespace edm { void ParameterDescription >::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { + Modifier modifier) const { bool exists = pset.existsAs >(label(), isTracked()); if (exists) { @@ -207,7 +212,7 @@ namespace edm { throwParameterWrongType(); } - if (!exists && !optional) { + if (!exists && modifier == Modifier::kNone) { if (hasDefault()) { if (isTracked()) { pset.addParameter(label(), vPset_); @@ -222,6 +227,10 @@ namespace edm { exists = pset.existsAs >(label(), isTracked()); if (exists) { + if (modifier == Modifier::kObsolete) { + edm::LogWarning("Configuration") << "ignoring obsolete parameter '" << label() << "'"; + return; + } VParameterSetEntry* vpsetEntry = pset.getPSetVectorForUpdate(label()); assert(vpsetEntry); diff --git a/FWCore/ParameterSet/src/ParameterDescriptionBase.cc b/FWCore/ParameterSet/src/ParameterDescriptionBase.cc index d20cd9dcf9f68..edf03c99c351e 100644 --- a/FWCore/ParameterSet/src/ParameterDescriptionBase.cc +++ b/FWCore/ParameterSet/src/ParameterDescriptionBase.cc @@ -14,6 +14,7 @@ #include "FWCore/ParameterSet/interface/DocFormatHelper.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" #include "FWCore/Utilities/interface/EDMException.h" #include @@ -97,7 +98,7 @@ namespace edm { void ParameterDescriptionBase::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { + Modifier modifier) const { bool exists = exists_(pset, isTracked()); if (exists) { @@ -108,7 +109,11 @@ namespace edm { throwParameterWrongType(); } - if (!exists && !optional) { + if (exists and modifier == Modifier::kObsolete) { + edm::LogWarning("Configuration") << "ignoring obsolete parameter '" << label() << "'"; + return; + } + if (!exists && modifier == Modifier::kNone) { if (hasDefault()) { insertDefault_(pset); validatedLabels.insert(label()); @@ -119,7 +124,7 @@ namespace edm { } void ParameterDescriptionBase::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, @@ -131,11 +136,13 @@ namespace edm { auto check = cfi::needToSwitchToTyped(label(), options); if (check.first) { CfiOptions fullOp = cfi::Typed{}; - writeFullCfi(os, optional, startWithComma, indentation, fullOp, wroteSomething); + writeFullCfi(os, modifier, startWithComma, indentation, fullOp, wroteSomething); } else if (shouldWriteUntyped(options)) { - writeLabelValueCfi(os, optional, startWithComma, indentation, options, wroteSomething); + if (modifier != Modifier::kObsolete) { + writeLabelValueCfi(os, modifier == Modifier::kOptional, startWithComma, indentation, options, wroteSomething); + } } else { - writeFullCfi(os, optional, startWithComma, indentation, options, wroteSomething); + writeFullCfi(os, modifier, startWithComma, indentation, options, wroteSomething); } } @@ -199,7 +206,7 @@ namespace edm { } void ParameterDescriptionBase::writeFullCfi(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, @@ -214,9 +221,11 @@ namespace edm { os << label() << " = cms."; - if (!hasDefault()) { - if (optional) { + if (modifier == Modifier::kObsolete or !hasDefault()) { + if (modifier == Modifier::kOptional) { os << "optional."; + } else if (modifier == Modifier::kObsolete) { + os << "obsolete."; } else { os << "required."; } @@ -231,7 +240,12 @@ namespace edm { os << ")"; } } - void ParameterDescriptionBase::print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const { + void ParameterDescriptionBase::print_(std::ostream& os, + Modifier modifier, + bool writeToCfi, + DocFormatHelper& dfh) const { + const bool optional = (modifier == Modifier::kOptional); + const bool obsolete = (modifier == Modifier::kObsolete); if (dfh.pass() == 0) { dfh.setAtLeast1(label().size()); if (isTracked()) { @@ -262,6 +276,8 @@ namespace edm { os << std::setw(dfh.column3()); if (optional) { os << "optional"; + } else if (obsolete) { + os << "obsolete"; } else { os << ""; } @@ -282,6 +298,8 @@ namespace edm { if (optional) os << "optional"; + if (obsolete) + os << "obsolete"; os << "\n"; dfh.indent2(os); diff --git a/FWCore/ParameterSet/src/ParameterDescriptionNode.cc b/FWCore/ParameterSet/src/ParameterDescriptionNode.cc index a1320688163f1..fdf86693e35e8 100644 --- a/FWCore/ParameterSet/src/ParameterDescriptionNode.cc +++ b/FWCore/ParameterSet/src/ParameterDescriptionNode.cc @@ -110,11 +110,14 @@ namespace edm { void ParameterDescriptionNode::setComment(char const* value) { comment_ = value; } - void ParameterDescriptionNode::print(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const { + void ParameterDescriptionNode::print(std::ostream& os, + Modifier modifier, + bool writeToCfi, + DocFormatHelper& dfh) const { if (hasNestedContent()) { dfh.incrementCounter(); } - print_(os, optional, writeToCfi, dfh); + print_(os, modifier, writeToCfi, dfh); } void ParameterDescriptionNode::printNestedContent(std::ostream& os, bool optional, DocFormatHelper& dfh) const { diff --git a/FWCore/ParameterSet/src/ParameterSetDescription.cc b/FWCore/ParameterSet/src/ParameterSetDescription.cc index ca9331215d7b1..4a64de18f9732 100644 --- a/FWCore/ParameterSet/src/ParameterSetDescription.cc +++ b/FWCore/ParameterSet/src/ParameterSetDescription.cc @@ -40,26 +40,26 @@ namespace edm { ParameterDescriptionNode* ParameterSetDescription::addNode(ParameterDescriptionNode const& node) { std::unique_ptr clonedNode(node.clone()); - return addNode(std::move(clonedNode), false, true); + return addNode(std::move(clonedNode), Modifier::kNone, true); } ParameterDescriptionNode* ParameterSetDescription::addNode(std::unique_ptr node) { - return addNode(std::move(node), false, true); + return addNode(std::move(node), Modifier::kNone, true); } ParameterDescriptionNode* ParameterSetDescription::addOptionalNode(ParameterDescriptionNode const& node, bool writeToCfi) { std::unique_ptr clonedNode(node.clone()); - return addNode(std::move(clonedNode), true, writeToCfi); + return addNode(std::move(clonedNode), Modifier::kOptional, writeToCfi); } ParameterDescriptionNode* ParameterSetDescription::addOptionalNode(std::unique_ptr node, bool writeToCfi) { - return addNode(std::move(node), true, writeToCfi); + return addNode(std::move(node), Modifier::kOptional, writeToCfi); } ParameterDescriptionNode* ParameterSetDescription::addNode(std::unique_ptr node, - bool optional, + Modifier modifier, bool writeToCfi) { std::set nodeLabels; std::set nodeParameterTypes; @@ -69,7 +69,7 @@ namespace edm { throwIfWildcardCollision(nodeParameterTypes, nodeWildcardTypes); SetDescriptionEntry entry; - entry.setOptional(optional); + entry.setModifier(modifier); entry.setWriteToCfi(writeToCfi); entries_.push_back(entry); return entries_.back().setNode(std::move(node)); @@ -158,7 +158,7 @@ namespace edm { void ParameterSetDescription::validateNode(SetDescriptionEntry const& entry, ParameterSet& pset, std::set& validatedLabels) { - entry.node()->validate(pset, validatedLabels, entry.optional()); + entry.node()->validate(pset, validatedLabels, entry.modifier()); } void ParameterSetDescription::print(std::ostream& os, DocFormatHelper& dfh) const { @@ -242,7 +242,7 @@ namespace edm { CfiOptions& options, bool& wroteSomething) { if (entry.writeToCfi()) { - entry.node()->writeCfi(os, entry.optional(), startWithComma, indentation, options, wroteSomething); + entry.node()->writeCfi(os, entry.modifier(), startWithComma, indentation, options, wroteSomething); } else { //The simplest way to handle this is to force all items to be full in this PSet cfi::parameterMustBeTyped(options); @@ -251,7 +251,7 @@ namespace edm { void ParameterSetDescription::printNode(SetDescriptionEntry const& entry, std::ostream& os, DocFormatHelper& dfh) { if (dfh.pass() < 2) { - entry.node()->print(os, entry.optional(), entry.writeToCfi(), dfh); + entry.node()->print(os, entry.modifier(), entry.writeToCfi(), dfh); } else { entry.node()->printNestedContent(os, entry.optional(), dfh); } @@ -343,9 +343,9 @@ namespace edm { ParameterDescriptionNode* ParameterSetDescription::ifExists(ParameterDescriptionNode const& node1, ParameterDescriptionNode const& node2, - bool optional, + Modifier modifier, bool writeToCfi) { std::unique_ptr pdIfExists = std::make_unique(node1, node2); - return addNode(std::move(pdIfExists), optional, writeToCfi); + return addNode(std::move(pdIfExists), modifier, writeToCfi); } } // namespace edm diff --git a/FWCore/ParameterSet/src/ParameterSwitchBase.cc b/FWCore/ParameterSet/src/ParameterSwitchBase.cc index 09cfb13cd4bd2..75a84065400b7 100644 --- a/FWCore/ParameterSet/src/ParameterSwitchBase.cc +++ b/FWCore/ParameterSet/src/ParameterSwitchBase.cc @@ -59,7 +59,7 @@ namespace edm { } void ParameterSwitchBase::printBase(std::ostream& os, - bool optional, + Modifier modifier, bool writeToCfi, DocFormatHelper& dfh, std::string const& switchLabel, @@ -77,6 +77,8 @@ namespace edm { if (dfh.pass() == 1) { dfh.indent(os); + const bool optional = (Modifier::kOptional == modifier); + const bool obsolete = (Modifier::kObsolete == modifier); if (dfh.brief()) { std::stringstream ss; ss << switchLabel << " (switch)"; @@ -96,6 +98,8 @@ namespace edm { os << " " << std::setw(dfh.column3()); if (optional) os << "optional"; + else if (obsolete) + os << "obsolete"; else os << ""; @@ -117,6 +121,8 @@ namespace edm { if (optional) os << "optional"; + if (obsolete) + os << "obsolete"; if (!writeToCfi) os << " (do not write to cfi)"; @@ -172,7 +178,7 @@ namespace edm { DocFormatHelper& dfh, std::string const& switchLabel) { if (dfh.pass() == 0) { - p.second->print(os, false, true, dfh); + p.second->print(os, Modifier::kNone, true, dfh); } if (dfh.pass() == 1) { dfh.indent(os); @@ -182,7 +188,7 @@ namespace edm { else os << "False"; os << "\n"; - p.second->print(os, false, true, dfh); + p.second->print(os, Modifier::kNone, true, dfh); } if (dfh.pass() == 2) { p.second->printNestedContent(os, false, dfh); @@ -195,12 +201,12 @@ namespace edm { DocFormatHelper& dfh, std::string const& switchLabel) { if (dfh.pass() == 0) { - p.second->print(os, false, true, dfh); + p.second->print(os, Modifier::kNone, true, dfh); } if (dfh.pass() == 1) { dfh.indent(os); os << "if " << switchLabel << " = " << p.first << "\n"; - p.second->print(os, false, true, dfh); + p.second->print(os, Modifier::kNone, true, dfh); } if (dfh.pass() == 2) { p.second->printNestedContent(os, false, dfh); @@ -213,12 +219,12 @@ namespace edm { DocFormatHelper& dfh, std::string const& switchLabel) { if (dfh.pass() == 0) { - p.second->print(os, false, true, dfh); + p.second->print(os, Modifier::kNone, true, dfh); } if (dfh.pass() == 1) { dfh.indent(os); os << "if " << switchLabel << " = \"" << p.first << "\"\n"; - p.second->print(os, false, true, dfh); + p.second->print(os, Modifier::kNone, true, dfh); } if (dfh.pass() == 2) { p.second->printNestedContent(os, false, dfh); diff --git a/FWCore/ParameterSet/src/ParameterWildcard.cc b/FWCore/ParameterSet/src/ParameterWildcard.cc index 192debc4a94cb..fb278a53a863b 100644 --- a/FWCore/ParameterSet/src/ParameterWildcard.cc +++ b/FWCore/ParameterSet/src/ParameterWildcard.cc @@ -49,9 +49,9 @@ namespace edm { void ParameterWildcard::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { + Modifier modifier) const { std::vector parameterNames = pset.getParameterNamesForType(isTracked()); - validateMatchingNames(parameterNames, validatedLabels, optional); + validateMatchingNames(parameterNames, validatedLabels, modifier == Modifier::kOptional); if (psetDesc_) { for_all(parameterNames, @@ -162,9 +162,9 @@ namespace edm { void ParameterWildcard >::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { + Modifier modifier) const { std::vector parameterNames = pset.getParameterNamesForType >(isTracked()); - validateMatchingNames(parameterNames, validatedLabels, optional); + validateMatchingNames(parameterNames, validatedLabels, modifier == Modifier::kOptional); if (psetDesc_) { for_all(parameterNames, diff --git a/FWCore/ParameterSet/src/ParameterWildcardBase.cc b/FWCore/ParameterSet/src/ParameterWildcardBase.cc index 23de41b4bb45d..4ce289041266c 100644 --- a/FWCore/ParameterSet/src/ParameterWildcardBase.cc +++ b/FWCore/ParameterSet/src/ParameterWildcardBase.cc @@ -61,7 +61,10 @@ namespace edm { wildcardTypes.insert(type()); } - void ParameterWildcardBase::print_(std::ostream& os, bool optional, bool /*writeToCfi*/, DocFormatHelper& dfh) const { + void ParameterWildcardBase::print_(std::ostream& os, + Modifier modifier, + bool /*writeToCfi*/, + DocFormatHelper& dfh) const { if (dfh.pass() == 0) { dfh.setAtLeast1(11U); if (isTracked()) { @@ -71,6 +74,8 @@ namespace edm { } dfh.setAtLeast3(8U); } else { + const bool optional = (Modifier::kOptional == modifier); + const bool obsolete = (Modifier::kObsolete == modifier); if (dfh.brief()) { dfh.indent(os); std::ios::fmtflags oldFlags = os.flags(); @@ -89,6 +94,8 @@ namespace edm { os << std::setw(dfh.column3()); if (optional) os << "optional"; + else if (obsolete) + os << "obsolete"; else os << ""; @@ -121,6 +128,8 @@ namespace edm { if (optional) os << " optional"; + if (obsolete) + os << "obsolete"; os << "\n"; dfh.indent2(os); @@ -147,7 +156,7 @@ namespace edm { } void ParameterWildcardBase::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, @@ -162,8 +171,10 @@ namespace edm { os << "allowAnyLabel_ = cms."; - if (optional) { + if (Modifier::kOptional == modifier) { os << "optional."; + } else if (Modifier::kObsolete == modifier) { + os << "obsolete."; } else { os << "required."; } diff --git a/FWCore/ParameterSet/src/ParameterWildcardWithSpecifics.cc b/FWCore/ParameterSet/src/ParameterWildcardWithSpecifics.cc index 5193951ac202b..102f649d3946c 100644 --- a/FWCore/ParameterSet/src/ParameterWildcardWithSpecifics.cc +++ b/FWCore/ParameterSet/src/ParameterWildcardWithSpecifics.cc @@ -27,9 +27,9 @@ namespace edm { void ParameterWildcardWithSpecifics::validate_(ParameterSet& pset, std::set& validatedLabels, - bool optional) const { + Modifier modifier) const { std::vector parameterNames = pset.getParameterNamesForType(isTracked()); - validateMatchingNames(parameterNames, validatedLabels, optional); + validateMatchingNames(parameterNames, validatedLabels, modifier == Modifier::kOptional); for (auto const& name : parameterNames) { validateDescription(name, pset); diff --git a/FWCore/ParameterSet/src/XORGroupDescription.cc b/FWCore/ParameterSet/src/XORGroupDescription.cc index 1824f98707205..52a630d1b4cc1 100644 --- a/FWCore/ParameterSet/src/XORGroupDescription.cc +++ b/FWCore/ParameterSet/src/XORGroupDescription.cc @@ -47,12 +47,14 @@ namespace edm { wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end()); } - void XORGroupDescription::validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const { + void XORGroupDescription::validate_(ParameterSet& pset, + std::set& validatedLabels, + Modifier modifier) const { int nExistLeft = node_left_->howManyXORSubNodesExist(pset); int nExistRight = node_right_->howManyXORSubNodesExist(pset); int nTotal = nExistLeft + nExistRight; - if (nTotal == 0 && optional) + if (nTotal == 0 && modifier != Modifier::kNone) return; if (nTotal > 1) { @@ -60,11 +62,11 @@ namespace edm { } if (nExistLeft == 1) { - node_left_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); } else if (nExistRight == 1) { - node_right_->validate(pset, validatedLabels, false); + node_right_->validate(pset, validatedLabels, Modifier::kNone); } else if (nTotal == 0) { - node_left_->validate(pset, validatedLabels, false); + node_left_->validate(pset, validatedLabels, Modifier::kNone); // When missing parameters get inserted, both nodes could // be affected so we have to recheck both nodes. @@ -79,19 +81,19 @@ namespace edm { } void XORGroupDescription::writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions& options, bool& wroteSomething) const { - node_left_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething); + node_left_->writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething); } - void XORGroupDescription::print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const { + void XORGroupDescription::print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const { if (dfh.parent() == DocFormatHelper::XOR) { dfh.decrementCounter(); - node_left_->print(os, false, true, dfh); - node_right_->print(os, false, true, dfh); + node_left_->print(os, Modifier::kNone, true, dfh); + node_right_->print(os, Modifier::kNone, true, dfh); return; } @@ -99,10 +101,15 @@ namespace edm { dfh.indent(os); os << "XOR group:"; + const bool optional = (modifier == Modifier::kOptional); + const bool obsolete = (modifier == Modifier::kObsolete); if (dfh.brief()) { - if (optional) + if (optional) { os << " optional"; - + } + if (obsolete) { + os << " obsolete"; + } if (!writeToCfi) os << " (do not write to cfi)"; @@ -113,8 +120,12 @@ namespace edm { os << "\n"; dfh.indent2(os); - if (optional) + if (optional) { os << "optional"; + } + if (obsolete) { + os << " obsolete"; + } if (!writeToCfi) os << " (do not write to cfi)"; if (optional || !writeToCfi) { @@ -166,14 +177,14 @@ namespace edm { new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent()); new_dfh.setParent(DocFormatHelper::XOR); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(1); new_dfh.setCounter(0); - node_left_->print(os, false, true, new_dfh); - node_right_->print(os, false, true, new_dfh); + node_left_->print(os, Modifier::kNone, true, new_dfh); + node_right_->print(os, Modifier::kNone, true, new_dfh); new_dfh.setPass(2); new_dfh.setCounter(0); diff --git a/FWCore/ParameterSet/src/XORGroupDescription.h b/FWCore/ParameterSet/src/XORGroupDescription.h index 6c427c4bc1a48..41dd7a921e426 100644 --- a/FWCore/ParameterSet/src/XORGroupDescription.h +++ b/FWCore/ParameterSet/src/XORGroupDescription.h @@ -35,16 +35,16 @@ namespace edm { std::set& parameterTypes, std::set& wildcardTypes) const override; - void validate_(ParameterSet& pset, std::set& validatedLabels, bool optional) const override; + void validate_(ParameterSet& pset, std::set& validatedLabels, Modifier modifier) const override; void writeCfi_(std::ostream& os, - bool optional, + Modifier modifier, bool& startWithComma, int indentation, CfiOptions&, bool& wroteSomething) const override; - void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override; + void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override; bool hasNestedContent_() const override { return true; } diff --git a/FWCore/ParameterSet/test/test_catch_ParameterSetDescription.cc b/FWCore/ParameterSet/test/test_catch_ParameterSetDescription.cc index 280346699780c..a5b9ecc2fcda5 100644 --- a/FWCore/ParameterSet/test/test_catch_ParameterSetDescription.cc +++ b/FWCore/ParameterSet/test/test_catch_ParameterSetDescription.cc @@ -87,7 +87,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") { bool startWithComma = false; bool wroteSomething = false; edm::CfiOptions ops = edm::cfi::Typed{}; - w.writeCfi(os, false, startWithComma, 0, ops, wroteSomething); + w.writeCfi(os, edm::ParameterModifier::kNone, startWithComma, 0, ops, wroteSomething); REQUIRE_THAT(os.str(), Equals("\nallowAnyLabel_ = cms.required.int32")); } @@ -110,7 +110,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") { bool wroteSomething = false; edm::CfiOptions ops = edm::cfi::Typed{}; - w.writeCfi(os, false, startWithComma, 0, ops, wroteSomething); + w.writeCfi(os, edm::ParameterModifier::kNone, startWithComma, 0, ops, wroteSomething); REQUIRE_THAT(os.str(), Equals("\nallowAnyLabel_ = cms.required.untracked.uint32")); } @@ -157,7 +157,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") { bool wroteSomething = false; edm::CfiOptions ops = edm::cfi::Typed{}; - w.writeCfi(os, false, startWithComma, 0, ops, wroteSomething); + w.writeCfi(os, edm::ParameterModifier::kNone, startWithComma, 0, ops, wroteSomething); REQUIRE_THAT(os.str(), Equals("\nallowAnyLabel_ = cms.required.double")); } @@ -192,7 +192,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") { bool startWithComma = false; bool wroteSomething = false; edm::CfiOptions ops = edm::cfi::Typed{}; - w.writeCfi(os, false, startWithComma, 0, ops, wroteSomething); + w.writeCfi(os, edm::ParameterModifier::kNone, startWithComma, 0, ops, wroteSomething); REQUIRE_THAT(os.str(), Equals("\nallowAnyLabel_ = cms.required.PSetTemplate()")); } @@ -242,7 +242,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") { bool startWithComma = false; bool wroteSomething = false; edm::CfiOptions ops = edm::cfi::Typed{}; - w.writeCfi(os, false, startWithComma, 0, ops, wroteSomething); + w.writeCfi(os, edm::ParameterModifier::kNone, startWithComma, 0, ops, wroteSomething); REQUIRE_THAT(os.str(), Equals("\nallowAnyLabel_ = cms.required.PSetTemplate(\n n1 = cms.untracked.uint32(1)\n)")); @@ -295,7 +295,7 @@ TEST_CASE("test ParameterSetDescription", "[ParameterSetDescription]") { bool startWithComma = false; bool wroteSomething = false; edm::CfiOptions ops = edm::cfi::Typed{}; - w.writeCfi(os, false, startWithComma, 0, ops, wroteSomething); + w.writeCfi(os, edm::ParameterModifier::kNone, startWithComma, 0, ops, wroteSomething); REQUIRE_THAT(os.str(), Equals("\nallowAnyLabel_ = cms.required.VPSet")); } @@ -1643,6 +1643,137 @@ p = dict( psetDesc.validate(params); } + SECTION("obsolete") { + SECTION("string") { + edm::ParameterSetDescription psetDesc; + + psetDesc.add("testname"); + psetDesc.add("hadDefault", "default"); + psetDesc.addObsolete("noLongerUsed"); + SECTION("with obsolete") { + edm::ParameterSet params; + params.addParameter("testname", std::string("testvalue")); + params.addParameter("noLongerUsed", std::string("testvalue")); + + psetDesc.validate(params); + } + SECTION("without obsolete") { + edm::ParameterSet params; + params.addParameter("testname", std::string("testvalue")); + psetDesc.validate(params); + CHECK(not params.existsAs("noLongerUsed")); + } + SECTION("writeCfi full") { + std::ostringstream s; + edm::CfiOptions fullOps = edm::cfi::Typed{}; + psetDesc.writeCfi(s, false, 0, fullOps); + std::string expected = R"-( +testname = cms.required.string, +hadDefault = cms.string('default'), +noLongerUsed = cms.obsolete.string +)-"; + + CHECK(expected == s.str()); + } + SECTION("writeCfi Untyped") { + std::ostringstream s; + edm::CfiOptions fullOps = edm::cfi::Untyped{edm::cfi::Paths{}}; + psetDesc.writeCfi(s, false, 0, fullOps); + std::string expected = R"-( +hadDefault = 'default' +)-"; + CHECK(expected == s.str()); + } + } + SECTION("PSet") { + edm::ParameterSetDescription psetDesc; + + psetDesc.add("testname"); + psetDesc.add("hadDefault", "default"); + psetDesc.addObsolete("noLongerUsed"); + SECTION("with obsolete") { + edm::ParameterSet params; + params.addParameter("testname", std::string("testvalue")); + edm::ParameterSet obs; + obs.addParameter("something", 1); + params.addParameter("noLongerUsed", obs); + + psetDesc.validate(params); + } + SECTION("without obsolete") { + edm::ParameterSet params; + params.addParameter("testname", std::string("testvalue")); + psetDesc.validate(params); + } + SECTION("writeCfi full") { + std::ostringstream s; + edm::CfiOptions fullOps = edm::cfi::Typed{}; + psetDesc.writeCfi(s, false, 0, fullOps); + std::string expected = R"-( +testname = cms.required.string, +hadDefault = cms.string('default'), +noLongerUsed = cms.obsolete.PSet +)-"; + + CHECK(expected == s.str()); + } + SECTION("writeCfi Untyped") { + std::ostringstream s; + edm::CfiOptions fullOps = edm::cfi::Untyped{edm::cfi::Paths{}}; + psetDesc.writeCfi(s, false, 0, fullOps); + std::string expected = R"-( +hadDefault = 'default' +)-"; + CHECK(expected == s.str()); + } + } + } + + SECTION("VPSet") { + edm::ParameterSetDescription psetDesc; + + psetDesc.add("testname"); + psetDesc.add("hadDefault", "default"); + psetDesc.addVPSetObsolete("noLongerUsed"); + SECTION("with obsolete") { + edm::ParameterSet params; + params.addParameter("testname", std::string("testvalue")); + + edm::ParameterSet obs; + obs.addParameter("something", 1); + std::vector vobs{1, obs}; + params.addParameter>("noLongerUsed", vobs); + + psetDesc.validate(params); + } + SECTION("without obsolete") { + edm::ParameterSet params; + params.addParameter("testname", std::string("testvalue")); + psetDesc.validate(params); + } + SECTION("writeCfi full") { + std::ostringstream s; + edm::CfiOptions fullOps = edm::cfi::Typed{}; + psetDesc.writeCfi(s, false, 0, fullOps); + std::string expected = R"-( +testname = cms.required.string, +hadDefault = cms.string('default'), +noLongerUsed = cms.obsolete.VPSet +)-"; + + CHECK(expected == s.str()); + } + SECTION("writeCfi Untyped") { + std::ostringstream s; + edm::CfiOptions fullOps = edm::cfi::Untyped{edm::cfi::Paths{}}; + psetDesc.writeCfi(s, false, 0, fullOps); + std::string expected = R"-( +hadDefault = 'default' +)-"; + CHECK(expected == s.str()); + } + } + SECTION("FileInPath") { // Test this type separately because I do not know how to // add an entry into a ParameterSet without FileInPath pointing