Skip to content

Commit 3b46cbe

Browse files
committed
Can mark Parameters as obsolete in fillDescriptions
- Obsolete parameters will cause a warning to be issued and then skipped in the validation. - The _cfi.py files will get a cms.obsolete parameter added which allows one to still set the parameter in python but will not be passed to the C++.
1 parent bf82d0e commit 3b46cbe

31 files changed

+496
-230
lines changed

FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ namespace edm {
3232
std::set<ParameterTypes>& parameterTypes,
3333
std::set<ParameterTypes>& wildcardTypes) const override;
3434

35-
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
35+
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;
3636

3737
void writeCfi_(std::ostream& os,
38-
bool optional,
38+
Modifier modifier,
3939
bool& startWithComma,
4040
int indentation,
4141
CfiOptions&,
4242
bool& wroteSomething) const override;
4343

44-
void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override;
44+
void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override;
4545

4646
bool hasNestedContent_() const override;
4747

FWCore/ParameterSet/interface/EmptyGroupDescription.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,16 @@ namespace edm {
2323
std::set<ParameterTypes>& parameterTypes,
2424
std::set<ParameterTypes>& wildcardTypes) const override;
2525

26-
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
26+
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;
2727

2828
void writeCfi_(std::ostream& os,
29-
bool optional,
29+
Modifier modifier,
3030
bool& startWithComma,
3131
int indentation,
3232
CfiOptions&,
3333
bool& wroteSomething) const override;
3434

35-
void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override;
35+
void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override;
3636

3737
bool exists_(ParameterSet const& pset) const override;
3838

FWCore/ParameterSet/interface/IfExistsDescription.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ namespace edm {
3535
std::set<ParameterTypes>& parameterTypes,
3636
std::set<ParameterTypes>& wildcardTypes) const override;
3737

38-
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
38+
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;
3939

4040
void writeCfi_(std::ostream& os,
41-
bool optional,
41+
Modifier modifier,
4242
bool& startWithComma,
4343
int indentation,
4444
CfiOptions&,
4545
bool& wroteSomething) const override;
4646

47-
void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override;
47+
void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override;
4848

4949
bool hasNestedContent_() const override { return true; }
5050

FWCore/ParameterSet/interface/ParameterDescription.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ namespace edm {
217217
ParameterDescriptionNode* clone() const override { return new ParameterDescription(*this); }
218218

219219
private:
220-
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
220+
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;
221221

222222
void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const override;
223223

@@ -274,7 +274,7 @@ namespace edm {
274274
void setPartOfDefaultOfVPSet(bool value) { partOfDefaultOfVPSet_ = value; }
275275

276276
private:
277-
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
277+
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;
278278

279279
void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const override;
280280

FWCore/ParameterSet/interface/ParameterDescriptionBase.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ namespace edm {
5858
std::set<ParameterTypes>& parameterTypes,
5959
std::set<ParameterTypes>& wildcardTypes) const override;
6060

61-
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
61+
void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;
6262

6363
void writeCfi_(std::ostream& os,
64-
bool optional,
64+
Modifier modifier,
6565
bool& startWithComma,
6666
int indentation,
6767
CfiOptions&,
@@ -75,7 +75,7 @@ namespace edm {
7575
bool& wroteSomething) const;
7676

7777
void writeFullCfi(std::ostream& os,
78-
bool optional,
78+
Modifier modifier,
7979
bool& startWithComma,
8080
int indentation,
8181
CfiOptions&,
@@ -89,7 +89,7 @@ namespace edm {
8989

9090
virtual void writeDoc_(std::ostream& os, int indentation) const = 0;
9191

92-
void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override;
92+
void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override;
9393

9494
virtual void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const;
9595

FWCore/ParameterSet/interface/ParameterDescriptionNode.h

+16-9
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ namespace edm {
7070

7171
std::string parameterTypeEnumToString(ParameterTypes iType);
7272

73+
enum class ParameterModifier : unsigned char { kNone, kOptional, kObsolete };
74+
inline ParameterModifier modifierIsOptional(bool iOptional) {
75+
return iOptional ? ParameterModifier::kOptional : ParameterModifier::kNone;
76+
}
77+
7378
namespace cfi {
7479
struct Paths {
7580
//This is the 'path' through the cms.PSet hierarchy.
@@ -204,6 +209,8 @@ namespace edm {
204209

205210
class ParameterDescriptionNode {
206211
public:
212+
using Modifier = ParameterModifier;
213+
207214
ParameterDescriptionNode() {}
208215

209216
explicit ParameterDescriptionNode(Comment const& iComment) : comment_(iComment.comment()) {}
@@ -219,11 +226,11 @@ namespace edm {
219226
// The validate function should do one of three things, find that the
220227
// node "exists", make the node "exist" by inserting missing parameters
221228
// or throw. The only exception to this rule occurs when the argument
222-
// named "optional" is true, which should only be possible for the
229+
// named "modifier" is kOptional or kObsolete, which should only be possible for the
223230
// top level nodes of a ParameterSetDescription. When a parameter is
224231
// found or inserted its label is added into the list of validatedLabels.
225-
void validate(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const {
226-
validate_(pset, validatedLabels, optional);
232+
void validate(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const {
233+
validate_(pset, validatedLabels, modifier);
227234
}
228235

229236
// As long as it has default values, this will attempt to write
@@ -237,16 +244,16 @@ namespace edm {
237244
// a valid cfi, in some cases the description can be so pathological
238245
// that it is impossible to write a cfi that will pass validation.
239246
void writeCfi(std::ostream& os,
240-
bool optional,
247+
Modifier modifier,
241248
bool& startWithComma,
242249
int indentation,
243250
CfiOptions& options,
244251
bool& wroteSomething) const {
245-
writeCfi_(os, optional, startWithComma, indentation, options, wroteSomething);
252+
writeCfi_(os, modifier, startWithComma, indentation, options, wroteSomething);
246253
}
247254

248255
// Print out the description in human readable format
249-
void print(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const;
256+
void print(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const;
250257

251258
bool hasNestedContent() const { return hasNestedContent_(); }
252259

@@ -346,16 +353,16 @@ namespace edm {
346353
std::set<ParameterTypes>& parameterTypes,
347354
std::set<ParameterTypes>& wildcardTypes) const = 0;
348355

349-
virtual void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const = 0;
356+
virtual void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const = 0;
350357

351358
virtual void writeCfi_(std::ostream& os,
352-
bool optional,
359+
Modifier modifier,
353360
bool& startWithComma,
354361
int indentation,
355362
CfiOptions&,
356363
bool& wroteSomething) const = 0;
357364

358-
virtual void print_(std::ostream&, bool /*optional*/, bool /*writeToCfi*/, DocFormatHelper&) const {}
365+
virtual void print_(std::ostream&, Modifier /*modifier*/, bool /*writeToCfi*/, DocFormatHelper&) const {}
359366

360367
virtual bool hasNestedContent_() const { return false; }
361368

0 commit comments

Comments
 (0)