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 175 of file ParameterDescription.cc.

178  :
180  psetDesc_(new ParameterSetDescription(psetDesc)),
181  vPset_(vPset),
182  partOfDefaultOfVPSet_(false) {
183  }
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 186 of file ParameterDescription.cc.

189  :
191  psetDesc_(new ParameterSetDescription(psetDesc)),
192  vPset_(vPset),
193  partOfDefaultOfVPSet_(false) {
194  }
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 197 of file ParameterDescription.cc.

199  :
200  ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false),
201  psetDesc_(new ParameterSetDescription(psetDesc)),
202  vPset_(),
203  partOfDefaultOfVPSet_(false) {
204  }
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 207 of file ParameterDescription.cc.

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

Definition at line 217 of file ParameterDescription.cc.

217 { }

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 384 of file ParameterDescription.cc.

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

384  {
385  return pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
386  }
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 432 of file ParameterDescription.cc.

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

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 285 of file ParameterDescription.cc.

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

Implements edm::ParameterDescriptionBase.

Definition at line 439 of file ParameterDescription.cc.

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

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

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 221 of file ParameterDescription.cc.

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

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 227 of file ParameterDescription.cc.

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

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 273 of file ParameterDescription.cc.

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

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

Reimplemented from edm::ParameterDescriptionBase.

Definition at line 291 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(), and edm::DocFormatHelper::TOP.

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

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

235  {
236 
237  bool exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
238 
239  if(exists) {
240  validatedLabels.insert(label());
241  } else if(pset.existsAs<std::vector<ParameterSet> >(label(), !isTracked())) {
243  } else if(pset.exists(label())) {
245  }
246 
247  if(!exists && !optional) {
248  if(hasDefault()) {
249  if(isTracked()) {
250  pset.addParameter(label(), vPset_);
251  } else {
252  pset.addUntrackedParameter(label(), vPset_);
253  }
254  validatedLabels.insert(label());
255  } else {
257  }
258  }
259 
260  exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
261  if(exists) {
262  VParameterSetEntry * vpsetEntry = pset.getPSetVectorForUpdate(label());
263  assert(vpsetEntry);
264 
265  for(unsigned i = 0; i < vpsetEntry->size(); ++i) {
266  psetDesc_->validate(vpsetEntry->psetInVector(i));
267  }
268  }
269  }
int i
Definition: DBlmapReader.cc:9
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 413 of file ParameterDescription.cc.

References edm::for_all().

413  {
414  bool nextOneStartsWithAComma = false;
415  for_all(vPset_, boost::bind(&writeOneElementToCfi,
416  _1,
417  boost::ref(os),
418  indentation,
419  boost::ref(nextOneStartsWithAComma)));
420  os << "\n";
421  printSpaces(os, indentation);
422  }
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 426 of file ParameterDescription.cc.

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

Definition at line 390 of file ParameterDescription.cc.

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

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