CMS 3D CMS Logo

AllowedLabelsDescriptionBase.cc
Go to the documentation of this file.
1 
7 
8 #include <iomanip>
9 #include <ostream>
10 
11 namespace edm {
12 
14 
16  ParameterTypes iType,
17  bool isTracked)
18  : parameterHoldingLabels_(label, std::vector<std::string>(), isTracked), type_(iType), isTracked_(isTracked) {}
19 
21  : parameterHoldingLabels_(label, std::vector<std::string>(), isTracked), type_(iType), isTracked_(isTracked) {}
22 
23  void AllowedLabelsDescriptionBase::checkAndGetLabelsAndTypes_(std::set<std::string>& usedLabels,
24  std::set<ParameterTypes>& parameterTypes,
25  std::set<ParameterTypes>& wildcardTypes) const {
26  parameterHoldingLabels_.checkAndGetLabelsAndTypes(usedLabels, parameterTypes, wildcardTypes);
27  }
28 
30  std::set<std::string>& validatedLabels,
31  bool optional) const {
32  parameterHoldingLabels_.validate(pset, validatedLabels, optional);
34  std::vector<std::string> allowedLabels;
35  if (isTracked()) {
36  allowedLabels = pset.getParameter<std::vector<std::string> >(parameterHoldingLabels_.label());
37  } else {
38  allowedLabels = pset.getUntrackedParameter<std::vector<std::string> >(parameterHoldingLabels_.label());
39  }
40  for_all(allowedLabels,
42  this,
43  std::placeholders::_1,
44  std::ref(pset),
45  std::ref(validatedLabels)));
46  }
47  }
48 
50  std::ostream& os, bool optional, bool& startWithComma, int indentation, bool& wroteSomething) const {
51  parameterHoldingLabels_.writeCfi(os, optional, startWithComma, indentation, wroteSomething);
52  }
53 
54  void AllowedLabelsDescriptionBase::print_(std::ostream& os,
55  bool optional,
56  bool writeToCfi,
57  DocFormatHelper& dfh) const {
58  if (dfh.pass() == 1) {
59  dfh.indent(os);
60  os << parameterHoldingLabels_.label() << " (list of allowed labels)";
61 
62  if (dfh.brief()) {
63  if (optional)
64  os << " optional";
65 
66  if (!writeToCfi)
67  os << " (do not write to cfi)";
68 
69  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
70  }
71  // not brief
72  else {
73  os << "\n";
74  dfh.indent2(os);
75 
76  if (optional)
77  os << "optional";
78  if (!writeToCfi)
79  os << " (do not write to cfi)";
80  if (optional || !writeToCfi) {
81  os << "\n";
82  dfh.indent2(os);
83  }
84 
85  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
86 
87  if (!comment().empty()) {
89  }
90  os << "\n";
91  }
92  }
93  }
94 
96 
99  if (!dfh.brief())
100  os << "\n";
101  }
102 
104  bool optional,
105  DocFormatHelper& dfh) const {
106  int indentation = dfh.indentation();
107  if (dfh.parent() != DocFormatHelper::TOP) {
109  }
110 
112  os << "Section " << dfh.section() << "." << dfh.counter() << " " << parameterHoldingLabels_.label()
113  << " - allowed labels description\n";
115  os << "The following parameter contains a list of parameter labels\n";
117  os << "which are allowed to be in the PSet\n";
118  if (!dfh.brief())
119  os << "\n";
120 
121  DocFormatHelper new_dfh(dfh);
122  new_dfh.init();
123  new_dfh.setPass(1);
124  parameterHoldingLabels_.print(os, optional, true, new_dfh);
125  dfh.indent(os);
126  os << "type of allowed parameters:";
127  if (dfh.brief())
128  os << " ";
129  else {
130  os << "\n";
131  dfh.indent2(os);
132  }
133  if (!isTracked())
134  os << "untracked ";
135  os << parameterTypeEnumToString(type()) << "\n";
136  }
137 
140  }
141 
143 
145  return exists(pset) ? 1 : 0;
146  }
147 } // namespace edm
void writeCfi(std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const
std::string const & label() const
int startColumn2() const
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
void print(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const
void writeCfi_(std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const override
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
void print_(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
std::string parameterTypeEnumToString(ParameterTypes iType)
AllowedLabelsDescriptionBase(std::string const &label, ParameterTypes iType, bool isTracked)
size_t commentWidth() const
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
void indent2(std::ostream &os) const
char const * label
bool exists_(ParameterSet const &pset) const override
int howManyXORSubNodesExist_(ParameterSet const &pset) const override
virtual void validateAllowedLabel_(std::string const &allowedLabel, ParameterSet &pset, std::set< std::string > &validatedLabels) const =0
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
void printNestedContentBase_(std::ostream &os, bool optional, DocFormatHelper &dfh) const
static int offsetSectionContent()
optional
Definition: Types.py:198
void setPass(int value)
std::string const & section() const
static void printSpaces(std::ostream &os, int n)
bool partiallyExists_(ParameterSet const &pset) const override
void checkAndGetLabelsAndTypes(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
std::string const & comment() const
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
bool exists(ParameterSet const &pset) const
HLT enums.
void checkAndGetLabelsAndTypes_(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
void indent(std::ostream &os) const
void validate(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
DescriptionParent parent() const