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 58 of file ParameterDescriptionBase.cc.

58 { }
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().

29  :ParameterDescriptionNode(iComment),
30  label_(iLabel),
31  type_(iType),
34  if(label_.empty()) {
36  << "Empty string used as a label for a parameter. This is\n"
37  "not allowed.\n";
38  }
39  }
ParameterDescriptionBase::ParameterDescriptionBase ( char const *  iLabel,
ParameterTypes  iType,
bool  isTracked,
bool  hasDefault,
Comment const &  iComment 
)
protected

Definition at line 41 of file ParameterDescriptionBase.cc.

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

46  :ParameterDescriptionNode(iComment),
47  label_(iLabel),
48  type_(iType),
51  if(label_.empty()) {
53  << "Empty string used as a label for a parameter. This is\n"
54  "not allowed.\n";
55  }
56  }

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 102 of file ParameterDescriptionBase.cc.

References label(), type(), and validate_().

Referenced by parameterSetDescription(), and throwMissingRequiredNoDefault().

104  {
105  usedLabels.insert(label());
106  parameterTypes.insert(type());
107  }
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 280 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by parameterSetDescription(), and partiallyExists_().

280  {
281  return exists(pset) ? 1 : 0;
282  }
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 40 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
void ParameterDescriptionBase::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 162 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(), and writeCfi_().

165  {
166  if(dfh.pass() == 0) {
167  dfh.setAtLeast1(label().size());
168  if(isTracked()) {
169  dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
170  } else {
171  dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
172  }
173  if(optional) {
174  dfh.setAtLeast3(8U);
175  }
176  } else {
177 
178  if(dfh.brief()) {
179  std::ios::fmtflags oldFlags = os.flags();
180 
181  dfh.indent(os);
182  os << std::left << std::setw(dfh.column1()) << label() << " ";
183 
184  if(isTracked()) {
185  os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
186  } else {
187  std::stringstream ss;
188  ss << "untracked ";
190  os << std::setw(dfh.column2()) << ss.str();
191  }
192  os << " ";
193 
194  os << std::setw(dfh.column3());
195  if(optional) {
196  os << "optional";
197  } else {
198  os << "";
199  }
200  os << " ";
201  os.flags(oldFlags);
202  printDefault_(os, writeToCfi, dfh);
203  } else {
204  // not brief
205  dfh.indent(os);
206  os << label() << "\n";
207 
208  dfh.indent2(os);
209  os << "type: ";
210  if(!isTracked()) os << "untracked ";
211 
212  os << parameterTypeEnumToString(type()) << " ";
213 
214  if(optional) os << "optional";
215  os << "\n";
216 
217  dfh.indent2(os);
218  printDefault_(os, writeToCfi, dfh);
219 
220  if(!comment().empty()) {
222  comment(),
223  dfh.startColumn2(),
224  dfh.commentWidth());
225  }
226  os << "\n";
227  }
228  }
229  }
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 233 of file ParameterDescriptionBase.cc.

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

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

235  {
236  if(!dfh.brief()) os << "default: ";
237  if(writeToCfi && hasDefault()) {
238  if(hasNestedContent()) {
239  os << "see Section " << dfh.section()
240  << "." << dfh.counter();
241  } else {
242  if(dfh.brief()) {
243  writeDoc_(os, dfh.indentation());
244  } else {
245  writeDoc_(os, dfh.startColumn2());
246  }
247  }
248  } else {
249  os << "none (do not write to cfi)";
250  }
251  os << "\n";
252  }
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 256 of file ParameterDescriptionBase.cc.

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

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

258  {
259  int indentation = dfh.indentation();
260  if(dfh.parent() != DocFormatHelper::TOP) {
261  indentation -= DocFormatHelper::offsetSectionContent();
262  }
263 
264  printSpaces(os, indentation);
265  os << "Section " << dfh.section() << "." << dfh.counter()
266  << " " << label() << " default contents: ";
267  writeDoc_(os, indentation + 2);
268  os << "\n";
269  if(!dfh.brief()) os << "\n";
270  }
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 87 of file ParameterDescriptionBase.cc.

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

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

87  {
88 
89  std::string tr("untracked");
90  if(isTracked()) tr = "tracked";
91 
93  << "Missing required parameter. It should have label \""
94  << label() << "\" and have type \""
95  << tr << " " << parameterTypeEnumToString(type()) << "\".\n"
96  << "The description has no default. The parameter must be defined "
97  "in the configuration\n";
98  }
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & label() const
void ParameterDescriptionBase::throwParameterWrongTrackiness ( ) const
protected

Definition at line 61 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_().

61  {
62  std::string tr("a tracked");
63  std::string shouldBe("untracked");
64  if(isTracked()) {
65  tr = "an untracked";
66  shouldBe = "tracked";
67  }
68 
70  << "In the configuration, parameter \"" << label() << "\" is defined "
71  "as " << tr << " " << parameterTypeEnumToString(type()) << ".\n"
72  << "It should be " << shouldBe << ".\n";
73  }
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & label() const
void ParameterDescriptionBase::throwParameterWrongType ( ) const
protected

Definition at line 76 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_().

76  {
77  std::string tr("an untracked");
78  if(isTracked()) tr = "a tracked";
79 
81  << "Parameter \"" << label() << "\" should be defined "
82  "as " << tr << " " << parameterTypeEnumToString(type()) << ".\n"
83  << "The type in the configuration is incorrect.\n";
84  }
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 111 of file ParameterDescriptionBase.cc.

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

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

113  {
114 
115  bool exists = exists_(pset, isTracked());
116 
117  if(exists) {
118  validatedLabels.insert(label());
119  } else if(exists_(pset, !isTracked())) {
121  } else if(pset.exists(label())) {
123  }
124 
125  if(!exists && !optional) {
126  if(hasDefault()) {
127  insertDefault_(pset);
128  validatedLabels.insert(label());
129  } else {
131  }
132  }
133  }
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 137 of file ParameterDescriptionBase.cc.

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

Referenced by parameterSetDescription(), and validate_().

140  {
141 
142  if(!hasDefault()) return;
143 
144  wroteSomething = true;
145  if(startWithComma) os << ",";
146  startWithComma = true;
147 
148  os << "\n";
149  printSpaces(os, indentation);
150 
151  os << label()
152  << " = cms.";
153  if(!isTracked()) os << "untracked.";
155  << "(";
156  writeCfi_(os, indentation);
157  os << ")";
158  }
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 109 of file ParameterDescriptionBase.h.

Referenced by hasDefault().

bool edm::ParameterDescriptionBase::isTracked_
private

Definition at line 108 of file ParameterDescriptionBase.h.

Referenced by isTracked().

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