CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual ~ParameterSwitchBase ()
 
- 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 ()
 
int howManyXORSubNodesExist (ParameterSet const &pset) const
 
bool partiallyExists (ParameterSet const &pset) const
 
void print (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
 
void printNestedContent (std::ostream &os, bool optional, DocFormatHelper &dfh)
 
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 &startWithComma, int indentation, bool &wroteSomething) const
 
virtual ~ParameterDescriptionNode ()
 

Protected Member Functions

virtual bool hasNestedContent_ ()
 
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)
 
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 &)
 
virtual void printNestedContent_ (std::ostream &, bool, DocFormatHelper &)
 
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const =0
 
virtual void writeCfi_ (std::ostream &os, 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

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

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

edm::ParameterSwitchBase::~ParameterSwitchBase ( )
virtual

Definition at line 13 of file ParameterSwitchBase.cc.

13 { }

Member Function Documentation

bool edm::ParameterSwitchBase::hasNestedContent_ ( )
protectedvirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 155 of file ParameterSwitchBase.cc.

155  {
156  return true;
157  }
int edm::ParameterSwitchBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 265 of file ParameterSwitchBase.cc.

References edm::ParameterDescriptionNode::exists().

265  {
266  return exists(pset) ? 1 : 0;
267  }
bool exists(ParameterSet const &pset) const
void edm::ParameterSwitchBase::insertAndCheckLabels ( std::string const &  switchLabel,
std::set< std::string > &  usedLabels,
std::set< std::string > &  labels 
) const
protected

Definition at line 27 of file ParameterSwitchBase.cc.

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

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

29  {
30 
31  std::pair<std::set<std::string>::iterator,bool> status = labels.insert(switchLabel);
32  if(status.second == false) {
34  << "The label used for the switch parameter in a ParameterSetDescription\n"
35  << "must be different from the labels used in the associated cases. The following\n"
36  << "duplicate label was found: \"" << switchLabel << "\"\n";
37  }
38  usedLabels.insert(labels.begin(), labels.end());
39  }
tuple status
Definition: ntuplemaker.py:245
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 43 of file ParameterSwitchBase.cc.

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

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

47  {
48 
49  if(caseWildcardTypes.find(switchType) != caseWildcardTypes.end()) {
51  << "The type used for the switch parameter in a ParameterSetDescription\n"
52  << "must be different from the types used for wildcards in the associated cases. The following\n"
53  << "duplicate type was found: \"" << parameterTypeEnumToString(switchType) << "\"\n";
54  }
55  parameterTypes.insert(switchType);
56  parameterTypes.insert(caseParameterTypes.begin(), caseParameterTypes.end());
57  wildcardTypes.insert(caseWildcardTypes.begin(), caseWildcardTypes.end());
58  }
std::string parameterTypeEnumToString(ParameterTypes iType)
bool edm::ParameterSwitchBase::partiallyExists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 259 of file ParameterSwitchBase.cc.

References edm::ParameterDescriptionNode::exists().

259  {
260  return exists(pset);
261  }
bool exists(ParameterSet const &pset) const
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 78 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(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setAtLeast1(), edm::DocFormatHelper::setAtLeast2(), edm::DocFormatHelper::setAtLeast3(), contentValuesCheck::ss, edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

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

84  {
85 
86  if(dfh.pass() == 0) {
87  dfh.setAtLeast1(switchLabel.size() + 9U);
88  if(isTracked) {
89  dfh.setAtLeast2(typeString.size());
90  } else {
91  dfh.setAtLeast2(typeString.size() + 10U);
92  }
93  dfh.setAtLeast3(8U);
94  }
95  if(dfh.pass() == 1) {
96 
97  dfh.indent(os);
98 
99  if(dfh.brief()) {
100 
101  std::stringstream ss;
102  ss << switchLabel << " (switch)";
103  std::ios::fmtflags oldFlags = os.flags();
104  os << std::left << std::setw(dfh.column1()) << ss.str();
105  os << " ";
106 
107  os << std::setw(dfh.column2());
108  if(isTracked) {
109  os << typeString;
110  } else {
111  std::stringstream ss1;
112  ss1 << "untracked " << typeString;
113  os << ss1.str();
114  }
115 
116  os << " " << std::setw(dfh.column3());
117  if(optional) os << "optional";
118  else os << "";
119 
120  if(!writeToCfi) os << " (do not write to cfi)";
121 
122  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
123  os.flags(oldFlags);
124  } else {
125  // not brief
126 
127  os << switchLabel << " (switch)\n";
128 
129  dfh.indent2(os);
130  os << "type: ";
131  if(!isTracked) os << "untracked ";
132  os << typeString << " ";
133 
134  if(optional) os << "optional";
135 
136  if(!writeToCfi) os << " (do not write to cfi)";
137  os << "\n";
138 
139  dfh.indent2(os);
140  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
141 
142  if(!comment().empty()) {
144  comment(),
145  dfh.startColumn2(),
146  dfh.commentWidth());
147  }
148  os << "\n";
149  }
150  }
151  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
std::string const & comment() const
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 196 of file ParameterSwitchBase.cc.

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

Referenced by printCaseT().

200  {
201  if(dfh.pass() == 0) {
202  p.second->print(os, false, true, dfh);
203  }
204  if(dfh.pass() == 1) {
205  dfh.indent(os);
206  os << "if " << switchLabel << " = ";
207  if(p.first) os << "True";
208  else os << "False";
209  os << "\n";
210  p.second->print(os, false, true, dfh);
211  }
212  if(dfh.pass() == 2) {
213  p.second->printNestedContent(os, false, dfh);
214  }
215  }
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 219 of file ParameterSwitchBase.cc.

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

223  {
224  if(dfh.pass() == 0) {
225  p.second->print(os, false, true, dfh);
226  }
227  if(dfh.pass() == 1) {
228  dfh.indent(os);
229  os << "if " << switchLabel << " = " << p.first << "\n";
230  p.second->print(os, false, true, dfh);
231  }
232  if(dfh.pass() == 2) {
233  p.second->printNestedContent(os, false, dfh);
234  }
235  }
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 239 of file ParameterSwitchBase.cc.

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

243  {
244  if(dfh.pass() == 0) {
245  p.second->print(os, false, true, dfh);
246  }
247  if(dfh.pass() == 1) {
248  dfh.indent(os);
249  os << "if " << switchLabel << " = \"" << p.first << "\"\n";
250  p.second->print(os, false, true, dfh);
251  }
252  if(dfh.pass() == 2) {
253  p.second->printNestedContent(os, false, dfh);
254  }
255  }
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 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)
void edm::ParameterSwitchBase::printNestedContentBase ( std::ostream &  os,
DocFormatHelper dfh,
DocFormatHelper new_dfh,
std::string const &  switchLabel 
)
protected

Definition at line 161 of file ParameterSwitchBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), 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_().

164  {
165 
166  int indentation = dfh.indentation();
167  if(dfh.parent() != DocFormatHelper::TOP) {
168  indentation -= DocFormatHelper::offsetSectionContent();
169  }
170 
171  std::stringstream ss;
172  ss << dfh.section() << "." << dfh.counter();
173  std::string newSection = ss.str();
174 
175  printSpaces(os, indentation);
176  os << "Section " << newSection
177  << " " << switchLabel << " (switch):\n";
178 
179  if(!dfh.brief()) {
180  printSpaces(os, indentation);
181  os << "The value of \"" << switchLabel << "\" controls which other parameters\n";
182  printSpaces(os, indentation);
183  os << "are required or allowed to be in the PSet.\n";
184  }
185  if(!dfh.brief()) os << "\n";
186 
187  new_dfh.init();
188  new_dfh.setSection(newSection);
189  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
190  new_dfh.setParent(DocFormatHelper::OTHER);
191  }
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
void edm::ParameterSwitchBase::throwDuplicateCaseValues ( std::string const &  switchLabel) const
protected

Definition at line 17 of file ParameterSwitchBase.cc.

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

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

17  {
19  << "When adding a ParameterSwitch to a ParameterSetDescription the values\n"
20  << "associated with the different cases must be unique. Duplicate\n"
21  << "values were found for the switch with label: \"" << switchLabel
22  << "\"\n";
23  }
void edm::ParameterSwitchBase::throwNoCaseForDefault ( std::string const &  switchLabel) const
protected

Definition at line 62 of file ParameterSwitchBase.cc.

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

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

62  {
64  << "The default value used for the switch parameter in a ParameterSetDescription\n"
65  << "must match the value used to select one of the associated cases. This is not\n"
66  << "true for the switch named \"" << switchLabel << "\"\n";
67  }
void edm::ParameterSwitchBase::throwNoCaseForSwitchValue ( std::string const &  message) const
protected