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);
33  if (parameterHoldingLabels_.exists(pset)) {
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& startWithComma,
51  int indentation,
52  bool& wroteSomething) const {
53  parameterHoldingLabels_.writeCfi(os, startWithComma, indentation, wroteSomething);
54  }
55 
56  void AllowedLabelsDescriptionBase::print_(std::ostream& os,
57  bool optional,
58  bool writeToCfi,
59  DocFormatHelper& dfh) const {
60  if (dfh.pass() == 1) {
61  dfh.indent(os);
62  os << parameterHoldingLabels_.label() << " (list of allowed labels)";
63 
64  if (dfh.brief()) {
65  if (optional)
66  os << " optional";
67 
68  if (!writeToCfi)
69  os << " (do not write to cfi)";
70 
71  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
72  }
73  // not brief
74  else {
75  os << "\n";
76  dfh.indent2(os);
77 
78  if (optional)
79  os << "optional";
80  if (!writeToCfi)
81  os << " (do not write to cfi)";
82  if (optional || !writeToCfi) {
83  os << "\n";
84  dfh.indent2(os);
85  }
86 
87  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
88 
89  if (!comment().empty()) {
91  }
92  os << "\n";
93  }
94  }
95  }
96 
98 
99  void AllowedLabelsDescriptionBase::printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const {
100  printNestedContentBase_(os, optional, dfh);
101  if (!dfh.brief())
102  os << "\n";
103  }
104 
106  bool optional,
107  DocFormatHelper& dfh) const {
108  int indentation = dfh.indentation();
109  if (dfh.parent() != DocFormatHelper::TOP) {
110  indentation -= DocFormatHelper::offsetSectionContent();
111  }
112 
113  printSpaces(os, indentation);
114  os << "Section " << dfh.section() << "." << dfh.counter() << " " << parameterHoldingLabels_.label()
115  << " - allowed labels description\n";
116  printSpaces(os, indentation);
117  os << "The following parameter contains a list of parameter labels\n";
118  printSpaces(os, indentation);
119  os << "which are allowed to be in the PSet\n";
120  if (!dfh.brief())
121  os << "\n";
122 
123  DocFormatHelper new_dfh(dfh);
124  new_dfh.init();
125  new_dfh.setPass(1);
126  parameterHoldingLabels_.print(os, optional, true, new_dfh);
127  dfh.indent(os);
128  os << "type of allowed parameters:";
129  if (dfh.brief())
130  os << " ";
131  else {
132  os << "\n";
133  dfh.indent2(os);
134  }
135  if (!isTracked())
136  os << "untracked ";
137  os << parameterTypeEnumToString(type()) << "\n";
138  }
139 
141  return parameterHoldingLabels_.exists(pset);
142  }
143 
145 
147  return exists(pset) ? 1 : 0;
148  }
149 } // namespace edm
bool exists_(ParameterSet const &pset) const override
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
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 validate(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
void writeCfi_(std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const override
int startColumn2() const
std::string parameterTypeEnumToString(ParameterTypes iType)
AllowedLabelsDescriptionBase(std::string const &label, ParameterTypes iType, bool isTracked)
DescriptionParent parent() const
bool partiallyExists_(ParameterSet const &pset) const override
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
char const * label
int indentation() const
std::string const & comment() const
void print(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const
static int offsetSectionContent()
void indent2(std::ostream &os) const
void setPass(int value)
int howManyXORSubNodesExist_(ParameterSet const &pset) const override
static void printSpaces(std::ostream &os, int n)
bool exists(ParameterSet const &pset) const
void printNestedContentBase_(std::ostream &os, bool optional, DocFormatHelper &dfh) const
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
HLT enums.
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
void checkAndGetLabelsAndTypes(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
void print_(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
void indent(std::ostream &os) const
void checkAndGetLabelsAndTypes_(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
void writeCfi(std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const
size_t commentWidth() const
std::string const & label() const
std::string const & section() const