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  bool optional,
51  bool& startWithComma,
52  int indentation,
54  bool& wroteSomething) const {
55  parameterHoldingLabels_.writeCfi(os, optional, startWithComma, indentation, options, wroteSomething);
56  }
57 
59  bool optional,
60  bool writeToCfi,
61  DocFormatHelper& dfh) const {
62  if (dfh.pass() == 1) {
63  dfh.indent(os);
64  os << parameterHoldingLabels_.label() << " (list of allowed labels)";
65 
66  if (dfh.brief()) {
67  if (optional)
68  os << " optional";
69 
70  if (!writeToCfi)
71  os << " (do not write to cfi)";
72 
73  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
74  }
75  // not brief
76  else {
77  os << "\n";
78  dfh.indent2(os);
79 
80  if (optional)
81  os << "optional";
82  if (!writeToCfi)
83  os << " (do not write to cfi)";
84  if (optional || !writeToCfi) {
85  os << "\n";
86  dfh.indent2(os);
87  }
88 
89  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
90 
91  if (!comment().empty()) {
93  }
94  os << "\n";
95  }
96  }
97  }
98 
100 
103  if (!dfh.brief())
104  os << "\n";
105  }
106 
108  bool optional,
109  DocFormatHelper& dfh) const {
110  int indentation = dfh.indentation();
111  if (dfh.parent() != DocFormatHelper::TOP) {
113  }
114 
116  os << "Section " << dfh.section() << "." << dfh.counter() << " " << parameterHoldingLabels_.label()
117  << " - allowed labels description\n";
119  os << "The following parameter contains a list of parameter labels\n";
121  os << "which are allowed to be in the PSet\n";
122  if (!dfh.brief())
123  os << "\n";
124 
125  DocFormatHelper new_dfh(dfh);
126  new_dfh.init();
127  new_dfh.setPass(1);
128  parameterHoldingLabels_.print(os, optional, true, new_dfh);
129  dfh.indent(os);
130  os << "type of allowed parameters:";
131  if (dfh.brief())
132  os << " ";
133  else {
134  os << "\n";
135  dfh.indent2(os);
136  }
137  if (!isTracked())
138  os << "untracked ";
139  os << parameterTypeEnumToString(type()) << "\n";
140  }
141 
144  }
145 
147 
149  return exists(pset) ? 1 : 0;
150  }
151 } // namespace edm
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 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:245
void writeCfi_(std::ostream &os, bool optional, bool &startWithComma, int indentation, CfiOptions &, bool &wroteSomething) const override
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 writeCfi(std::ostream &os, bool optional, bool &startWithComma, int indentation, CfiOptions &options, bool &wroteSomething) const
void indent(std::ostream &os) const
void validate(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
cfi::CfiOptions CfiOptions
DescriptionParent parent() const