CMS 3D CMS Logo

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

virtual ParameterDescriptionNodeclone () const
 
 ParameterSwitch (ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
 
- Public Member Functions inherited from edm::ParameterSwitchBase
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
 
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 ()
 

Private Member Functions

virtual void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
virtual bool exists_ (ParameterSet const &pset) const
 
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
 
virtual void writeCfi_ (std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const
 

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
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
 
- 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 27 of file ParameterSwitch.h.

Member Typedef Documentation

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

Definition at line 30 of file ParameterSwitch.h.

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

Definition at line 31 of file ParameterSwitch.h.

Constructor & Destructor Documentation

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

Definition at line 33 of file ParameterSwitch.h.

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

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

34  :
35  switch_(switchParameter),
36  cases_(*cases->caseMap())
37  {
38  if (cases->duplicateCaseValues()) {
39  throwDuplicateCaseValues(switchParameter.label());
40  }
41  }
void throwDuplicateCaseValues(std::string const &switchLabel) const
ParameterDescription< T > switch_

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 49 of file ParameterSwitch.h.

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().

51  {
52 
53  std::set<std::string> caseLabels;
54  std::set<ParameterTypes> caseParameterTypes;
55  std::set<ParameterTypes> caseWildcardTypes;
57  _1,
58  boost::ref(caseLabels),
59  boost::ref(caseParameterTypes),
60  boost::ref(caseWildcardTypes)));
61 
63  usedLabels,
64  caseLabels);
65 
67  caseParameterTypes,
68  caseWildcardTypes,
69  parameterTypes,
70  wildcardTypes);
71 
72  if (cases_.find(switch_.getDefaultValue()) == cases_.end()) {
74  }
75  }
void insertAndCheckTypes(ParameterTypes switchType, std::set< ParameterTypes > const &caseParameterTypes, std::set< ParameterTypes > const &caseWildcardTypes, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
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)
void insertAndCheckLabels(std::string const &switchLabel, std::set< std::string > &usedLabels, std::set< std::string > &labels) const
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void throwNoCaseForDefault(std::string const &switchLabel) const
ParameterDescription< T > switch_
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 175 of file ParameterSwitch.h.

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

178  {
179  thePair.second->checkAndGetLabelsAndTypes(labels, parameterTypes, wildcardTypes);
180  }
template<class T >
virtual ParameterDescriptionNode* edm::ParameterSwitch< T >::clone ( void  ) const
inlinevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 43 of file ParameterSwitch.h.

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

43  {
44  return new ParameterSwitch(*this);
45  }
ParameterSwitch(ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)
template<class T >
virtual bool edm::ParameterSwitch< T >::exists_ ( ParameterSet const &  pset) const
inlineprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 173 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::switch_.

173 { return switch_.exists(pset); }
ParameterDescription< T > switch_
template<class T >
virtual void edm::ParameterSwitch< T >::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
)
inlineprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 126 of file ParameterSwitch.h.

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

129  {
130  printBase(os, optional, writeToCfi, dfh, switch_.label(), switch_.isTracked(), parameterTypeEnumToString(switch_.type()));
131  }
std::string parameterTypeEnumToString(ParameterTypes iType)
void printBase(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh, std::string const &switchLabel, bool isTracked, std::string const &typeString) const
ParameterDescription< T > switch_
template<class T >
virtual void edm::ParameterSwitch< T >::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
inlineprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 133 of file ParameterSwitch.h.

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

135  {
136 
137  DocFormatHelper new_dfh(dfh);
138  printNestedContentBase(os, dfh, new_dfh, switch_.label());
139 
140  switch_.print(os, optional, true, new_dfh);
141  for_all(cases_, boost::bind(&ParameterSwitchBase::printCaseT<T>,
142  _1,
143  boost::ref(os),
144  optional,
145  boost::ref(new_dfh),
146  boost::cref(switch_.label())));
147 
148  new_dfh.setPass(1);
149  new_dfh.setCounter(0);
150 
151  new_dfh.indent(os);
152  os << "switch:\n";
153  switch_.print(os, optional, true, new_dfh);
154  for_all(cases_, boost::bind(&ParameterSwitchBase::printCaseT<T>,
155  _1,
156  boost::ref(os),
157  optional,
158  boost::ref(new_dfh),
159  boost::cref(switch_.label())));
160 
161  new_dfh.setPass(2);
162  new_dfh.setCounter(0);
163 
164  switch_.printNestedContent(os, optional, new_dfh);
165  for_all(cases_, boost::bind(&ParameterSwitchBase::printCaseT<T>,
166  _1,
167  boost::ref(os),
168  optional,
169  boost::ref(new_dfh),
170  boost::cref(switch_.label())));
171  }
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
void printNestedContentBase(std::ostream &os, DocFormatHelper &dfh, DocFormatHelper &new_dfh, std::string const &switchLabel)
ParameterDescription< T > switch_
template<class T >
virtual void edm::ParameterSwitch< T >::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
inlineprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 77 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::cases_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), getDQMSummary::iter, contentValuesCheck::ss, edm::ParameterSwitch< T >::switch_, and edm::ParameterSwitchBase::throwNoCaseForSwitchValue().

79  {
80 
81  switch_.validate(pset, validatedLabels, optional);
82  if (switch_.exists(pset)) {
83  T switchValue;
84  if (switch_.isTracked()) {
85  switchValue = pset.getParameter<T>(switch_.label());
86  }
87  else {
88  switchValue = pset.getUntrackedParameter<T>(switch_.label());
89  }
90  typename CaseMap::const_iterator selectedCase = cases_.find(switchValue);
91  if (selectedCase != cases_.end()) {
92  selectedCase->second->validate(pset, validatedLabels, false);
93  }
94  else {
95  std::stringstream ss;
96  ss << "The switch parameter with label \""
97  << switch_.label()
98  << "\" has been assigned an illegal value.\n"
99  << "The value from the configuration is \""
100  << switchValue
101  << "\".\n"
102  << "The allowed values are:\n";
103 
104  for (CaseMapConstIter iter = cases_.begin(), iEnd = cases_.end();
105  iter != iEnd;
106  ++iter) {
107  ss << " " << iter->first << "\n";
108  }
109  throwNoCaseForSwitchValue(ss.str());
110  }
111  }
112  }
std::map< T, edm::value_ptr< ParameterDescriptionNode > >::const_iterator CaseMapConstIter
void throwNoCaseForSwitchValue(std::string const &message) const
ParameterDescription< T > switch_
long double T
template<class T >
virtual void edm::ParameterSwitch< T >::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
inlineprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 114 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::cases_, and edm::ParameterSwitch< T >::switch_.

117  {
118  switch_.writeCfi(os, startWithComma, indentation, wroteSomething);
119 
120  typename CaseMap::const_iterator selectedCase = cases_.find(switch_.getDefaultValue());
121  if (selectedCase != cases_.end()) {
122  selectedCase->second->writeCfi(os, startWithComma, indentation, wroteSomething);
123  }
124  }
ParameterDescription< T > switch_

Member Data Documentation

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