CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Member Functions | Static Private Member Functions
edm::ParameterSwitchBase Class Reference

#include <ParameterSwitchBase.h>

Inheritance diagram for edm::ParameterSwitchBase:
edm::ParameterDescriptionNode edm::ParameterSwitch< T >

Public Member Functions

 ~ParameterSwitchBase () override
 
- Public Member Functions inherited from edm::ParameterDescriptionNode
void checkAndGetLabelsAndTypes (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
virtual ParameterDescriptionNodeclone () const =0
 
std::string const & comment () const
 
bool exists (ParameterSet const &pset) const
 
bool hasNestedContent () const
 
int howManyXORSubNodesExist (ParameterSet const &pset) const
 
 ParameterDescriptionNode ()
 
 ParameterDescriptionNode (Comment const &iComment)
 
bool partiallyExists (ParameterSet const &pset) const
 
void print (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const
 
void printNestedContent (std::ostream &os, bool optional, DocFormatHelper &dfh) const
 
void setComment (std::string const &value)
 
void setComment (char const *value)
 
void validate (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
 
void writeCfi (std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const
 
virtual ~ParameterDescriptionNode ()
 

Protected Member Functions

bool hasNestedContent_ () const override
 
void insertAndCheckLabels (std::string const &switchLabel, std::set< std::string > &usedLabels, std::set< std::string > &labels) const
 
void insertAndCheckTypes (ParameterTypes switchType, std::set< ParameterTypes > const &caseParameterTypes, std::set< ParameterTypes > const &caseWildcardTypes, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
void printBase (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh, std::string const &switchLabel, bool isTracked, std::string const &typeString) const
 
void printNestedContentBase (std::ostream &os, DocFormatHelper &dfh, DocFormatHelper &new_dfh, std::string const &switchLabel) const
 
void throwDuplicateCaseValues (std::string const &switchLabel) const
 
void throwNoCaseForDefault (std::string const &switchLabel) const
 
void throwNoCaseForSwitchValue (std::string const &message) const
 
- Protected Member Functions inherited from edm::ParameterDescriptionNode
virtual void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const =0
 
virtual bool exists_ (ParameterSet const &pset) const =0
 
virtual void print_ (std::ostream &, bool, bool, DocFormatHelper &) const
 
virtual void printNestedContent_ (std::ostream &, bool, DocFormatHelper &) const
 
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const =0
 
virtual void writeCfi_ (std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const =0
 

Static Protected Member Functions

template<typename T >
static void printCaseT (std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &p, std::ostream &os, bool optional, DocFormatHelper &dfh, std::string const &switchLabel)
 

Private Member Functions

int howManyXORSubNodesExist_ (ParameterSet const &pset) const override
 
bool partiallyExists_ (ParameterSet const &pset) const override
 

Static Private Member Functions

static void printCase (std::pair< bool, edm::value_ptr< ParameterDescriptionNode > > const &p, std::ostream &os, bool optional, DocFormatHelper &dfh, std::string const &switchLabel)
 
static void printCase (std::pair< int, edm::value_ptr< ParameterDescriptionNode > > const &p, std::ostream &os, bool optional, DocFormatHelper &dfh, std::string const &switchLabel)
 
static void printCase (std::pair< std::string, edm::value_ptr< ParameterDescriptionNode > > const &p, std::ostream &os, bool optional, DocFormatHelper &dfh, std::string const &switchLabel)
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::ParameterDescriptionNode
static void printSpaces (std::ostream &os, int n)
 
- Protected Attributes inherited from edm::ParameterDescriptionNode
std::string comment_
 

Detailed Description

Definition at line 16 of file ParameterSwitchBase.h.

Constructor & Destructor Documentation

◆ ~ParameterSwitchBase()

edm::ParameterSwitchBase::~ParameterSwitchBase ( )
override

Definition at line 13 of file ParameterSwitchBase.cc.

13 {}

Member Function Documentation

◆ hasNestedContent_()

bool edm::ParameterSwitchBase::hasNestedContent_ ( ) const
overrideprotectedvirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 136 of file ParameterSwitchBase.cc.

136 { return true; }

◆ howManyXORSubNodesExist_()

int edm::ParameterSwitchBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 230 of file ParameterSwitchBase.cc.

References edm::ParameterDescriptionNode::exists(), and muonDTDigis_cfi::pset.

230 { return exists(pset) ? 1 : 0; }
bool exists(ParameterSet const &pset) const

◆ insertAndCheckLabels()

void edm::ParameterSwitchBase::insertAndCheckLabels ( std::string const &  switchLabel,
std::set< std::string > &  usedLabels,
std::set< std::string > &  labels 
) const
protected

Definition at line 21 of file ParameterSwitchBase.cc.

References Exception, SummaryClient_cfi::labels, edm::errors::LogicError, and mps_update::status.

Referenced by edm::ParameterSwitch< T >::checkAndGetLabelsAndTypes_().

23  {
24  std::pair<std::set<std::string>::iterator, bool> status = labels.insert(switchLabel);
25  if (status.second == false) {
27  << "The label used for the switch parameter in a ParameterSetDescription\n"
28  << "must be different from the labels used in the associated cases. The following\n"
29  << "duplicate label was found: \"" << switchLabel << "\"\n";
30  }
31  usedLabels.insert(labels.begin(), labels.end());
32  }

◆ insertAndCheckTypes()

void edm::ParameterSwitchBase::insertAndCheckTypes ( ParameterTypes  switchType,
std::set< ParameterTypes > const &  caseParameterTypes,
std::set< ParameterTypes > const &  caseWildcardTypes,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) const
protected

Definition at line 34 of file ParameterSwitchBase.cc.

References Exception, edm::errors::LogicError, and edm::parameterTypeEnumToString().

Referenced by edm::ParameterSwitch< T >::checkAndGetLabelsAndTypes_().

38  {
39  if (caseWildcardTypes.find(switchType) != caseWildcardTypes.end()) {
41  << "The type used for the switch parameter in a ParameterSetDescription\n"
42  << "must be different from the types used for wildcards in the associated cases. The following\n"
43  << "duplicate type was found: \"" << parameterTypeEnumToString(switchType) << "\"\n";
44  }
45  parameterTypes.insert(switchType);
46  parameterTypes.insert(caseParameterTypes.begin(), caseParameterTypes.end());
47  wildcardTypes.insert(caseWildcardTypes.begin(), caseWildcardTypes.end());
48  }
std::string parameterTypeEnumToString(ParameterTypes iType)

◆ partiallyExists_()

bool edm::ParameterSwitchBase::partiallyExists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 228 of file ParameterSwitchBase.cc.

References edm::ParameterDescriptionNode::exists(), and muonDTDigis_cfi::pset.

228 { return exists(pset); }
bool exists(ParameterSet const &pset) const

◆ printBase()

void edm::ParameterSwitchBase::printBase ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh,
std::string const &  switchLabel,
bool  isTracked,
std::string const &  typeString 
) const
protected

Definition at line 61 of file ParameterSwitchBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::column1(), edm::DocFormatHelper::column2(), edm::DocFormatHelper::column3(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), Types::optional, edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setAtLeast1(), edm::DocFormatHelper::setAtLeast2(), edm::DocFormatHelper::setAtLeast3(), contentValuesCheck::ss, edm::DocFormatHelper::startColumn2(), mitigatedMETSequence_cff::U, and edm::DocFormatHelper::wrapAndPrintText().

Referenced by edm::ParameterSwitch< T >::print_().

67  {
68  if (dfh.pass() == 0) {
69  dfh.setAtLeast1(switchLabel.size() + 9U);
70  if (isTracked) {
71  dfh.setAtLeast2(typeString.size());
72  } else {
73  dfh.setAtLeast2(typeString.size() + 10U);
74  }
75  dfh.setAtLeast3(8U);
76  }
77  if (dfh.pass() == 1) {
78  dfh.indent(os);
79 
80  if (dfh.brief()) {
81  std::stringstream ss;
82  ss << switchLabel << " (switch)";
83  std::ios::fmtflags oldFlags = os.flags();
84  os << std::left << std::setw(dfh.column1()) << ss.str();
85  os << " ";
86 
87  os << std::setw(dfh.column2());
88  if (isTracked) {
89  os << typeString;
90  } else {
91  std::stringstream ss1;
92  ss1 << "untracked " << typeString;
93  os << ss1.str();
94  }
95 
96  os << " " << std::setw(dfh.column3());
97  if (optional)
98  os << "optional";
99  else
100  os << "";
101 
102  if (!writeToCfi)
103  os << " (do not write to cfi)";
104 
105  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
106  os.flags(oldFlags);
107  } else {
108  // not brief
109 
110  os << switchLabel << " (switch)\n";
111 
112  dfh.indent2(os);
113  os << "type: ";
114  if (!isTracked)
115  os << "untracked ";
116  os << typeString << " ";
117 
118  if (optional)
119  os << "optional";
120 
121  if (!writeToCfi)
122  os << " (do not write to cfi)";
123  os << "\n";
124 
125  dfh.indent2(os);
126  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
127 
128  if (!comment().empty()) {
129  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
130  }
131  os << "\n";
132  }
133  }
134  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
optional
Definition: Types.py:198
std::string const & comment() const

◆ printCase() [1/3]

void edm::ParameterSwitchBase::printCase ( std::pair< bool, edm::value_ptr< ParameterDescriptionNode > > const &  p,
std::ostream &  os,
bool  optional,
DocFormatHelper dfh,
std::string const &  switchLabel 
)
staticprivate

Definition at line 169 of file ParameterSwitchBase.cc.

References edm::DocFormatHelper::indent(), AlCaHLTBitMon_ParallelJobs::p, and edm::DocFormatHelper::pass().

Referenced by printCaseT().

173  {
174  if (dfh.pass() == 0) {
175  p.second->print(os, false, true, dfh);
176  }
177  if (dfh.pass() == 1) {
178  dfh.indent(os);
179  os << "if " << switchLabel << " = ";
180  if (p.first)
181  os << "True";
182  else
183  os << "False";
184  os << "\n";
185  p.second->print(os, false, true, dfh);
186  }
187  if (dfh.pass() == 2) {
188  p.second->printNestedContent(os, false, dfh);
189  }
190  }

◆ printCase() [2/3]

void edm::ParameterSwitchBase::printCase ( std::pair< int, edm::value_ptr< ParameterDescriptionNode > > const &  p,
std::ostream &  os,
bool  optional,
DocFormatHelper dfh,
std::string const &  switchLabel 
)
staticprivate

Definition at line 192 of file ParameterSwitchBase.cc.

References edm::DocFormatHelper::indent(), AlCaHLTBitMon_ParallelJobs::p, and edm::DocFormatHelper::pass().

196  {
197  if (dfh.pass() == 0) {
198  p.second->print(os, false, true, dfh);
199  }
200  if (dfh.pass() == 1) {
201  dfh.indent(os);
202  os << "if " << switchLabel << " = " << p.first << "\n";
203  p.second->print(os, false, true, dfh);
204  }
205  if (dfh.pass() == 2) {
206  p.second->printNestedContent(os, false, dfh);
207  }
208  }

◆ printCase() [3/3]

void edm::ParameterSwitchBase::printCase ( std::pair< std::string, edm::value_ptr< ParameterDescriptionNode > > const &  p,
std::ostream &  os,
bool  optional,
DocFormatHelper dfh,
std::string const &  switchLabel 
)
staticprivate

Definition at line 210 of file ParameterSwitchBase.cc.

References edm::DocFormatHelper::indent(), AlCaHLTBitMon_ParallelJobs::p, and edm::DocFormatHelper::pass().

214  {
215  if (dfh.pass() == 0) {
216  p.second->print(os, false, true, dfh);
217  }
218  if (dfh.pass() == 1) {
219  dfh.indent(os);
220  os << "if " << switchLabel << " = \"" << p.first << "\"\n";
221  p.second->print(os, false, true, dfh);
222  }
223  if (dfh.pass() == 2) {
224  p.second->printNestedContent(os, false, dfh);
225  }
226  }

◆ printCaseT()

template<typename T >
static void edm::ParameterSwitchBase::printCaseT ( std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &  p,
std::ostream &  os,
bool  optional,
DocFormatHelper dfh,
std::string const &  switchLabel 
)
inlinestaticprotected

Definition at line 53 of file ParameterSwitchBase.h.

References Types::optional, AlCaHLTBitMon_ParallelJobs::p, and printCase().

57  {
58  ParameterSwitchBase::printCase(p, os, optional, dfh, switchLabel);
59  }
static void printCase(std::pair< bool, edm::value_ptr< ParameterDescriptionNode > > const &p, std::ostream &os, bool optional, DocFormatHelper &dfh, std::string const &switchLabel)
optional
Definition: Types.py:198

◆ printNestedContentBase()

void edm::ParameterSwitchBase::printNestedContentBase ( std::ostream &  os,
DocFormatHelper dfh,
DocFormatHelper new_dfh,
std::string const &  switchLabel 
) const
protected

Definition at line 138 of file ParameterSwitchBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), printContent_cfi::indentation, edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::OTHER, edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setParent(), edm::DocFormatHelper::setSection(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and edm::DocFormatHelper::TOP.

Referenced by edm::ParameterSwitch< T >::printNestedContent_().

141  {
142  int indentation = dfh.indentation();
143  if (dfh.parent() != DocFormatHelper::TOP) {
145  }
146 
147  std::stringstream ss;
148  ss << dfh.section() << "." << dfh.counter();
149  std::string newSection = ss.str();
150 
152  os << "Section " << newSection << " " << switchLabel << " (switch):\n";
153 
154  if (!dfh.brief()) {
156  os << "The value of \"" << switchLabel << "\" controls which other parameters\n";
158  os << "are required or allowed to be in the PSet.\n";
159  }
160  if (!dfh.brief())
161  os << "\n";
162 
163  new_dfh.init();
164  new_dfh.setSection(newSection);
165  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
166  new_dfh.setParent(DocFormatHelper::OTHER);
167  }
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)

◆ throwDuplicateCaseValues()

void edm::ParameterSwitchBase::throwDuplicateCaseValues ( std::string const &  switchLabel) const
protected

Definition at line 15 of file ParameterSwitchBase.cc.

References Exception, and edm::errors::LogicError.

Referenced by edm::ParameterSwitch< T >::ParameterSwitch().

15  {
16  throw Exception(errors::LogicError) << "When adding a ParameterSwitch to a ParameterSetDescription the values\n"
17  << "associated with the different cases must be unique. Duplicate\n"
18  << "values were found for the switch with label: \"" << switchLabel << "\"\n";
19  }

◆ throwNoCaseForDefault()

void edm::ParameterSwitchBase::throwNoCaseForDefault ( std::string const &  switchLabel) const
protected

Definition at line 50 of file ParameterSwitchBase.cc.

References Exception, and edm::errors::LogicError.

Referenced by edm::ParameterSwitch< T >::checkAndGetLabelsAndTypes_().

50  {
52  << "The default value used for the switch parameter in a ParameterSetDescription\n"
53  << "must match the value used to select one of the associated cases. This is not\n"
54  << "true for the switch named \"" << switchLabel << "\"\n";
55  }

◆ throwNoCaseForSwitchValue()

void edm::ParameterSwitchBase::throwNoCaseForSwitchValue ( std::string const &  message) const
protected

Definition at line 57 of file ParameterSwitchBase.cc.

References edm::errors::Configuration, and Exception.

Referenced by edm::ParameterSwitch< T >::validate_().

57  {
58  throw Exception(errors::Configuration) << message;
59  }