CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::ParameterDescriptionBase Class Referenceabstract

#include <ParameterDescriptionBase.h>

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

Public Member Functions

bool hasDefault () const
 
bool isTracked () const
 
std::string const & label () const
 
virtual ParameterSetDescription const * parameterSetDescription () const
 
virtual ParameterSetDescriptionparameterSetDescription ()
 
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
 
virtual ParameterDescriptionNodeclone () const =0
 
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 ()
 

Protected Member Functions

 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 Member Functions inherited from edm::ParameterDescriptionNode
virtual bool exists_ (ParameterSet const &pset) const =0
 
virtual bool hasNestedContent_ () const
 

Private Member Functions

void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
 
virtual bool exists_ (ParameterSet const &pset, bool isTracked) const =0
 
int howManyXORSubNodesExist_ (ParameterSet const &pset) const override
 
virtual void insertDefault_ (ParameterSet &pset) const =0
 
bool partiallyExists_ (ParameterSet const &pset) const override
 
void print_ (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
 
virtual void printDefault_ (std::ostream &os, bool writeToCfi, DocFormatHelper &dfh) const
 
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 &startWithComma, int indentation, bool &wroteSomething) const override
 
virtual void writeCfi_ (std::ostream &os, int indentation) const =0
 
virtual void writeDoc_ (std::ostream &os, int indentation) const =0
 

Private Attributes

bool hasDefault_
 
bool isTracked_
 
std::string label_
 
ParameterTypes type_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::ParameterDescriptionNode
static void printSpaces (std::ostream &os, int n)
 
- Protected Attributes inherited from edm::ParameterDescriptionNode
std::string comment_
 

Detailed Description

Definition at line 33 of file ParameterDescriptionBase.h.

Constructor & Destructor Documentation

ParameterDescriptionBase::~ParameterDescriptionBase ( )
override

Definition at line 50 of file ParameterDescriptionBase.cc.

50 {}
ParameterDescriptionBase::ParameterDescriptionBase ( std::string const &  iLabel,
ParameterTypes  iType,
bool  isTracked,
bool  hasDefault,
Comment const &  iComment 
)
protected

Definition at line 24 of file ParameterDescriptionBase.cc.

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

Referenced by parameterSetDescription().

26  : ParameterDescriptionNode(iComment),
27  label_(iLabel),
28  type_(iType),
31  if (label_.empty()) {
32  throw Exception(errors::LogicError) << "Empty string used as a label for a parameter. This is\n"
33  "not allowed.\n";
34  }
35  }
ParameterDescriptionBase::ParameterDescriptionBase ( char const *  iLabel,
ParameterTypes  iType,
bool  isTracked,
bool  hasDefault,
Comment const &  iComment 
)
protected

Definition at line 37 of file ParameterDescriptionBase.cc.

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

39  : ParameterDescriptionNode(iComment),
40  label_(iLabel),
41  type_(iType),
44  if (label_.empty()) {
45  throw Exception(errors::LogicError) << "Empty string used as a label for a parameter. This is\n"
46  "not allowed.\n";
47  }
48  }

Member Function Documentation

void ParameterDescriptionBase::checkAndGetLabelsAndTypes_ ( std::set< std::string > &  usedLabels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 91 of file ParameterDescriptionBase.cc.

References label(), and type().

Referenced by parameterSetDescription().

93  {
94  usedLabels.insert(label());
95  parameterTypes.insert(type());
96  }
std::string const & label() const
virtual bool edm::ParameterDescriptionBase::exists_ ( ParameterSet const &  pset,
bool  isTracked 
) const
privatepure virtual
bool edm::ParameterDescriptionBase::hasDefault ( ) const
inline
int ParameterDescriptionBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 243 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by parameterSetDescription().

243  {
244  return exists(pset) ? 1 : 0;
245  }
bool exists(ParameterSet const &pset) const
virtual void edm::ParameterDescriptionBase::insertDefault_ ( ParameterSet pset) const
privatepure virtual
bool edm::ParameterDescriptionBase::isTracked ( ) const
inline

Definition at line 39 of file ParameterDescriptionBase.h.

References isTracked_.

Referenced by Types.PSet::clone(), Mixins._ParameterTypeBase::configTypeName(), edm::ParameterDescription< ParameterSetDescription >::exists_(), edm::ParameterDescription< std::vector< ParameterSet > >::exists_(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Types.double::insertInto(), Mixins.UsingBlock::insertInto(), Types.bool::insertInto(), Types.string::insertInto(), Types.EventID::insertInto(), Types.LuminosityBlockID::insertInto(), Types.LuminosityBlockRange::insertInto(), Types.EventRange::insertInto(), Types.InputTag::insertInto(), Types.ESInputTag::insertInto(), Types.FileInPath::insertInto(), Types.PSet::insertInto(), Types.vint32::insertInto(), Types.vuint32::insertInto(), Types.vint64::insertInto(), Types.vuint64::insertInto(), Types.vdouble::insertInto(), Types.vbool::insertInto(), Types.vstring::insertInto(), Types.VLuminosityBlockID::insertInto(), Types.VInputTag::insertInto(), Types.VESInputTag::insertInto(), Types.VEventID::insertInto(), Types.VLuminosityBlockRange::insertInto(), Types.VEventRange::insertInto(), Types.VPSet::insertInto(), parameterSetDescription(), print_(), Mixins._ParameterTypeBase::pythonTypeName(), throwMissingRequiredNoDefault(), throwParameterWrongTrackiness(), throwParameterWrongType(), validate_(), edm::ParameterDescription< ParameterSetDescription >::validate_(), edm::ParameterDescription< std::vector< ParameterSet > >::validate_(), and writeCfi_().

std::string const& edm::ParameterDescriptionBase::label ( ) const
inline
virtual ParameterSetDescription const* edm::ParameterDescriptionBase::parameterSetDescription ( ) const
inlinevirtual
virtual ParameterSetDescription* edm::ParameterDescriptionBase::parameterSetDescription ( )
inlinevirtual
bool ParameterDescriptionBase::partiallyExists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 241 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by parameterSetDescription().

241 { return exists(pset); }
bool exists(ParameterSet const &pset) const
void ParameterDescriptionBase::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 144 of file ParameterDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::column1(), edm::DocFormatHelper::column2(), edm::DocFormatHelper::column3(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), isTracked(), label(), edm::parameterTypeEnumToString(), edm::DocFormatHelper::pass(), printDefault_(), edm::DocFormatHelper::setAtLeast1(), edm::DocFormatHelper::setAtLeast2(), edm::DocFormatHelper::setAtLeast3(), findQualityFiles::size, edm::DocFormatHelper::startColumn2(), type(), mitigatedMETSequence_cff::U, and edm::DocFormatHelper::wrapAndPrintText().

Referenced by parameterSetDescription().

144  {
145  if (dfh.pass() == 0) {
146  dfh.setAtLeast1(label().size());
147  if (isTracked()) {
148  dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
149  } else {
150  dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
151  }
152  if (optional) {
153  dfh.setAtLeast3(8U);
154  }
155  } else {
156  if (dfh.brief()) {
157  std::ios::fmtflags oldFlags = os.flags();
158 
159  dfh.indent(os);
160  os << std::left << std::setw(dfh.column1()) << label() << " ";
161 
162  if (isTracked()) {
163  os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
164  } else {
165  std::stringstream ss;
166  ss << "untracked ";
168  os << std::setw(dfh.column2()) << ss.str();
169  }
170  os << " ";
171 
172  os << std::setw(dfh.column3());
173  if (optional) {
174  os << "optional";
175  } else {
176  os << "";
177  }
178  os << " ";
179  os.flags(oldFlags);
180  printDefault_(os, writeToCfi, dfh);
181  } else {
182  // not brief
183  dfh.indent(os);
184  os << label() << "\n";
185 
186  dfh.indent2(os);
187  os << "type: ";
188  if (!isTracked())
189  os << "untracked ";
190 
191  os << parameterTypeEnumToString(type()) << " ";
192 
193  if (optional)
194  os << "optional";
195  os << "\n";
196 
197  dfh.indent2(os);
198  printDefault_(os, writeToCfi, dfh);
199 
200  if (!comment().empty()) {
201  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
202  }
203  os << "\n";
204  }
205  }
206  }
size
Write out results.
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
virtual void printDefault_(std::ostream &os, bool writeToCfi, DocFormatHelper &dfh) const
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & comment() const
std::string const & label() const
void ParameterDescriptionBase::printDefault_ ( std::ostream &  os,
bool  writeToCfi,
DocFormatHelper dfh 
) const
privatevirtual

Reimplemented in edm::ParameterDescription< std::vector< ParameterSet > >, and edm::ParameterDescription< ParameterSetDescription >.

Definition at line 208 of file ParameterDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), hasDefault(), edm::ParameterDescriptionNode::hasNestedContent(), edm::DocFormatHelper::indentation(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and writeDoc_().

Referenced by parameterSetDescription(), and print_().

208  {
209  if (!dfh.brief())
210  os << "default: ";
211  if (writeToCfi && hasDefault()) {
212  if (hasNestedContent()) {
213  os << "see Section " << dfh.section() << "." << dfh.counter();
214  } else {
215  if (dfh.brief()) {
216  writeDoc_(os, dfh.indentation());
217  } else {
218  writeDoc_(os, dfh.startColumn2());
219  }
220  }
221  } else {
222  os << "none (do not write to cfi)";
223  }
224  os << "\n";
225  }
virtual void writeDoc_(std::ostream &os, int indentation) const =0
void ParameterDescriptionBase::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 227 of file ParameterDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::indentation(), label(), edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::TOP, and writeDoc_().

Referenced by parameterSetDescription().

227  {
228  int indentation = dfh.indentation();
229  if (dfh.parent() != DocFormatHelper::TOP) {
230  indentation -= DocFormatHelper::offsetSectionContent();
231  }
232 
233  printSpaces(os, indentation);
234  os << "Section " << dfh.section() << "." << dfh.counter() << " " << label() << " default contents: ";
235  writeDoc_(os, indentation + 2);
236  os << "\n";
237  if (!dfh.brief())
238  os << "\n";
239  }
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
virtual void writeDoc_(std::ostream &os, int indentation) const =0
std::string const & label() const
void ParameterDescriptionBase::throwMissingRequiredNoDefault ( ) const
protected

Definition at line 79 of file ParameterDescriptionBase.cc.

References edm::errors::Configuration, Exception, isTracked(), label(), edm::parameterTypeEnumToString(), AlCaHLTBitMon_QueryRunRegistry::string, and type().

Referenced by parameterSetDescription(), validate_(), and edm::ParameterDescription< std::vector< ParameterSet > >::validate_().

79  {
80  std::string tr("untracked");
81  if (isTracked())
82  tr = "tracked";
83 
85  << "Missing required parameter. It should have label \"" << label() << "\" and have type \"" << tr << " "
86  << parameterTypeEnumToString(type()) << "\".\n"
87  << "The description has no default. The parameter must be defined "
88  "in the configuration\n";
89  }
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & label() const
void ParameterDescriptionBase::throwParameterWrongTrackiness ( ) const
protected

Definition at line 52 of file ParameterDescriptionBase.cc.

References edm::errors::Configuration, Exception, isTracked(), label(), edm::parameterTypeEnumToString(), AlCaHLTBitMon_QueryRunRegistry::string, and type().

Referenced by parameterSetDescription(), validate_(), edm::ParameterDescription< ParameterSetDescription >::validate_(), and edm::ParameterDescription< std::vector< ParameterSet > >::validate_().

52  {
53  std::string tr("a tracked");
54  std::string shouldBe("untracked");
55  if (isTracked()) {
56  tr = "an untracked";
57  shouldBe = "tracked";
58  }
59 
60  throw Exception(errors::Configuration) << "In the configuration, parameter \"" << label()
61  << "\" is defined "
62  "as "
63  << tr << " " << parameterTypeEnumToString(type()) << ".\n"
64  << "It should be " << shouldBe << ".\n";
65  }
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & label() const
void ParameterDescriptionBase::throwParameterWrongType ( ) const
protected

Definition at line 67 of file ParameterDescriptionBase.cc.

References edm::errors::Configuration, Exception, isTracked(), label(), edm::parameterTypeEnumToString(), AlCaHLTBitMon_QueryRunRegistry::string, and type().

Referenced by parameterSetDescription(), validate_(), edm::ParameterDescription< ParameterSetDescription >::validate_(), and edm::ParameterDescription< std::vector< ParameterSet > >::validate_().

67  {
68  std::string tr("an untracked");
69  if (isTracked())
70  tr = "a tracked";
71 
72  throw Exception(errors::Configuration) << "Parameter \"" << label()
73  << "\" should be defined "
74  "as "
75  << tr << " " << parameterTypeEnumToString(type()) << ".\n"
76  << "The type in the configuration is incorrect.\n";
77  }
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & label() const
ParameterTypes edm::ParameterDescriptionBase::type ( ) const
inline
void ParameterDescriptionBase::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 98 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists(), edm::ParameterSet::exists(), exists_(), hasDefault(), insertDefault_(), isTracked(), label(), throwMissingRequiredNoDefault(), throwParameterWrongTrackiness(), and throwParameterWrongType().

Referenced by parameterSetDescription().

100  {
101  bool exists = exists_(pset, isTracked());
102 
103  if (exists) {
104  validatedLabels.insert(label());
105  } else if (exists_(pset, !isTracked())) {
107  } else if (pset.exists(label())) {
109  }
110 
111  if (!exists && !optional) {
112  if (hasDefault()) {
113  insertDefault_(pset);
114  validatedLabels.insert(label());
115  } else {
117  }
118  }
119  }
virtual bool exists_(ParameterSet const &pset, bool isTracked) const =0
bool exists(ParameterSet const &pset) const
virtual void insertDefault_(ParameterSet &pset) const =0
std::string const & label() const
void ParameterDescriptionBase::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 121 of file ParameterDescriptionBase.cc.

References hasDefault(), isTracked(), label(), edm::parameterTypeEnumToString(), edm::ParameterDescriptionNode::printSpaces(), and type().

Referenced by parameterSetDescription().

124  {
125  if (!hasDefault())
126  return;
127 
128  wroteSomething = true;
129  if (startWithComma)
130  os << ",";
131  startWithComma = true;
132 
133  os << "\n";
134  printSpaces(os, indentation);
135 
136  os << label() << " = cms.";
137  if (!isTracked())
138  os << "untracked.";
139  os << parameterTypeEnumToString(type()) << "(";
140  writeCfi_(os, indentation);
141  os << ")";
142  }
void writeCfi_(std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const override
std::string parameterTypeEnumToString(ParameterTypes iType)
static void printSpaces(std::ostream &os, int n)
std::string const & label() const
virtual void edm::ParameterDescriptionBase::writeCfi_ ( std::ostream &  os,
int  indentation 
) const
privatepure virtual
virtual void edm::ParameterDescriptionBase::writeDoc_ ( std::ostream &  os,
int  indentation 
) const
privatepure virtual

Member Data Documentation

bool edm::ParameterDescriptionBase::hasDefault_
private

Definition at line 87 of file ParameterDescriptionBase.h.

Referenced by hasDefault().

bool edm::ParameterDescriptionBase::isTracked_
private

Definition at line 86 of file ParameterDescriptionBase.h.

Referenced by isTracked().

std::string edm::ParameterDescriptionBase::label_
private
ParameterTypes edm::ParameterDescriptionBase::type_
private