CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
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
 
virtual ParameterDescriptionNodeclone () const =0
 
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 ()
 

Protected Member Functions

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

Private Member Functions

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

Definition at line 54 of file ParameterDescriptionBase.cc.

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

Definition at line 24 of file ParameterDescriptionBase.cc.

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

28  :label_(iLabel),
29  type_(iType),
32  if(label_.empty()) {
34  << "Empty string used as a label for a parameter. This is\n"
35  "not allowed.\n";
36  }
37  }
ParameterDescriptionBase::ParameterDescriptionBase ( char const *  iLabel,
ParameterTypes  iType,
bool  isTracked,
bool  hasDefault 
)
protected

Definition at line 39 of file ParameterDescriptionBase.cc.

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

43  :label_(iLabel),
44  type_(iType),
47  if(label_.empty()) {
49  << "Empty string used as a label for a parameter. This is\n"
50  "not allowed.\n";
51  }
52  }

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 98 of file ParameterDescriptionBase.cc.

References label(), and type().

100  {
101  usedLabels.insert(label());
102  parameterTypes.insert(type());
103  }
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
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 276 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

276  {
277  return exists(pset) ? 1 : 0;
278  }
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< std::vector< std::string > >::exists_(), edm::ParameterDescription< ParameterSetDescription >::exists_(), edm::ParameterDescription< std::vector< std::string > >::insertDefault_(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::insertInto(), Mixins.UsingBlock::insertInto(), Types.double::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(), print_(), Mixins._ParameterTypeBase::pythonTypeName(), throwMissingRequiredNoDefault(), throwParameterWrongTrackiness(), throwParameterWrongType(), validate_(), edm::ParameterDescription< ParameterSetDescription >::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
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 270 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

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

Reimplemented from edm::ParameterDescriptionNode.

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

161  {
162  if(dfh.pass() == 0) {
163  dfh.setAtLeast1(label().size());
164  if(isTracked()) {
165  dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
166  } else {
167  dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
168  }
169  if(optional) {
170  dfh.setAtLeast3(8U);
171  }
172  } else {
173 
174  if(dfh.brief()) {
175  std::ios::fmtflags oldFlags = os.flags();
176 
177  dfh.indent(os);
178  os << std::left << std::setw(dfh.column1()) << label() << " ";
179 
180  if(isTracked()) {
181  os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
182  } else {
183  std::stringstream ss;
184  ss << "untracked ";
186  os << std::setw(dfh.column2()) << ss.str();
187  }
188  os << " ";
189 
190  os << std::setw(dfh.column3());
191  if(optional) {
192  os << "optional";
193  } else {
194  os << "";
195  }
196  os << " ";
197  os.flags(oldFlags);
198  printDefault_(os, writeToCfi, dfh);
199  } else {
200  // not brief
201  dfh.indent(os);
202  os << label() << "\n";
203 
204  dfh.indent2(os);
205  os << "type: ";
206  if(!isTracked()) os << "untracked ";
207 
208  os << parameterTypeEnumToString(type()) << " ";
209 
210  if(optional) os << "optional";
211  os << "\n";
212 
213  dfh.indent2(os);
214  printDefault_(os, writeToCfi, dfh);
215 
216  if(!comment().empty()) {
218  comment(),
219  dfh.startColumn2(),
220  dfh.commentWidth());
221  }
222  os << "\n";
223  }
224  }
225  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
std::string parameterTypeEnumToString(ParameterTypes iType)
virtual void printDefault_(std::ostream &os, bool writeToCfi, DocFormatHelper &dfh)
std::string const & comment() const
tuple size
Write out results.
std::string const & label() const
void ParameterDescriptionBase::printDefault_ ( std::ostream &  os,
bool  writeToCfi,
DocFormatHelper dfh 
)
privatevirtual

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

Definition at line 229 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 print_().

231  {
232  if(!dfh.brief()) os << "default: ";
233  if(writeToCfi && hasDefault()) {
234  if(hasNestedContent()) {
235  os << "see Section " << dfh.section()
236  << "." << dfh.counter();
237  } else {
238  if(dfh.brief()) {
239  writeDoc_(os, dfh.indentation());
240  } else {
241  writeDoc_(os, dfh.startColumn2());
242  }
243  }
244  } else {
245  os << "none (do not write to cfi)";
246  }
247  os << "\n";
248  }
virtual void writeDoc_(std::ostream &os, int indentation) const =0
void ParameterDescriptionBase::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

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

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

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

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

Referenced by validate_().

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

Definition at line 57 of file ParameterDescriptionBase.cc.

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

Referenced by validate_(), and edm::ParameterDescription< ParameterSetDescription >::validate_().

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

Definition at line 72 of file ParameterDescriptionBase.cc.

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

Referenced by validate_(), and edm::ParameterDescription< ParameterSetDescription >::validate_().

72  {
73  std::string tr("an untracked");
74  if(isTracked()) tr = "a tracked";
75 
77  << "Parameter \"" << label() << "\" should be defined "
78  "as " << tr << " " << parameterTypeEnumToString(type()) << ".\n"
79  << "The type in the configuration is incorrect.\n";
80  }
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
privatevirtual

Implements edm::ParameterDescriptionNode.

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

Definition at line 107 of file ParameterDescriptionBase.cc.

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

109  {
110 
111  bool exists = exists_(pset, isTracked());
112 
113  if(exists) {
114  validatedLabels.insert(label());
115  } else if(exists_(pset, !isTracked())) {
117  } else if(pset.exists(label())) {
119  }
120 
121  if(!exists && !optional) {
122  if(hasDefault()) {
123  insertDefault_(pset);
124  validatedLabels.insert(label());
125  } else {
127  }
128  }
129  }
bool exists(ParameterSet const &pset) const
virtual bool exists_(ParameterSet const &pset, bool isTracked) const =0
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
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 133 of file ParameterDescriptionBase.cc.

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

136  {
137 
138  if(!hasDefault()) return;
139 
140  wroteSomething = true;
141  if(startWithComma) os << ",";
142  startWithComma = true;
143 
144  os << "\n";
145  printSpaces(os, indentation);
146 
147  os << label()
148  << " = cms.";
149  if(!isTracked()) os << "untracked.";
151  << "(";
152  writeCfi_(os, indentation);
153  os << ")";
154  }
std::string parameterTypeEnumToString(ParameterTypes iType)
static void printSpaces(std::ostream &os, int n)
virtual void writeCfi_(std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const
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 106 of file ParameterDescriptionBase.h.

Referenced by hasDefault().

bool edm::ParameterDescriptionBase::isTracked_
private

Definition at line 105 of file ParameterDescriptionBase.h.

Referenced by isTracked().

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