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
|
#include "FWCore/ParameterSet/interface/AllowedLabelsDescription.h"
#include "FWCore/ParameterSet/interface/VParameterSetEntry.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include <cassert>
namespace edm {
AllowedLabelsDescription<ParameterSetDescription>::AllowedLabelsDescription(std::string const& label, bool isTracked)
: AllowedLabelsDescriptionBase(label, k_PSet, isTracked), psetDesc_() {}
AllowedLabelsDescription<ParameterSetDescription>::AllowedLabelsDescription(char const* label, bool isTracked)
: AllowedLabelsDescriptionBase(label, k_PSet, isTracked), psetDesc_() {}
AllowedLabelsDescription<ParameterSetDescription>::AllowedLabelsDescription(std::string const& label,
ParameterSetDescription const& value,
bool isTracked)
: AllowedLabelsDescriptionBase(label, k_PSet, isTracked), psetDesc_(new ParameterSetDescription(value)) {}
AllowedLabelsDescription<ParameterSetDescription>::AllowedLabelsDescription(char const* label,
ParameterSetDescription const& value,
bool isTracked)
: AllowedLabelsDescriptionBase(label, k_PSet, isTracked), psetDesc_(new ParameterSetDescription(value)) {}
AllowedLabelsDescription<ParameterSetDescription>::~AllowedLabelsDescription() {}
ParameterDescriptionNode* AllowedLabelsDescription<ParameterSetDescription>::clone() const {
return new AllowedLabelsDescription(*this);
}
void AllowedLabelsDescription<ParameterSetDescription>::printNestedContent_(std::ostream& os,
bool optional,
DocFormatHelper& dfh) const {
printNestedContentBase_(os, optional, dfh);
int indentation = dfh.indentation();
if (dfh.parent() != DocFormatHelper::TOP) {
indentation -= DocFormatHelper::offsetSectionContent();
}
std::stringstream ss;
ss << dfh.section() << "." << dfh.counter() << ".1";
std::string newSection = ss.str();
if (dfh.brief()) {
printSpaces(os, indentation + DocFormatHelper::offsetSectionContent());
} else {
dfh.indent2(os);
}
os << "see Section " << newSection << "\n";
if (!dfh.brief())
os << "\n";
printSpaces(os, indentation);
os << "Section " << newSection << " PSet description:\n";
if (!dfh.brief())
os << "\n";
DocFormatHelper new_dfh(dfh);
new_dfh.setSection(newSection);
new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
new_dfh.setParent(DocFormatHelper::OTHER);
psetDesc_->print(os, new_dfh);
}
void AllowedLabelsDescription<ParameterSetDescription>::validateAllowedLabel_(
std::string const& allowedLabel, ParameterSet& pset, std::set<std::string>& validatedLabels) const {
if (pset.existsAs<ParameterSet>(allowedLabel, isTracked())) {
validatedLabels.insert(allowedLabel);
if (psetDesc_) {
ParameterSet* containedPSet = pset.getPSetForUpdate(allowedLabel);
psetDesc_->validate(*containedPSet);
}
}
}
// -----------------------------------------------------------------------
AllowedLabelsDescription<std::vector<ParameterSet> >::AllowedLabelsDescription(std::string const& label,
bool isTracked)
: AllowedLabelsDescriptionBase(label, k_VPSet, isTracked), psetDesc_() {}
AllowedLabelsDescription<std::vector<ParameterSet> >::AllowedLabelsDescription(char const* label, bool isTracked)
: AllowedLabelsDescriptionBase(label, k_VPSet, isTracked), psetDesc_() {}
AllowedLabelsDescription<std::vector<ParameterSet> >::AllowedLabelsDescription(std::string const& label,
ParameterSetDescription const& value,
bool isTracked)
: AllowedLabelsDescriptionBase(label, k_VPSet, isTracked), psetDesc_(new ParameterSetDescription(value)) {}
AllowedLabelsDescription<std::vector<ParameterSet> >::AllowedLabelsDescription(char const* label,
ParameterSetDescription const& value,
bool isTracked)
: AllowedLabelsDescriptionBase(label, k_VPSet, isTracked), psetDesc_(new ParameterSetDescription(value)) {}
AllowedLabelsDescription<std::vector<ParameterSet> >::~AllowedLabelsDescription() {}
ParameterDescriptionNode* AllowedLabelsDescription<std::vector<ParameterSet> >::clone() const {
return new AllowedLabelsDescription(*this);
}
void AllowedLabelsDescription<std::vector<ParameterSet> >::printNestedContent_(std::ostream& os,
bool optional,
DocFormatHelper& dfh) const {
printNestedContentBase_(os, optional, dfh);
int indentation = dfh.indentation();
if (dfh.parent() != DocFormatHelper::TOP) {
indentation -= DocFormatHelper::offsetSectionContent();
}
std::stringstream ss;
ss << dfh.section() << "." << dfh.counter() << ".1";
std::string newSection = ss.str();
if (dfh.brief()) {
printSpaces(os, indentation + DocFormatHelper::offsetSectionContent());
} else {
dfh.indent2(os);
}
os << "see Section " << newSection << "\n";
if (!dfh.brief())
os << "\n";
printSpaces(os, indentation);
os << "Section " << newSection << " PSet description used to validate all elements of VPSet's:\n";
if (!dfh.brief())
os << "\n";
DocFormatHelper new_dfh(dfh);
new_dfh.setSection(newSection);
new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
new_dfh.setParent(DocFormatHelper::OTHER);
psetDesc_->print(os, new_dfh);
}
void AllowedLabelsDescription<std::vector<ParameterSet> >::validateAllowedLabel_(
std::string const& allowedLabel, ParameterSet& pset, std::set<std::string>& validatedLabels) const {
if (pset.existsAs<std::vector<ParameterSet> >(allowedLabel, isTracked())) {
validatedLabels.insert(allowedLabel);
if (psetDesc_) {
VParameterSetEntry* vpsetEntry = pset.getPSetVectorForUpdate(allowedLabel);
assert(vpsetEntry);
for (unsigned i = 0; i < vpsetEntry->size(); ++i) {
psetDesc_->validate(vpsetEntry->psetInVector(i));
}
}
}
}
} // namespace edm
|