CMS 3D CMS Logo

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

virtual ParameterDescriptionNodeclone () const
 
 ParameterDescription (std::string const &iLabel, ParameterSetDescription const &psetDesc, bool isTracked, std::vector< ParameterSet > const &vPset)
 
 ParameterDescription (char const *iLabel, ParameterSetDescription const &psetDesc, bool isTracked, std::vector< ParameterSet > const &vPset)
 
 ParameterDescription (std::string const &iLabel, ParameterSetDescription const &psetDesc, bool isTracked)
 
 ParameterDescription (char const *iLabel, ParameterSetDescription const &psetDesc, bool isTracked)
 
virtual
ParameterSetDescription const * 
parameterSetDescription () const
 
virtual ParameterSetDescriptionparameterSetDescription ()
 
void setPartOfDefaultOfVPSet (bool value)
 
virtual ~ParameterDescription ()
 
- Public Member Functions inherited from edm::ParameterDescriptionBase
bool hasDefault () const
 
bool isTracked () const
 
std::string const & label () const
 
ParameterTypes type () const
 
virtual ~ParameterDescriptionBase ()
 
- 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 bool exists_ (ParameterSet const &pset) const
 
virtual bool exists_ (ParameterSet const &pset, bool isTracked) const
 
virtual bool hasNestedContent_ ()
 
virtual void insertDefault_ (ParameterSet &pset) const
 
virtual void printDefault_ (std::ostream &os, 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, int indentation) const
 
virtual void writeDoc_ (std::ostream &os, int indentation) const
 

Static Private Member Functions

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

Private Attributes

bool partOfDefaultOfVPSet_
 
value_ptr
< ParameterSetDescription
psetDesc_
 
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)
 
 ParameterDescriptionBase (char const *iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)
 
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 254 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 
)

Definition at line 176 of file ParameterDescription.cc.

179  :
181  psetDesc_(new ParameterSetDescription(psetDesc)),
182  vPset_(vPset),
183  partOfDefaultOfVPSet_(false) {
184  }
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)
edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( char const *  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked,
std::vector< ParameterSet > const &  vPset 
)

Definition at line 187 of file ParameterDescription.cc.

190  :
192  psetDesc_(new ParameterSetDescription(psetDesc)),
193  vPset_(vPset),
194  partOfDefaultOfVPSet_(false) {
195  }
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)
edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( std::string const &  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked 
)

Definition at line 198 of file ParameterDescription.cc.

200  :
201  ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false),
202  psetDesc_(new ParameterSetDescription(psetDesc)),
203  vPset_(),
204  partOfDefaultOfVPSet_(false) {
205  }
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)
edm::ParameterDescription< std::vector< ParameterSet > >::ParameterDescription ( char const *  iLabel,
ParameterSetDescription const &  psetDesc,
bool  isTracked 
)

Definition at line 208 of file ParameterDescription.cc.

210  :
211  ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false),
212  psetDesc_(new ParameterSetDescription(psetDesc)),
213  vPset_(),
214  partOfDefaultOfVPSet_(false) {
215  }
ParameterDescriptionBase(std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)

Definition at line 218 of file ParameterDescription.cc.

218 { }

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 281 of file ParameterDescription.h.

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

281  {
282  return new ParameterDescription(*this);
283  }
ParameterDescription(std::string const &iLabel, ParameterSetDescription const &psetDesc, bool isTracked, std::vector< ParameterSet > const &vPset)
bool edm::ParameterDescription< std::vector< ParameterSet > >::exists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 385 of file ParameterDescription.cc.

References edm::ParameterSet::existsAs(), and diffTwoXMLs::label.

385  {
386  return pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
387  }
std::string const & label() const
bool edm::ParameterDescription< std::vector< ParameterSet > >::exists_ ( ParameterSet const &  pset,
bool  isTracked 
) const
privatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 433 of file ParameterDescription.cc.

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

433  {
435  return true;
436  }
bool edm::ParameterDescription< std::vector< ParameterSet > >::hasNestedContent_ ( )
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 286 of file ParameterDescription.cc.

286  {
287  return true;
288  }
void edm::ParameterDescription< std::vector< ParameterSet > >::insertDefault_ ( ParameterSet pset) const
privatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 440 of file ParameterDescription.cc.

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

440  {
442  return;
443  }
ParameterSetDescription const * edm::ParameterDescription< std::vector< ParameterSet > >::parameterSetDescription ( ) const
virtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 222 of file ParameterDescription.cc.

222  {
223  return psetDesc_.operator->();
224  }
ParameterSetDescription * edm::ParameterDescription< std::vector< ParameterSet > >::parameterSetDescription ( )
virtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 228 of file ParameterDescription.cc.

228  {
229  return psetDesc_.operator->();
230  }
void edm::ParameterDescription< std::vector< ParameterSet > >::printDefault_ ( std::ostream &  os,
bool  writeToCfi,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 274 of file ParameterDescription.cc.

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

276  {
277  os << "see Section " << dfh.section()
278  << "." << dfh.counter();
279  if(!writeToCfi) os << " (do not write to cfi)";
280  os << "\n";
281  }
void edm::ParameterDescription< std::vector< ParameterSet > >::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 292 of file ParameterDescription.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::fillDescriptionFromPSet(), i, edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), diffTwoXMLs::label, edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::parent(), edm::ParameterSetDescription::print(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setSection(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and edm::DocFormatHelper::TOP.

294  {
295 
296  int indentation = dfh.indentation();
297  if(dfh.parent() != DocFormatHelper::TOP) {
298  indentation -= DocFormatHelper::offsetSectionContent();
299  }
300 
301  if(!partOfDefaultOfVPSet_) {
302  printSpaces(os, indentation);
303  os << "Section " << dfh.section() << "." << dfh.counter()
304  << " " << label() << " VPSet description:\n";
305 
307  os << "All elements will be validated using the PSet description in Section "
308  << dfh.section() << "." << dfh.counter() << ".1.\n";
309  } else {
310  printSpaces(os, indentation);
311  os << "Section " << dfh.section() << "." << dfh.counter()
312  << " " << " VPSet description for VPSet that is part of the default of a containing VPSet:\n";
313  }
314 
316 
317  unsigned subsectionOffset = 2;
318  if(partOfDefaultOfVPSet_) subsectionOffset = 1;
319 
320  if(hasDefault()) {
321  if(vPset_.size() == 0U) os << "The default VPSet is empty.\n";
322  else if(vPset_.size() == 1U) os << "The default VPSet has 1 element.\n";
323  else os << "The default VPSet has " << vPset_.size() << " elements.\n";
324 
325  if(vPset_.size() > 0U) {
326  for(unsigned i = 0; i < vPset_.size(); ++i) {
328  os << "[" << (i) << "]: see Section " << dfh.section()
329  << "." << dfh.counter() << "." << (i + subsectionOffset) << "\n";
330  }
331  }
332  } else {
333  os << "Does not have a default VPSet.\n";
334  }
335 
336  if(!dfh.brief()) os << "\n";
337 
338  if(!partOfDefaultOfVPSet_) {
339 
340  std::stringstream ss;
341  ss << dfh.section() << "." << dfh.counter() << ".1";
342  std::string newSection = ss.str();
343 
344  printSpaces(os, indentation);
345  os << "Section " << newSection << " description of PSet used to validate elements of VPSet:\n";
346  if(!dfh.brief()) os << "\n";
347 
348  DocFormatHelper new_dfh(dfh);
349  new_dfh.init();
350  new_dfh.setSection(newSection);
351  if(dfh.parent() == DocFormatHelper::TOP) {
352  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
353  }
354  psetDesc_->print(os, new_dfh);
355  }
356 
357  if(hasDefault()) {
358  for(unsigned i = 0; i < vPset_.size(); ++i) {
359 
360  std::stringstream ss;
361  ss << dfh.section() << "." << dfh.counter() << "." << (i + subsectionOffset);
362  std::string newSection = ss.str();
363 
364  printSpaces(os, indentation);
365  os << "Section " << newSection << " PSet description of "
366  << "default VPSet element [" << i << "]\n";
367  if(!dfh.brief()) os << "\n";
368 
369  DocFormatHelper new_dfh(dfh);
370  new_dfh.init();
371  new_dfh.setSection(newSection);
372  if(dfh.parent() == DocFormatHelper::TOP) {
373  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
374  }
375 
376  ParameterSetDescription defaultDescription;
377  fillDescriptionFromPSet(vPset_[i], defaultDescription);
378  defaultDescription.print(os, new_dfh);
379  }
380  }
381  }
int i
Definition: DBlmapReader.cc:9
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
privatevirtual

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 234 of file ParameterDescription.cc.

References edm::ParameterSet::addParameter(), edm::ParameterSet::addUntrackedParameter(), assert(), edm::ParameterSet::exists(), edm::ParameterSet::existsAs(), edm::ParameterSet::getPSetVectorForUpdate(), i, diffTwoXMLs::label, edm::VParameterSetEntry::psetInVector(), and edm::VParameterSetEntry::size().

236  {
237 
238  bool exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
239 
240  if(exists) {
241  validatedLabels.insert(label());
242  } else if(pset.existsAs<std::vector<ParameterSet> >(label(), !isTracked())) {
244  } else if(pset.exists(label())) {
246  }
247 
248  if(!exists && !optional) {
249  if(hasDefault()) {
250  if(isTracked()) {
251  pset.addParameter(label(), vPset_);
252  } else {
253  pset.addUntrackedParameter(label(), vPset_);
254  }
255  validatedLabels.insert(label());
256  } else {
258  }
259  }
260 
261  exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
262  if(exists) {
263  VParameterSetEntry * vpsetEntry = pset.getPSetVectorForUpdate(label());
264  assert(vpsetEntry);
265 
266  for(unsigned i = 0; i < vpsetEntry->size(); ++i) {
267  psetDesc_->validate(vpsetEntry->psetInVector(i));
268  }
269  }
270  }
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
bool exists(ParameterSet const &pset) const
std::string const & label() const
void edm::ParameterDescription< std::vector< ParameterSet > >::writeCfi_ ( std::ostream &  os,
int  indentation 
) const
privatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 414 of file ParameterDescription.cc.

References edm::for_all().

414  {
415  bool nextOneStartsWithAComma = false;
416  for_all(vPset_, std::bind(&writeOneElementToCfi,
417  std::placeholders::_1,
418  std::ref(os),
419  indentation,
420  std::ref(nextOneStartsWithAComma)));
421  os << "\n";
422  printSpaces(os, indentation);
423  }
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
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
privatevirtual

Implements edm::ParameterDescriptionBase.

Definition at line 427 of file ParameterDescription.cc.

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

Definition at line 391 of file ParameterDescription.cc.

References edm::fillDescriptionFromPSet(), dataformats::indent(), and edm::ParameterSetDescription::writeCfi().

394  {
395  if(nextOneStartsWithAComma) os << ",";
396  nextOneStartsWithAComma = true;
397  os << "\n";
398  printSpaces(os, indentation + 2);
399 
400  os << "cms.PSet(";
401 
402  bool startWithComma = false;
403  int indent = indentation + 4;
404 
405  ParameterSetDescription psetDesc;
406  fillDescriptionFromPSet(pset, psetDesc);
407  psetDesc.writeCfi(os, startWithComma, indent);
408 
409  os << ")";
410  }
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 320 of file ParameterDescription.h.

Definition at line 318 of file ParameterDescription.h.

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

Definition at line 319 of file ParameterDescription.h.