#include <ParameterSwitchBase.h>
Public Member Functions | |
virtual | ~ParameterSwitchBase () |
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 > ¶meterTypes, 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 |
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< std::string, 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) |
Definition at line 16 of file ParameterSwitchBase.h.
edm::ParameterSwitchBase::~ParameterSwitchBase | ( | ) | [virtual] |
Definition at line 13 of file ParameterSwitchBase.cc.
{ }
bool edm::ParameterSwitchBase::hasNestedContent_ | ( | ) | [protected, virtual] |
Reimplemented from edm::ParameterDescriptionNode.
Definition at line 155 of file ParameterSwitchBase.cc.
{ return true; }
int edm::ParameterSwitchBase::howManyXORSubNodesExist_ | ( | ParameterSet const & | pset | ) | const [private, virtual] |
Implements edm::ParameterDescriptionNode.
Definition at line 265 of file ParameterSwitchBase.cc.
References edm::ParameterDescriptionNode::exists().
{ return exists(pset) ? 1 : 0; }
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_().
{ std::pair<std::set<std::string>::iterator,bool> status = labels.insert(switchLabel); if(status.second == false) { throw Exception(errors::LogicError) << "The label used for the switch parameter in a ParameterSetDescription\n" << "must be different from the labels used in the associated cases. The following\n" << "duplicate label was found: \"" << switchLabel << "\"\n"; } usedLabels.insert(labels.begin(), labels.end()); }
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_().
{ if(caseWildcardTypes.find(switchType) != caseWildcardTypes.end()) { throw Exception(errors::LogicError) << "The type used for the switch parameter in a ParameterSetDescription\n" << "must be different from the types used for wildcards in the associated cases. The following\n" << "duplicate type was found: \"" << parameterTypeEnumToString(switchType) << "\"\n"; } parameterTypes.insert(switchType); parameterTypes.insert(caseParameterTypes.begin(), caseParameterTypes.end()); wildcardTypes.insert(caseWildcardTypes.begin(), caseWildcardTypes.end()); }
bool edm::ParameterSwitchBase::partiallyExists_ | ( | ParameterSet const & | pset | ) | const [private, virtual] |
Implements edm::ParameterDescriptionNode.
Definition at line 259 of file ParameterSwitchBase.cc.
References edm::ParameterDescriptionNode::exists().
{ return exists(pset); }
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_().
{ if(dfh.pass() == 0) { dfh.setAtLeast1(switchLabel.size() + 9U); if(isTracked) { dfh.setAtLeast2(typeString.size()); } else { dfh.setAtLeast2(typeString.size() + 10U); } dfh.setAtLeast3(8U); } if(dfh.pass() == 1) { dfh.indent(os); if(dfh.brief()) { std::stringstream ss; ss << switchLabel << " (switch)"; std::ios::fmtflags oldFlags = os.flags(); os << std::left << std::setw(dfh.column1()) << ss.str(); os << " "; os << std::setw(dfh.column2()); if(isTracked) { os << typeString; } else { std::stringstream ss1; ss1 << "untracked " << typeString; os << ss1.str(); } os << " " << std::setw(dfh.column3()); if(optional) os << "optional"; else os << ""; if(!writeToCfi) os << " (do not write to cfi)"; os << " see Section " << dfh.section() << "." << dfh.counter() << "\n"; os.flags(oldFlags); } else { // not brief os << switchLabel << " (switch)\n"; dfh.indent2(os); os << "type: "; if(!isTracked) os << "untracked "; os << typeString << " "; if(optional) os << "optional"; if(!writeToCfi) os << " (do not write to cfi)"; os << "\n"; dfh.indent2(os); os << "see Section " << dfh.section() << "." << dfh.counter() << "\n"; if(!comment().empty()) { DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth()); } os << "\n"; } } }
static void edm::ParameterSwitchBase::printCase | ( | std::pair< bool, edm::value_ptr< ParameterDescriptionNode > > const & | p, |
std::ostream & | os, | ||
bool | optional, | ||
DocFormatHelper & | dfh, | ||
std::string const & | switchLabel | ||
) | [static, private] |
Referenced by printCaseT().
static void edm::ParameterSwitchBase::printCase | ( | std::pair< int, edm::value_ptr< ParameterDescriptionNode > > const & | p, |
std::ostream & | os, | ||
bool | optional, | ||
DocFormatHelper & | dfh, | ||
std::string const & | switchLabel | ||
) | [static, private] |
static 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 | ||
) | [static, private] |
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 | ||
) | [inline, static, protected] |
Definition at line 53 of file ParameterSwitchBase.h.
References AlCaHLTBitMon_ParallelJobs::p, and printCase().
{ ParameterSwitchBase::printCase(p, os, optional, dfh, 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(), and pat::TOP.
Referenced by edm::ParameterSwitch< T >::printNestedContent_().
{ int indentation = dfh.indentation(); if(dfh.parent() != DocFormatHelper::TOP) { indentation -= DocFormatHelper::offsetSectionContent(); } std::stringstream ss; ss << dfh.section() << "." << dfh.counter(); std::string newSection = ss.str(); printSpaces(os, indentation); os << "Section " << newSection << " " << switchLabel << " (switch):\n"; if(!dfh.brief()) { printSpaces(os, indentation); os << "The value of \"" << switchLabel << "\" controls which other parameters\n"; printSpaces(os, indentation); os << "are required or allowed to be in the PSet.\n"; } if(!dfh.brief()) os << "\n"; new_dfh.init(); new_dfh.setSection(newSection); new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent()); new_dfh.setParent(DocFormatHelper::OTHER); }
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().
{ throw Exception(errors::LogicError) << "When adding a ParameterSwitch to a ParameterSetDescription the values\n" << "associated with the different cases must be unique. Duplicate\n" << "values were found for the switch with label: \"" << switchLabel << "\"\n"; }
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_().
{ throw Exception(errors::LogicError) << "The default value used for the switch parameter in a ParameterSetDescription\n" << "must match the value used to select one of the associated cases. This is not\n" << "true for the switch named \"" << switchLabel << "\"\n"; }
void edm::ParameterSwitchBase::throwNoCaseForSwitchValue | ( | std::string const & | message | ) | const [protected] |
Definition at line 71 of file ParameterSwitchBase.cc.
References edm::errors::Configuration, Exception, and python::rootplot::argparse::message.
Referenced by edm::ParameterSwitch< T >::validate_().
{ throw Exception(errors::Configuration) << message; }