CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
edm::ParameterSwitch< T > Class Template Reference

#include <ParameterSwitch.h>

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

Public Types

typedef std::map< T, edm::value_ptr< ParameterDescriptionNode > > CaseMap
 
typedef std::map< T, edm::value_ptr< ParameterDescriptionNode > >::const_iterator CaseMapConstIter
 

Public Member Functions

ParameterDescriptionNodeclone () const override
 
 ParameterSwitch (ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
 
- Public Member Functions inherited from edm::ParameterSwitchBase
 ~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
 
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 (char const *value)
 
void setComment (std::string 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 ()
 

Private Member Functions

void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
 
bool exists_ (ParameterSet const &pset) const override
 
void print_ (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
 
void printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh) const override
 
void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
 
void writeCfi_ (std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const override
 

Static Private Member Functions

static void checkCaseLabels (std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &thePair, std::set< std::string > &labels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes)
 

Private Attributes

CaseMap cases_
 
ParameterDescription< Tswitch_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::ParameterDescriptionNode
static void printSpaces (std::ostream &os, int n)
 
- Protected Member Functions inherited from edm::ParameterSwitchBase
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
 
- Static Protected Member Functions inherited from edm::ParameterSwitchBase
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)
 
- Protected Attributes inherited from edm::ParameterDescriptionNode
std::string comment_
 

Detailed Description

template<class T>
class edm::ParameterSwitch< T >

Definition at line 25 of file ParameterSwitch.h.

Member Typedef Documentation

◆ CaseMap

template<class T >
typedef std::map<T, edm::value_ptr<ParameterDescriptionNode> > edm::ParameterSwitch< T >::CaseMap

Definition at line 27 of file ParameterSwitch.h.

◆ CaseMapConstIter

template<class T >
typedef std::map<T, edm::value_ptr<ParameterDescriptionNode> >::const_iterator edm::ParameterSwitch< T >::CaseMapConstIter

Definition at line 28 of file ParameterSwitch.h.

Constructor & Destructor Documentation

◆ ParameterSwitch()

template<class T >
edm::ParameterSwitch< T >::ParameterSwitch ( ParameterDescription< T > const &  switchParameter,
std::unique_ptr< ParameterDescriptionCases< T > >  cases 
)
inline

Definition at line 30 of file ParameterSwitch.h.

32  : switch_(switchParameter), cases_(*cases->caseMap()) {
33  if (cases->duplicateCaseValues()) {
34  throwDuplicateCaseValues(switchParameter.label());
35  }
36  }

References edm::ParameterDescriptionBase::label(), and edm::ParameterSwitchBase::throwDuplicateCaseValues().

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

Member Function Documentation

◆ checkAndGetLabelsAndTypes_()

template<class T >
void edm::ParameterSwitch< T >::checkAndGetLabelsAndTypes_ ( std::set< std::string > &  usedLabels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) const
inlineoverrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 41 of file ParameterSwitch.h.

43  {
44  std::set<std::string> caseLabels;
45  std::set<ParameterTypes> caseParameterTypes;
46  std::set<ParameterTypes> caseWildcardTypes;
49  std::placeholders::_1,
50  std::ref(caseLabels),
51  std::ref(caseParameterTypes),
52  std::ref(caseWildcardTypes)));
53 
54  insertAndCheckLabels(switch_.label(), usedLabels, caseLabels);
55 
56  insertAndCheckTypes(switch_.type(), caseParameterTypes, caseWildcardTypes, parameterTypes, wildcardTypes);
57 
58  if (cases_.find(switch_.getDefaultValue()) == cases_.end()) {
60  }
61  }

References edm::ParameterSwitch< T >::cases_, edm::ParameterSwitch< T >::checkCaseLabels(), edm::for_all(), edm::ParameterSwitchBase::insertAndCheckLabels(), edm::ParameterSwitchBase::insertAndCheckTypes(), edm::ParameterSwitch< T >::switch_, and edm::ParameterSwitchBase::throwNoCaseForDefault().

◆ checkCaseLabels()

template<class T >
static void edm::ParameterSwitch< T >::checkCaseLabels ( std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &  thePair,
std::set< std::string > &  labels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
)
inlinestaticprivate

Definition at line 151 of file ParameterSwitch.h.

154  {
155  thePair.second->checkAndGetLabelsAndTypes(labels, parameterTypes, wildcardTypes);
156  }

References SummaryClient_cfi::labels.

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

◆ clone()

template<class T >
ParameterDescriptionNode* edm::ParameterSwitch< T >::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 38 of file ParameterSwitch.h.

38 { return new ParameterSwitch(*this); }

References edm::ParameterSwitch< T >::ParameterSwitch().

◆ exists_()

template<class T >
bool edm::ParameterSwitch< T >::exists_ ( ParameterSet const &  pset) const
inlineoverrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 149 of file ParameterSwitch.h.

149 { return switch_.exists(pset); }

References muonDTDigis_cfi::pset, and edm::ParameterSwitch< T >::switch_.

◆ print_()

template<class T >
void edm::ParameterSwitch< T >::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) const
inlineoverrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 99 of file ParameterSwitch.h.

99  {
100  printBase(os,
101  optional,
102  writeToCfi,
103  dfh,
104  switch_.label(),
105  switch_.isTracked(),
107  }

References Types::optional, edm::parameterTypeEnumToString(), edm::ParameterSwitchBase::printBase(), and edm::ParameterSwitch< T >::switch_.

◆ printNestedContent_()

template<class T >
void edm::ParameterSwitch< T >::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) const
inlineoverrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 109 of file ParameterSwitch.h.

109  {
110  DocFormatHelper new_dfh(dfh);
111  printNestedContentBase(os, dfh, new_dfh, switch_.label());
112 
113  switch_.print(os, optional, true, new_dfh);
114  for_all(cases_,
115  std::bind(&ParameterSwitchBase::printCaseT<T>,
116  std::placeholders::_1,
117  std::ref(os),
118  optional,
119  std::ref(new_dfh),
120  std::cref(switch_.label())));
121 
122  new_dfh.setPass(1);
123  new_dfh.setCounter(0);
124 
125  new_dfh.indent(os);
126  os << "switch:\n";
127  switch_.print(os, optional, true, new_dfh);
128  for_all(cases_,
129  std::bind(&ParameterSwitchBase::printCaseT<T>,
130  std::placeholders::_1,
131  std::ref(os),
132  optional,
133  std::ref(new_dfh),
134  std::cref(switch_.label())));
135 
136  new_dfh.setPass(2);
137  new_dfh.setCounter(0);
138 
139  switch_.printNestedContent(os, optional, new_dfh);
140  for_all(cases_,
141  std::bind(&ParameterSwitchBase::printCaseT<T>,
142  std::placeholders::_1,
143  std::ref(os),
144  optional,
145  std::ref(new_dfh),
146  std::cref(switch_.label())));
147  }

References edm::ParameterSwitch< T >::cases_, edm::for_all(), edm::DocFormatHelper::indent(), Types::optional, edm::ParameterSwitchBase::printNestedContentBase(), edm::DocFormatHelper::setCounter(), edm::DocFormatHelper::setPass(), and edm::ParameterSwitch< T >::switch_.

◆ validate_()

template<class T >
void edm::ParameterSwitch< T >::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
inlineoverrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 63 of file ParameterSwitch.h.

63  {
64  switch_.validate(pset, validatedLabels, optional);
65  if (switch_.exists(pset)) {
66  T switchValue;
67  if (switch_.isTracked()) {
68  switchValue = pset.getParameter<T>(switch_.label());
69  } else {
70  switchValue = pset.getUntrackedParameter<T>(switch_.label());
71  }
72  typename CaseMap::const_iterator selectedCase = cases_.find(switchValue);
73  if (selectedCase != cases_.end()) {
74  selectedCase->second->validate(pset, validatedLabels, false);
75  } else {
76  std::stringstream ss;
77  ss << "The switch parameter with label \"" << switch_.label() << "\" has been assigned an illegal value.\n"
78  << "The value from the configuration is \"" << switchValue << "\".\n"
79  << "The allowed values are:\n";
80 
81  for (CaseMapConstIter iter = cases_.begin(), iEnd = cases_.end(); iter != iEnd; ++iter) {
82  ss << " " << iter->first << "\n";
83  }
85  }
86  }
87  }

References edm::ParameterSwitch< T >::cases_, Types::optional, muonDTDigis_cfi::pset, contentValuesCheck::ss, edm::ParameterSwitch< T >::switch_, and edm::ParameterSwitchBase::throwNoCaseForSwitchValue().

◆ writeCfi_()

template<class T >
void edm::ParameterSwitch< T >::writeCfi_ ( std::ostream &  os,
bool  optional,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
inlineoverrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 89 of file ParameterSwitch.h.

90  {
91  switch_.writeCfi(os, optional, startWithComma, indentation, wroteSomething);
92 
93  typename CaseMap::const_iterator selectedCase = cases_.find(switch_.getDefaultValue());
94  if (selectedCase != cases_.end()) {
95  selectedCase->second->writeCfi(os, optional, startWithComma, indentation, wroteSomething);
96  }
97  }

References edm::ParameterSwitch< T >::cases_, printContent_cfi::indentation, Types::optional, and edm::ParameterSwitch< T >::switch_.

Member Data Documentation

◆ cases_

template<class T >
CaseMap edm::ParameterSwitch< T >::cases_
private

◆ switch_

template<class T >
ParameterDescription<T> edm::ParameterSwitch< T >::switch_
private
edm::ParameterSwitchBase::throwNoCaseForSwitchValue
void throwNoCaseForSwitchValue(std::string const &message) const
Definition: ParameterSwitchBase.cc:57
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
edm::ParameterSwitch::CaseMapConstIter
std::map< T, edm::value_ptr< ParameterDescriptionNode > >::const_iterator CaseMapConstIter
Definition: ParameterSwitch.h:28
edm::ParameterSwitch::cases_
CaseMap cases_
Definition: ParameterSwitch.h:159
edm::ParameterSwitch::switch_
ParameterDescription< T > switch_
Definition: ParameterSwitch.h:158
Types.optional
optional
Definition: Types.py:198
edm::parameterTypeEnumToString
std::string parameterTypeEnumToString(ParameterTypes iType)
Definition: ParameterDescriptionNode.cc:64
edm::for_all
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::ParameterSwitch::ParameterSwitch
ParameterSwitch(ParameterDescription< T > const &switchParameter, std::unique_ptr< ParameterDescriptionCases< T > > cases)
Definition: ParameterSwitch.h:30
edm::ParameterSwitchBase::printNestedContentBase
void printNestedContentBase(std::ostream &os, DocFormatHelper &dfh, DocFormatHelper &new_dfh, std::string const &switchLabel) const
Definition: ParameterSwitchBase.cc:138
edm::ParameterSwitchBase::insertAndCheckLabels
void insertAndCheckLabels(std::string const &switchLabel, std::set< std::string > &usedLabels, std::set< std::string > &labels) const
Definition: ParameterSwitchBase.cc:21
edm::ParameterSwitchBase::throwDuplicateCaseValues
void throwDuplicateCaseValues(std::string const &switchLabel) const
Definition: ParameterSwitchBase.cc:15
edm::ParameterSwitch::checkCaseLabels
static void checkCaseLabels(std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &thePair, std::set< std::string > &labels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes)
Definition: ParameterSwitch.h:151
edm::ParameterSwitchBase::insertAndCheckTypes
void insertAndCheckTypes(ParameterTypes switchType, std::set< ParameterTypes > const &caseParameterTypes, std::set< ParameterTypes > const &caseWildcardTypes, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
Definition: ParameterSwitchBase.cc:34
edm::ParameterSwitchBase::printBase
void printBase(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh, std::string const &switchLabel, bool isTracked, std::string const &typeString) const
Definition: ParameterSwitchBase.cc:61
T
long double T
Definition: Basic3DVectorLD.h:48
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ParameterSwitchBase::throwNoCaseForDefault
void throwNoCaseForDefault(std::string const &switchLabel) const
Definition: ParameterSwitchBase.cc:50
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27