CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
edm::ParameterDescription< std::vector< ParameterSet > > Class Template Reference

#include <ParameterDescription.h>

Inheritance diagram for edm::ParameterDescription< std::vector< ParameterSet > >:
edm::ParameterDescriptionBase edm::ParameterDescriptionNode

Public Member Functions

ParameterDescriptionNodeclone () const override
 
 ParameterDescription (std::string const &iLabel, ParameterSetDescription const &psetDesc, bool isTracked, std::vector< ParameterSet > const &vPset, Comment const &iComment=Comment())
 
 ParameterDescription (char const *iLabel, ParameterSetDescription const &psetDesc, bool isTracked, std::vector< ParameterSet > const &vPset, Comment const &iComment=Comment())
 
 ParameterDescription (std::string const &iLabel, ParameterSetDescription const &psetDesc, bool isTracked, Comment const &iComment=Comment())
 
 ParameterDescription (char const *iLabel, ParameterSetDescription const &psetDesc, bool isTracked, Comment const &iComment=Comment())
 
ParameterSetDescription const * parameterSetDescription () const override
 
ParameterSetDescriptionparameterSetDescription () override
 
void setPartOfDefaultOfVPSet (bool value)
 
 ~ParameterDescription () override
 
- Public Member Functions inherited from edm::ParameterDescriptionBase
bool hasDefault () const
 
bool isTracked () const
 
std::string const & label () const
 
ParameterTypes type () const
 
 ~ParameterDescriptionBase () 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 (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

bool exists_ (ParameterSet const &pset) const override
 
bool exists_ (ParameterSet const &pset, bool isTracked) const override
 
bool hasNestedContent_ () const override
 
void insertDefault_ (ParameterSet &pset) const override
 
void printDefault_ (std::ostream &os, 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, int indentation) const override
 
void writeDoc_ (std::ostream &os, int indentation) const override
 

Static Private Member Functions

static void writeOneElementToCfi (ParameterSet const &pset, std::ostream &os, int indentation, bool &nextOneStartsWithAComma)
 

Private Attributes

bool partOfDefaultOfVPSet_
 
value_ptr< ParameterSetDescriptionpsetDesc_
 
std::vector< ParameterSetvPset_
 

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::ParameterDescriptionBase
 ParameterDescriptionBase (std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const &iComment)
 
 ParameterDescriptionBase (char const *iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const &iComment)
 
void throwMissingRequiredNoDefault () const
 
void throwParameterWrongTrackiness () const
 
void throwParameterWrongType () const
 
- Protected Attributes inherited from edm::ParameterDescriptionNode
std::string comment_
 

Detailed Description

template<>
class edm::ParameterDescription< std::vector< ParameterSet > >

Definition at line 236 of file ParameterDescription.h.

Constructor & Destructor Documentation

edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( std::string const &  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked,
std::vector< ParameterSet > const &  vPset,
Comment const &  iComment = Comment() 
)

Definition at line 146 of file ParameterDescription.cc.

151  : ParameterDescriptionBase(iLabel, k_VPSet, isTracked, true, iComment),
152  psetDesc_(new ParameterSetDescription(psetDesc)),
153  vPset_(vPset),
154  partOfDefaultOfVPSet_(false) {}
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const &iComment)
edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( char const *  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked,
std::vector< ParameterSet > const &  vPset,
Comment const &  iComment = Comment() 
)

Definition at line 156 of file ParameterDescription.cc.

161  : ParameterDescriptionBase(iLabel, k_VPSet, isTracked, true, iComment),
162  psetDesc_(new ParameterSetDescription(psetDesc)),
163  vPset_(vPset),
164  partOfDefaultOfVPSet_(false) {}
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const &iComment)
edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( std::string const &  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked,
Comment const &  iComment = Comment() 
)

Definition at line 166 of file ParameterDescription.cc.

170  : ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false, iComment),
171  psetDesc_(new ParameterSetDescription(psetDesc)),
172  vPset_(),
173  partOfDefaultOfVPSet_(false) {}
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const &iComment)
edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( char const *  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked,
Comment const &  iComment = Comment() 
)

Definition at line 175 of file ParameterDescription.cc.

179  : ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false, iComment),
180  psetDesc_(new ParameterSetDescription(psetDesc)),
181  vPset_(),
182  partOfDefaultOfVPSet_(false) {}
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const &iComment)

Definition at line 184 of file ParameterDescription.cc.

184 {}

Member Function Documentation

ParameterDescriptionNode* edm::ParameterDescription< std::vector< ParameterSet > >::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 265 of file ParameterDescription.h.

265 { return new ParameterDescription(*this); }
ParameterDescription(std::string const &iLabel, ParameterSetDescription const &psetDesc, bool isTracked, std::vector< ParameterSet > const &vPset, Comment const &iComment=Comment())
bool edm::ParameterDescription< std::vector< ParameterSet > >::exists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 336 of file ParameterDescription.cc.

References edm::ParameterSet::existsAs(), edm::ParameterDescriptionBase::isTracked(), and edm::ParameterDescriptionBase::label().

336  {
337  return pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
338  }
std::string const & label() const
bool edm::ParameterDescription< std::vector< ParameterSet > >::exists_ ( ParameterSet const &  pset,
bool  isTracked 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 375 of file ParameterDescription.cc.

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

375  {
377  return true;
378  }
bool edm::ParameterDescription< std::vector< ParameterSet > >::hasNestedContent_ ( ) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 240 of file ParameterDescription.cc.

240 { return true; }
void edm::ParameterDescription< std::vector< ParameterSet > >::insertDefault_ ( ParameterSet pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 380 of file ParameterDescription.cc.

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

380  {
382  return;
383  }
ParameterSetDescription const * edm::ParameterDescription< std::vector< ParameterSet > >::parameterSetDescription ( ) const
overridevirtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 186 of file ParameterDescription.cc.

186  {
187  return psetDesc_.operator->();
188  }
ParameterSetDescription * edm::ParameterDescription< std::vector< ParameterSet > >::parameterSetDescription ( )
overridevirtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 190 of file ParameterDescription.cc.

190  {
191  return psetDesc_.operator->();
192  }
void edm::ParameterDescription< std::vector< ParameterSet > >::printDefault_ ( std::ostream &  os,
bool  writeToCfi,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 231 of file ParameterDescription.cc.

References edm::DocFormatHelper::counter(), and edm::DocFormatHelper::section().

233  {
234  os << "see Section " << dfh.section() << "." << dfh.counter();
235  if (!writeToCfi)
236  os << " (do not write to cfi)";
237  os << "\n";
238  }
void edm::ParameterDescription< std::vector< ParameterSet > >::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 242 of file ParameterDescription.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::fillDescriptionFromPSet(), edm::ParameterDescriptionBase::hasDefault(), mps_fire::i, edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), edm::ParameterDescriptionBase::label(), edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::parent(), edm::ParameterSetDescription::print(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setSection(), AlCaHLTBitMon_QueryRunRegistry::string, edm::DocFormatHelper::TOP, and mitigatedMETSequence_cff::U.

244  {
245  int indentation = dfh.indentation();
246  if (dfh.parent() != DocFormatHelper::TOP) {
247  indentation -= DocFormatHelper::offsetSectionContent();
248  }
249 
250  if (!partOfDefaultOfVPSet_) {
251  printSpaces(os, indentation);
252  os << "Section " << dfh.section() << "." << dfh.counter() << " " << label() << " VPSet description:\n";
253 
255  os << "All elements will be validated using the PSet description in Section " << dfh.section() << "."
256  << dfh.counter() << ".1.\n";
257  } else {
258  printSpaces(os, indentation);
259  os << "Section " << dfh.section() << "." << dfh.counter() << " "
260  << " VPSet description for VPSet that is part of the default of a containing VPSet:\n";
261  }
262 
264 
265  unsigned subsectionOffset = 2;
267  subsectionOffset = 1;
268 
269  if (hasDefault()) {
270  if (vPset_.empty())
271  os << "The default VPSet is empty.\n";
272  else if (vPset_.size() == 1U)
273  os << "The default VPSet has 1 element.\n";
274  else
275  os << "The default VPSet has " << vPset_.size() << " elements.\n";
276 
277  if (!vPset_.empty()) {
278  for (unsigned i = 0; i < vPset_.size(); ++i) {
280  os << "[" << (i) << "]: see Section " << dfh.section() << "." << dfh.counter() << "."
281  << (i + subsectionOffset) << "\n";
282  }
283  }
284  } else {
285  os << "Does not have a default VPSet.\n";
286  }
287 
288  if (!dfh.brief())
289  os << "\n";
290 
291  if (!partOfDefaultOfVPSet_) {
292  std::stringstream ss;
293  ss << dfh.section() << "." << dfh.counter() << ".1";
294  std::string newSection = ss.str();
295 
296  printSpaces(os, indentation);
297  os << "Section " << newSection << " description of PSet used to validate elements of VPSet:\n";
298  if (!dfh.brief())
299  os << "\n";
300 
301  DocFormatHelper new_dfh(dfh);
302  new_dfh.init();
303  new_dfh.setSection(newSection);
304  if (dfh.parent() == DocFormatHelper::TOP) {
305  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
306  }
307  psetDesc_->print(os, new_dfh);
308  }
309 
310  if (hasDefault()) {
311  for (unsigned i = 0; i < vPset_.size(); ++i) {
312  std::stringstream ss;
313  ss << dfh.section() << "." << dfh.counter() << "." << (i + subsectionOffset);
314  std::string newSection = ss.str();
315 
316  printSpaces(os, indentation);
317  os << "Section " << newSection << " PSet description of "
318  << "default VPSet element [" << i << "]\n";
319  if (!dfh.brief())
320  os << "\n";
321 
322  DocFormatHelper new_dfh(dfh);
323  new_dfh.init();
324  new_dfh.setSection(newSection);
325  if (dfh.parent() == DocFormatHelper::TOP) {
326  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
327  }
328 
329  ParameterSetDescription defaultDescription;
330  fillDescriptionFromPSet(vPset_[i], defaultDescription);
331  defaultDescription.print(os, new_dfh);
332  }
333  }
334  }
void fillDescriptionFromPSet(ParameterSet const &pset, ParameterSetDescription &desc)
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
std::string const & label() const
void edm::ParameterDescription< std::vector< ParameterSet > >::setPartOfDefaultOfVPSet ( bool  value)
inline
void edm::ParameterDescription< std::vector< ParameterSet > >::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 194 of file ParameterDescription.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), edm::ParameterDescriptionNode::exists(), edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::ParameterSet::getPSetVectorForUpdate(), edm::ParameterDescriptionBase::hasDefault(), mps_fire::i, edm::ParameterDescriptionBase::isTracked(), edm::ParameterDescriptionBase::label(), edm::VParameterSetEntry::psetInVector(), edm::VParameterSetEntry::size(), edm::ParameterDescriptionBase::throwMissingRequiredNoDefault(), edm::ParameterDescriptionBase::throwParameterWrongTrackiness(), and edm::ParameterDescriptionBase::throwParameterWrongType().

196  {
197  bool exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
198 
199  if (exists) {
200  validatedLabels.insert(label());
201  } else if (pset.existsAs<std::vector<ParameterSet> >(label(), !isTracked())) {
203  } else if (pset.exists(label())) {
205  }
206 
207  if (!exists && !optional) {
208  if (hasDefault()) {
209  if (isTracked()) {
210  pset.addParameter(label(), vPset_);
211  } else {
212  pset.addUntrackedParameter(label(), vPset_);
213  }
214  validatedLabels.insert(label());
215  } else {
217  }
218  }
219 
220  exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
221  if (exists) {
222  VParameterSetEntry* vpsetEntry = pset.getPSetVectorForUpdate(label());
223  assert(vpsetEntry);
224 
225  for (unsigned i = 0; i < vpsetEntry->size(); ++i) {
226  psetDesc_->validate(vpsetEntry->psetInVector(i));
227  }
228  }
229  }
bool exists(ParameterSet const &pset) const
std::string const & label() const
void edm::ParameterDescription< std::vector< ParameterSet > >::writeCfi_ ( std::ostream &  os,
int  indentation 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 362 of file ParameterDescription.cc.

References edm::for_all(), and edm::ParameterDescriptionNode::printSpaces().

362  {
363  bool nextOneStartsWithAComma = false;
364  for_all(
365  vPset_,
366  std::bind(
367  &writeOneElementToCfi, std::placeholders::_1, std::ref(os), indentation, std::ref(nextOneStartsWithAComma)));
368  os << "\n";
369  printSpaces(os, indentation);
370  }
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:14
static void printSpaces(std::ostream &os, int n)
static void writeOneElementToCfi(ParameterSet const &pset, std::ostream &os, int indentation, bool &nextOneStartsWithAComma)
void edm::ParameterDescription< std::vector< ParameterSet > >::writeDoc_ ( std::ostream &  os,
int  indentation 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 372 of file ParameterDescription.cc.

372 {}
void edm::ParameterDescription< std::vector< ParameterSet > >::writeOneElementToCfi ( ParameterSet const &  pset,
std::ostream &  os,
int  indentation,
bool &  nextOneStartsWithAComma 
)
staticprivate

Definition at line 340 of file ParameterDescription.cc.

References edm::fillDescriptionFromPSet(), summarizeEdmComparisonLogfiles::indent, edm::ParameterDescriptionNode::printSpaces(), and edm::ParameterSetDescription::writeCfi().

343  {
344  if (nextOneStartsWithAComma)
345  os << ",";
346  nextOneStartsWithAComma = true;
347  os << "\n";
348  printSpaces(os, indentation + 2);
349 
350  os << "cms.PSet(";
351 
352  bool startWithComma = false;
353  int indent = indentation + 4;
354 
355  ParameterSetDescription psetDesc;
356  fillDescriptionFromPSet(pset, psetDesc);
357  psetDesc.writeCfi(os, startWithComma, indent);
358 
359  os << ")";
360  }
void fillDescriptionFromPSet(ParameterSet const &pset, ParameterSetDescription &desc)
static void printSpaces(std::ostream &os, int n)

Member Data Documentation

bool edm::ParameterDescription< std::vector< ParameterSet > >::partOfDefaultOfVPSet_
private

Definition at line 295 of file ParameterDescription.h.

Definition at line 293 of file ParameterDescription.h.

std::vector<ParameterSet> edm::ParameterDescription< std::vector< ParameterSet > >::vPset_
private

Definition at line 294 of file ParameterDescription.h.