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
edm::DocFormatHelper::TOP
Definition: DocFormatHelper.h:17
edm::DocFormatHelper::init
void init()
Definition: DocFormatHelper.cc:113
edm::ParameterDescriptionNode::print
void print(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const
Definition: ParameterDescriptionNode.cc:110
edm::ParameterDescriptionNode::exists
bool exists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:134
edm::ParameterTypes
ParameterTypes
Definition: ParameterDescriptionNode.h:33
edm::ParameterDescriptionBase::label
std::string const & label() const
Definition: ParameterDescriptionBase.h:37
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::AllowedLabelsDescriptionBase::writeCfi_
void writeCfi_(std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const override
Definition: AllowedLabelsDescriptionBase.cc:49
edm::AllowedLabelsDescriptionBase::validate_
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
Definition: AllowedLabelsDescriptionBase.cc:29
Types.optional
optional
Definition: Types.py:167
Algorithms.h
AllowedLabelsDescriptionBase.h
edm::AllowedLabelsDescriptionBase::~AllowedLabelsDescriptionBase
~AllowedLabelsDescriptionBase() override
Definition: AllowedLabelsDescriptionBase.cc:13
edm::DocFormatHelper::parent
DescriptionParent parent() const
Definition: DocFormatHelper.h:71
edm::ParameterDescriptionNode::validate
void validate(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
Definition: ParameterDescriptionNode.h:102
edm::AllowedLabelsDescriptionBase::AllowedLabelsDescriptionBase
AllowedLabelsDescriptionBase(std::string const &label, ParameterTypes iType, bool isTracked)
Definition: AllowedLabelsDescriptionBase.cc:15
edm::parameterTypeEnumToString
std::string parameterTypeEnumToString(ParameterTypes iType)
Definition: ParameterDescriptionNode.cc:64
edm::AllowedLabelsDescriptionBase::exists_
bool exists_(ParameterSet const &pset) const override
Definition: AllowedLabelsDescriptionBase.cc:138
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
edm::AllowedLabelsDescriptionBase::print_
void print_(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
Definition: AllowedLabelsDescriptionBase.cc:54
edm::AllowedLabelsDescriptionBase::howManyXORSubNodesExist_
int howManyXORSubNodesExist_(ParameterSet const &pset) const override
Definition: AllowedLabelsDescriptionBase.cc:144
edm::DocFormatHelper
Definition: DocFormatHelper.h:15
edm::AllowedLabelsDescriptionBase::printNestedContentBase_
void printNestedContentBase_(std::ostream &os, bool optional, DocFormatHelper &dfh) const
Definition: AllowedLabelsDescriptionBase.cc:103
edm::AllowedLabelsDescriptionBase::isTracked
bool isTracked() const
Definition: AllowedLabelsDescriptionBase.h:21
edm::AllowedLabelsDescriptionBase::printNestedContent_
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
Definition: AllowedLabelsDescriptionBase.cc:97
ParameterSetDescription.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::DocFormatHelper::startColumn2
int startColumn2() const
Definition: DocFormatHelper.h:37
edm::AllowedLabelsDescriptionBase::partiallyExists_
bool partiallyExists_(ParameterSet const &pset) const override
Definition: AllowedLabelsDescriptionBase.cc:142
edm::AllowedLabelsDescriptionBase::validateAllowedLabel_
virtual void validateAllowedLabel_(std::string const &allowedLabel, ParameterSet &pset, std::set< std::string > &validatedLabels) const =0
edm::ParameterSet
Definition: ParameterSet.h:36
edm::DocFormatHelper::brief
bool brief() const
Definition: DocFormatHelper.h:34
edm::DocFormatHelper::wrapAndPrintText
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
Definition: DocFormatHelper.cc:97
edm::AllowedLabelsDescriptionBase::type
ParameterTypes type() const
Definition: AllowedLabelsDescriptionBase.h:20
edm::ParameterDescriptionNode::checkAndGetLabelsAndTypes
void checkAndGetLabelsAndTypes(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
Definition: ParameterDescriptionNode.h:207
edm::DocFormatHelper::indent
void indent(std::ostream &os) const
Definition: DocFormatHelper.cc:133
edm::AllowedLabelsDescriptionBase::parameterHoldingLabels_
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
Definition: AllowedLabelsDescriptionBase.h:56
edm::DocFormatHelper::commentWidth
size_t commentWidth() const
Definition: DocFormatHelper.cc:123
edm::DocFormatHelper::indent2
void indent2(std::ostream &os) const
Definition: DocFormatHelper.cc:139
edm::ParameterDescriptionNode::printSpaces
static void printSpaces(std::ostream &os, int n)
Definition: ParameterDescriptionNode.cc:124
edm::DocFormatHelper::counter
int counter() const
Definition: DocFormatHelper.h:66
std
Definition: JetResolutionObject.h:76
DocFormatHelper.h
edm::DocFormatHelper::offsetSectionContent
static int offsetSectionContent()
Definition: DocFormatHelper.h:83
edm::DocFormatHelper::pass
int pass() const
Definition: DocFormatHelper.h:46
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::DocFormatHelper::setPass
void setPass(int value)
Definition: DocFormatHelper.h:47
edm::ParameterDescriptionNode::comment
std::string const & comment() const
Definition: ParameterDescriptionNode.h:92
edm::DocFormatHelper::section
std::string const & section() const
Definition: DocFormatHelper.h:43
ParameterSet.h
edm::AllowedLabelsDescriptionBase::hasNestedContent_
bool hasNestedContent_() const override
Definition: AllowedLabelsDescriptionBase.cc:95
label
const char * label
Definition: PFTauDecayModeTools.cc:11
edm::AllowedLabelsDescriptionBase::checkAndGetLabelsAndTypes_
void checkAndGetLabelsAndTypes_(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
Definition: AllowedLabelsDescriptionBase.cc:23
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::ParameterDescriptionNode::writeCfi
void writeCfi(std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const
Definition: ParameterDescriptionNode.h:116
edm::DocFormatHelper::indentation
int indentation() const
Definition: DocFormatHelper.h:36