CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
46  clone() const {
47  return new AllowedLabelsDescription(*this);
48  }
49 
50  void
52  printNestedContent_(std::ostream & os,
53  bool optional,
54  DocFormatHelper & dfh) {
55 
56  printNestedContentBase_(os, optional, dfh);
57 
58  int indentation = dfh.indentation();
59  if (dfh.parent() != DocFormatHelper::TOP) {
61  }
62 
63  std::stringstream ss;
64  ss << dfh.section() << "." << dfh.counter() << ".1";
65  std::string newSection = ss.str();
66 
67  if (dfh.brief()) {
69  }
70  else {
71  dfh.indent2(os);
72  }
73  os << "see Section " << newSection << "\n";
74  if (!dfh.brief()) os << "\n";
75 
76  printSpaces(os, indentation);
77  os << "Section " << newSection
78  << " PSet description:\n";
79  if (!dfh.brief()) os << "\n";
80 
81  DocFormatHelper new_dfh(dfh);
82  new_dfh.setSection(newSection);
85 
86  psetDesc_->print(os, new_dfh);
87  }
88 
89  void
91  validateAllowedLabel_(std::string const& allowedLabel,
92  ParameterSet & pset,
93  std::set<std::string> & validatedLabels) const {
94  if (pset.existsAs<ParameterSet>(allowedLabel, isTracked())) {
95  validatedLabels.insert(allowedLabel);
96  if (psetDesc_) {
97  ParameterSet * containedPSet = pset.getPSetForUpdate(allowedLabel);
98  psetDesc_->validate(*containedPSet);
99  }
100  }
101  }
102 
103 // -----------------------------------------------------------------------
104 
107  bool isTracked) :
108  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
109  psetDesc_()
110  {
111  }
112 
115  bool isTracked) :
116  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
117  psetDesc_()
118  {
119  }
120 
124  bool isTracked) :
125  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
126  psetDesc_(new ParameterSetDescription(value))
127  {
128  }
129 
133  bool isTracked) :
134  AllowedLabelsDescriptionBase(label, k_VPSet, isTracked),
135  psetDesc_(new ParameterSetDescription(value))
136  {
137  }
138 
141  clone() const {
142  return new AllowedLabelsDescription(*this);
143  }
144 
145  void
147  printNestedContent_(std::ostream & os,
148  bool optional,
149  DocFormatHelper & dfh) {
150 
151  printNestedContentBase_(os, optional, dfh);
152 
153  int indentation = dfh.indentation();
154  if (dfh.parent() != DocFormatHelper::TOP) {
155  indentation -= DocFormatHelper::offsetSectionContent();
156  }
157 
158  std::stringstream ss;
159  ss << dfh.section() << "." << dfh.counter() << ".1";
160  std::string newSection = ss.str();
161 
162  if (dfh.brief()) {
163  printSpaces(os, indentation + DocFormatHelper::offsetSectionContent());
164  }
165  else {
166  dfh.indent2(os);
167  }
168  os << "see Section " << newSection << "\n";
169  if (!dfh.brief()) os << "\n";
170 
171  printSpaces(os, indentation);
172  os << "Section " << newSection
173  << " PSet description used to validate all elements of VPSet's:\n";
174  if (!dfh.brief()) os << "\n";
175 
176  DocFormatHelper new_dfh(dfh);
177  new_dfh.setSection(newSection);
178  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
180 
181  psetDesc_->print(os, new_dfh);
182  }
183 
184  void
186  validateAllowedLabel_(std::string const& allowedLabel,
187  ParameterSet & pset,
188  std::set<std::string> & validatedLabels) const {
189  if (pset.existsAs<std::vector<ParameterSet> >(allowedLabel, isTracked())) {
190  validatedLabels.insert(allowedLabel);
191 
192  if (psetDesc_) {
193  VParameterSetEntry * vpsetEntry = pset.getPSetVectorForUpdate(allowedLabel);
194  assert(vpsetEntry);
195  for (unsigned i = 0; i < vpsetEntry->size(); ++i) {
196  psetDesc_->validate(vpsetEntry->psetInVector(i));
197  }
198  }
199  }
200  }
201 }
void printNestedContentBase_(std::ostream &os, bool optional, DocFormatHelper &dfh)
int i
Definition: DBlmapReader.cc:9
virtual ParameterDescriptionNode * clone() const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:184
virtual void validateAllowedLabel_(std::string const &allowedLabel, ParameterSet &pset, std::set< std::string > &validatedLabels) const
DescriptionParent parent() const
int indentation() const
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
static int offsetSectionContent()
void indent2(std::ostream &os) const
static void printSpaces(std::ostream &os, int n)
AllowedLabelsDescription(std::string const &label, bool isTracked)
std::vector< ParameterSet >::size_type size() const
tuple clone
Definition: statics.py:58
ParameterSet & psetInVector(int i)
virtual void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh)
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