CMS 3D CMS Logo

AllowedLabelsDescription.cc
Go to the documentation of this file.
1 
5 
6 #include <cassert>
7 
8 namespace edm {
9 
12  bool isTracked) :
13  AllowedLabelsDescriptionBase(label, k_PSet, isTracked),
14  psetDesc_()
15  {
16  }
17 
20  bool isTracked) :
21  AllowedLabelsDescriptionBase(label, k_PSet, isTracked),
22  psetDesc_()
23  {
24  }
25 
29  bool isTracked) :
30  AllowedLabelsDescriptionBase(label, k_PSet, isTracked),
31  psetDesc_(new ParameterSetDescription(value))
32  {
33  }
34 
38  bool isTracked) :
39  AllowedLabelsDescriptionBase(label, k_PSet, isTracked),
40  psetDesc_(new ParameterSetDescription(value))
41  {
42  }
43 
45  {
46  }
47 
50  clone() const {
51  return new AllowedLabelsDescription(*this);
52  }
53 
54  void
56  printNestedContent_(std::ostream & os,
57  bool optional,
58  DocFormatHelper & dfh) const {
59 
60  printNestedContentBase_(os, optional, dfh);
61 
62  int indentation = dfh.indentation();
63  if (dfh.parent() != DocFormatHelper::TOP) {
65  }
66 
67  std::stringstream ss;
68  ss << dfh.section() << "." << dfh.counter() << ".1";
69  std::string newSection = ss.str();
70 
71  if (dfh.brief()) {
73  }
74  else {
75  dfh.indent2(os);
76  }
77  os << "see Section " << newSection << "\n";
78  if (!dfh.brief()) os << "\n";
79 
80  printSpaces(os, indentation);
81  os << "Section " << newSection
82  << " PSet description:\n";
83  if (!dfh.brief()) os << "\n";
84 
85  DocFormatHelper new_dfh(dfh);
86  new_dfh.setSection(newSection);
89 
90  psetDesc_->print(os, new_dfh);
91  }
92 
93  void
95  validateAllowedLabel_(std::string const& allowedLabel,
97  std::set<std::string> & validatedLabels) const {
98  if (pset.existsAs<ParameterSet>(allowedLabel, isTracked())) {
99  validatedLabels.insert(allowedLabel);
100  if (psetDesc_) {
101  ParameterSet * containedPSet = pset.getPSetForUpdate(allowedLabel);
102  psetDesc_->validate(*containedPSet);
103  }
104  }
105  }
106 
107 // -----------------------------------------------------------------------
108 
111  bool isTracked) :
112  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
113  psetDesc_()
114  {
115  }
116 
119  bool isTracked) :
120  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
121  psetDesc_()
122  {
123  }
124 
128  bool isTracked) :
129  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
130  psetDesc_(new ParameterSetDescription(value))
131  {
132  }
133 
137  bool isTracked) :
138  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
139  psetDesc_(new ParameterSetDescription(value))
140  {
141  }
142 
144  {
145  }
146 
149  clone() const {
150  return new AllowedLabelsDescription(*this);
151  }
152 
153  void
155  printNestedContent_(std::ostream & os,
156  bool optional,
157  DocFormatHelper & dfh) const {
158 
159  printNestedContentBase_(os, optional, dfh);
160 
161  int indentation = dfh.indentation();
162  if (dfh.parent() != DocFormatHelper::TOP) {
163  indentation -= DocFormatHelper::offsetSectionContent();
164  }
165 
166  std::stringstream ss;
167  ss << dfh.section() << "." << dfh.counter() << ".1";
168  std::string newSection = ss.str();
169 
170  if (dfh.brief()) {
172  }
173  else {
174  dfh.indent2(os);
175  }
176  os << "see Section " << newSection << "\n";
177  if (!dfh.brief()) os << "\n";
178 
179  printSpaces(os, indentation);
180  os << "Section " << newSection
181  << " PSet description used to validate all elements of VPSet's:\n";
182  if (!dfh.brief()) os << "\n";
183 
184  DocFormatHelper new_dfh(dfh);
185  new_dfh.setSection(newSection);
186  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
188 
189  psetDesc_->print(os, new_dfh);
190  }
191 
192  void
195  ParameterSet & pset,
196  std::set<std::string> & validatedLabels) const {
197  if (pset.existsAs<std::vector<ParameterSet> >(allowedLabel, isTracked())) {
198  validatedLabels.insert(allowedLabel);
199 
200  if (psetDesc_) {
201  VParameterSetEntry * vpsetEntry = pset.getPSetVectorForUpdate(allowedLabel);
202  assert(vpsetEntry);
203  for (unsigned i = 0; i < vpsetEntry->size(); ++i) {
204  psetDesc_->validate(vpsetEntry->psetInVector(i));
205  }
206  }
207  }
208  }
209 }
ParameterDescriptionNode * clone() const override
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
DescriptionParent parent() const
int indentation() const
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
void validateAllowedLabel_(std::string const &allowedLabel, ParameterSet &pset, std::set< std::string > &validatedLabels) const override
static int offsetSectionContent()
Definition: value.py:1
void indent2(std::ostream &os) const
static void printSpaces(std::ostream &os, int n)
void printNestedContentBase_(std::ostream &os, bool optional, DocFormatHelper &dfh) const
AllowedLabelsDescription(std::string const &label, bool isTracked)
HLT enums.
std::vector< ParameterSet >::size_type size() const
ParameterSet & psetInVector(int i)
void setSection(std::string const &value)
void setParent(DescriptionParent value)
void setIndentation(int value)
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::string const & section() const