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 &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
 
virtual void printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh)
 
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 12 of file ParameterSwitchBase.cc.

12 { }

Member Function Documentation

bool edm::ParameterSwitchBase::hasNestedContent_ ( )
protectedvirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 158 of file ParameterSwitchBase.cc.

158  {
159  return true;
160  }
int edm::ParameterSwitchBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 268 of file ParameterSwitchBase.cc.

References edm::ParameterDescriptionNode::exists().

268  {
269  return exists(pset) ? 1 : 0;
270  }
tuple pset
Definition: CrabTask.py:85
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 26 of file ParameterSwitchBase.cc.

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

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

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

References edm::ParameterDescriptionNode::exists().

262  {
263  return exists(pset);
264  }
tuple pset
Definition: CrabTask.py:85
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(), 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  }
91  else {
92  dfh.setAtLeast2(typeString.size() + 10U);
93  }
94  dfh.setAtLeast3(8U);
95  }
96  if (dfh.pass() == 1) {
97 
98  dfh.indent(os);
99 
100  if (dfh.brief()) {
101 
102  std::stringstream ss;
103  ss << switchLabel << " (switch)";
104  std::ios::fmtflags oldFlags = os.flags();
105  os << std::left << std::setw(dfh.column1()) << ss.str();
106  os << " ";
107 
108  os << std::setw(dfh.column2());
109  if (isTracked) {
110  os << typeString;
111  }
112  else {
113  std::stringstream ss1;
114  ss1 << "untracked " << typeString;
115  os << ss1.str();
116  }
117 
118  os << " " << std::setw(dfh.column3());
119  if (optional) os << "optional";
120  else os << "";
121 
122  if (!writeToCfi) os << " (do not write to cfi)";
123 
124  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
125  os.flags(oldFlags);
126  }
127  // not brief
128  else {
129 
130  os << switchLabel << " (switch)\n";
131 
132  dfh.indent2(os);
133  os << "type: ";
134  if (!isTracked) os << "untracked ";
135  os << typeString << " ";
136 
137  if (optional) os << "optional";
138 
139  if (!writeToCfi) os << " (do not write to cfi)";
140  os << "\n";
141 
142  dfh.indent2(os);
143  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
144 
145  if (!comment().empty()) {
147  comment(),
148  dfh.startColumn2(),
149  dfh.commentWidth());
150  }
151  os << "\n";
152  }
153  }
154  }
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 199 of file ParameterSwitchBase.cc.

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

Referenced by printCaseT().

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

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

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

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

246  {
247  if (dfh.pass() == 0) {
248  p.second->print(os, false, true, dfh);
249  }
250  if (dfh.pass() == 1) {
251  dfh.indent(os);
252  os << "if " << switchLabel << " = \"" << p.first << "\"\n";
253  p.second->print(os, false, true, dfh);
254  }
255  if (dfh.pass() == 2) {
256  p.second->printNestedContent(os, false, dfh);
257  }
258  }
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 L1TEmulatorMonitor_cff::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 164 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(), and edm::DocFormatHelper::TOP.

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

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

Definition at line 16 of file ParameterSwitchBase.cc.

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

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

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

Definition at line 62 of file ParameterSwitchBase.cc.

References edm::hlt::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