1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
|
#include "FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/Algorithms.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/ParameterSet/interface/DocFormatHelper.h"
#include <iomanip>
#include <ostream>
namespace edm {
AllowedLabelsDescriptionBase::~AllowedLabelsDescriptionBase() {}
AllowedLabelsDescriptionBase::AllowedLabelsDescriptionBase(std::string const& label,
ParameterTypes iType,
bool isTracked)
: parameterHoldingLabels_(label, std::vector<std::string>(), isTracked), type_(iType), isTracked_(isTracked) {}
AllowedLabelsDescriptionBase::AllowedLabelsDescriptionBase(char const* label, ParameterTypes iType, bool isTracked)
: parameterHoldingLabels_(label, std::vector<std::string>(), isTracked), type_(iType), isTracked_(isTracked) {}
void AllowedLabelsDescriptionBase::checkAndGetLabelsAndTypes_(std::set<std::string>& usedLabels,
std::set<ParameterTypes>& parameterTypes,
std::set<ParameterTypes>& wildcardTypes) const {
parameterHoldingLabels_.checkAndGetLabelsAndTypes(usedLabels, parameterTypes, wildcardTypes);
}
void AllowedLabelsDescriptionBase::validate_(ParameterSet& pset,
std::set<std::string>& validatedLabels,
Modifier modifier) const {
parameterHoldingLabels_.validate(pset, validatedLabels, modifier);
if (parameterHoldingLabels_.exists(pset)) {
std::vector<std::string> allowedLabels;
if (isTracked()) {
allowedLabels = pset.getParameter<std::vector<std::string> >(parameterHoldingLabels_.label());
} else {
allowedLabels = pset.getUntrackedParameter<std::vector<std::string> >(parameterHoldingLabels_.label());
}
for_all(allowedLabels,
std::bind(&AllowedLabelsDescriptionBase::validateAllowedLabel_,
this,
std::placeholders::_1,
std::ref(pset),
std::ref(validatedLabels)));
}
}
void AllowedLabelsDescriptionBase::writeCfi_(std::ostream& os,
Modifier modifier,
bool& startWithComma,
int indentation,
CfiOptions& options,
bool& wroteSomething) const {
parameterHoldingLabels_.writeCfi(os, modifier, startWithComma, indentation, options, wroteSomething);
}
void AllowedLabelsDescriptionBase::print_(std::ostream& os,
Modifier modifier,
bool writeToCfi,
DocFormatHelper& dfh) const {
if (dfh.pass() == 1) {
dfh.indent(os);
os << parameterHoldingLabels_.label() << " (list of allowed labels)";
if (dfh.brief()) {
if (modifier == Modifier::kOptional)
os << " optional";
if (modifier == Modifier::kObsolete)
os << " obsolete";
if (!writeToCfi)
os << " (do not write to cfi)";
os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
}
// not brief
else {
os << "\n";
dfh.indent2(os);
if (modifier == Modifier::kOptional)
os << "optional";
if (modifier == Modifier::kObsolete)
os << "obsolete";
if (!writeToCfi)
os << " (do not write to cfi)";
if (modifier == Modifier::kOptional || !writeToCfi) {
os << "\n";
dfh.indent2(os);
}
os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
if (!comment().empty()) {
DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
}
os << "\n";
}
}
}
bool AllowedLabelsDescriptionBase::hasNestedContent_() const { return true; }
void AllowedLabelsDescriptionBase::printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const {
printNestedContentBase_(os, optional, dfh);
if (!dfh.brief())
os << "\n";
}
void AllowedLabelsDescriptionBase::printNestedContentBase_(std::ostream& os,
bool optional,
DocFormatHelper& dfh) const {
int indentation = dfh.indentation();
if (dfh.parent() != DocFormatHelper::TOP) {
indentation -= DocFormatHelper::offsetSectionContent();
}
printSpaces(os, indentation);
os << "Section " << dfh.section() << "." << dfh.counter() << " " << parameterHoldingLabels_.label()
<< " - allowed labels description\n";
printSpaces(os, indentation);
os << "The following parameter contains a list of parameter labels\n";
printSpaces(os, indentation);
os << "which are allowed to be in the PSet\n";
if (!dfh.brief())
os << "\n";
DocFormatHelper new_dfh(dfh);
new_dfh.init();
new_dfh.setPass(1);
parameterHoldingLabels_.print(os, modifierIsOptional(optional), true, new_dfh);
dfh.indent(os);
os << "type of allowed parameters:";
if (dfh.brief())
os << " ";
else {
os << "\n";
dfh.indent2(os);
}
if (!isTracked())
os << "untracked ";
os << parameterTypeEnumToString(type()) << "\n";
}
bool AllowedLabelsDescriptionBase::exists_(ParameterSet const& pset) const {
return parameterHoldingLabels_.exists(pset);
}
bool AllowedLabelsDescriptionBase::partiallyExists_(ParameterSet const& pset) const { return exists(pset); }
int AllowedLabelsDescriptionBase::howManyXORSubNodesExist_(ParameterSet const& pset) const {
return exists(pset) ? 1 : 0;
}
} // namespace edm
|