CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::ParameterWildcardBase Class Reference

#include <ParameterWildcardBase.h>

Inheritance diagram for edm::ParameterWildcardBase:
edm::ParameterDescriptionNode edm::ParameterWildcard< T > edm::ParameterWildcard< ParameterSetDescription > edm::ParameterWildcard< std::vector< ParameterSet > > edm::ParameterWildcardWithSpecifics

Public Member Functions

WildcardValidationCriteria criteria () const
 
bool isTracked () const
 
ParameterTypes type () const
 
 ~ParameterWildcardBase () 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 optional, bool &startWithComma, int indentation, bool &wroteSomething) const
 
virtual ~ParameterDescriptionNode ()
 

Protected Member Functions

 ParameterWildcardBase (ParameterTypes iType, bool isTracked, WildcardValidationCriteria criteria)
 
void throwIfInvalidPattern (char const *pattern) const
 
void throwIfInvalidPattern (std::string const &pattern) const
 
void validateMatchingNames (std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const
 
- Protected Member Functions inherited from edm::ParameterDescriptionNode
virtual bool exists_ (ParameterSet const &pset) const =0
 
virtual bool hasNestedContent_ () const
 
virtual void printNestedContent_ (std::ostream &, bool, DocFormatHelper &) const
 
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const =0
 

Private Member Functions

void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
 
int howManyXORSubNodesExist_ (ParameterSet const &pset) const override
 
bool partiallyExists_ (ParameterSet const &pset) const override
 
void print_ (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const override
 
void writeCfi_ (std::ostream &os, bool optional, bool &startWithComma, int indentation, bool &wroteSomething) const override
 

Private Attributes

WildcardValidationCriteria criteria_
 
bool isTracked_
 
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 19 of file ParameterWildcardBase.h.

Constructor & Destructor Documentation

◆ ~ParameterWildcardBase()

edm::ParameterWildcardBase::~ParameterWildcardBase ( )
override

Definition at line 13 of file ParameterWildcardBase.cc.

13 {}

◆ ParameterWildcardBase()

edm::ParameterWildcardBase::ParameterWildcardBase ( ParameterTypes  iType,
bool  isTracked,
WildcardValidationCriteria  criteria 
)
protected

Definition at line 15 of file ParameterWildcardBase.cc.

Member Function Documentation

◆ checkAndGetLabelsAndTypes_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 58 of file ParameterWildcardBase.cc.

References type().

60  {
61  wildcardTypes.insert(type());
62  }
ParameterTypes type() const

◆ criteria()

WildcardValidationCriteria edm::ParameterWildcardBase::criteria ( ) const
inline

◆ howManyXORSubNodesExist_()

int edm::ParameterWildcardBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 157 of file ParameterWildcardBase.cc.

References edm::ParameterDescriptionNode::exists(), and muonDTDigis_cfi::pset.

157 { return exists(pset) ? 1 : 0; }
bool exists(ParameterSet const &pset) const

◆ isTracked()

bool edm::ParameterWildcardBase::isTracked ( ) const
inline

Definition at line 24 of file ParameterWildcardBase.h.

References isTracked_.

Referenced by Types.PSet::clone(), Mixins._ParameterTypeBase::configTypeName(), edm::ParameterWildcardWithSpecifics::exists_(), edm::ParameterWildcard< T >::exists_(), edm::ParameterWildcard< ParameterSetDescription >::exists_(), Mixins.UsingBlock::insertInto(), Types.int32::insertInto(), Types.uint32::insertInto(), Types.int64::insertInto(), Types.uint64::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(), edm::ParameterWildcardWithSpecifics::validate_(), edm::ParameterWildcard< T >::validate_(), and edm::ParameterWildcard< ParameterSetDescription >::validate_().

◆ partiallyExists_()

bool edm::ParameterWildcardBase::partiallyExists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

◆ print_()

void edm::ParameterWildcardBase::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 64 of file ParameterWildcardBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::column1(), edm::DocFormatHelper::column2(), edm::DocFormatHelper::column3(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), criteria(), relativeConstraints::empty, edm::ParameterDescriptionNode::hasNestedContent(), edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), isTracked(), Types::optional, edm::parameterTypeEnumToString(), edm::DocFormatHelper::pass(), edm::RequireAtLeastOne, edm::RequireExactlyOne, edm::RequireZeroOrMore, edm::DocFormatHelper::section(), edm::DocFormatHelper::setAtLeast1(), edm::DocFormatHelper::setAtLeast2(), edm::DocFormatHelper::setAtLeast3(), contentValuesCheck::ss, edm::DocFormatHelper::startColumn2(), type(), mitigatedMETSequence_cff::U, and edm::DocFormatHelper::wrapAndPrintText().

64  {
65  if (dfh.pass() == 0) {
66  dfh.setAtLeast1(11U);
67  if (isTracked()) {
68  dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
69  } else {
70  dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
71  }
72  dfh.setAtLeast3(8U);
73  } else {
74  if (dfh.brief()) {
75  dfh.indent(os);
76  std::ios::fmtflags oldFlags = os.flags();
77  os << std::left << std::setw(dfh.column1()) << "wildcard: *"
78  << " ";
79 
80  if (isTracked()) {
81  os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
82  } else {
83  std::stringstream ss;
84  ss << "untracked " << parameterTypeEnumToString(type());
85  os << ss.str();
86  }
87 
88  os << " ";
89  os << std::setw(dfh.column3());
90  if (optional)
91  os << "optional";
92  else
93  os << "";
94 
95  if (criteria() == RequireZeroOrMore) {
96  os << " (require zero or more)";
97  } else if (criteria() == RequireAtLeastOne) {
98  os << " (require at least one)";
99  } else if (criteria() == RequireExactlyOne) {
100  os << " (require exactly one)";
101  }
102  os << "\n";
103  if (hasNestedContent()) {
104  dfh.indent(os);
105  os << " (see Section " << dfh.section() << "." << dfh.counter() << ")\n";
106  }
107  os.flags(oldFlags);
108  } else {
109  // not brief
110 
111  dfh.indent(os);
112  os << "labels must match this wildcard pattern: *\n";
113 
114  dfh.indent2(os);
115  os << "type: ";
116  if (isTracked()) {
118  } else {
119  os << "untracked " << parameterTypeEnumToString(type());
120  }
121 
122  if (optional)
123  os << " optional";
124  os << "\n";
125 
126  dfh.indent2(os);
127  os << "criteria: ";
128  if (criteria() == RequireZeroOrMore)
129  os << "require zero or more";
130  else if (criteria() == RequireAtLeastOne)
131  os << "require at least one";
132  else if (criteria() == RequireExactlyOne)
133  os << "require exactly one";
134  os << "\n";
135 
136  if (hasNestedContent()) {
137  dfh.indent2(os);
138  os << "(see Section " << dfh.section() << "." << dfh.counter() << ")\n";
139  }
140 
141  if (!comment().empty()) {
142  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
143  }
144  os << "\n";
145  }
146  }
147  }
size
Write out results.
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
std::string parameterTypeEnumToString(ParameterTypes iType)
optional
Definition: Types.py:239
ParameterTypes type() const
WildcardValidationCriteria criteria() const
std::string const & comment() const

◆ throwIfInvalidPattern() [1/2]

void edm::ParameterWildcardBase::throwIfInvalidPattern ( char const *  pattern) const
protected

◆ throwIfInvalidPattern() [2/2]

void edm::ParameterWildcardBase::throwIfInvalidPattern ( std::string const &  pattern) const
protected

Definition at line 25 of file ParameterWildcardBase.cc.

References edm::errors::Configuration, Exception, edm::parameterTypeEnumToString(), topSingleLeptonDQM_PU_cfi::pattern, AlCaHLTBitMon_QueryRunRegistry::string, and type().

25  {
26  if (pattern != std::string("*")) {
28  << "Currently, the only supported wildcard in ParameterSetDescriptions\n"
29  << "is the single character \"*\". The configuration contains a wildcard\n"
30  << "with pattern \"" << pattern << "\" and type \"" << parameterTypeEnumToString(type()) << "\"\n"
31  << "At some future date, globbing or regular expression support may be added\n"
32  << "if there are any requests for it from users.\n";
33  }
34  }
std::string parameterTypeEnumToString(ParameterTypes iType)
ParameterTypes type() const

◆ type()

ParameterTypes edm::ParameterWildcardBase::type ( ) const
inline

Definition at line 23 of file ParameterWildcardBase.h.

References type_.

Referenced by checkAndGetLabelsAndTypes_(), print_(), throwIfInvalidPattern(), and validateMatchingNames().

23 { return type_; }

◆ validateMatchingNames()

void edm::ParameterWildcardBase::validateMatchingNames ( std::vector< std::string > const &  matchingNames,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
protected

Definition at line 36 of file ParameterWildcardBase.cc.

References edm::errors::Configuration, criteria_, Exception, Types::optional, edm::parameterTypeEnumToString(), edm::RequireAtLeastOne, edm::RequireExactlyOne, edm::RequireZeroOrMore, type(), and mitigatedMETSequence_cff::U.

Referenced by edm::ParameterWildcardWithSpecifics::validate_(), edm::ParameterWildcard< T >::validate_(), and edm::ParameterWildcard< ParameterSetDescription >::validate_().

38  {
39  validatedLabels.insert(matchingNames.begin(), matchingNames.end());
41  return;
42  if (criteria_ == RequireAtLeastOne && matchingNames.empty() && !optional) {
44  << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires "
45  << "at least one match\n"
46  << "and there are no parameters in the configuration matching\n"
47  << "that type.\n";
48  } else if (criteria_ == RequireExactlyOne) {
49  if ((matchingNames.empty() && !optional) || matchingNames.size() > 1U) {
51  << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires\n"
52  << "exactly one match and there are " << matchingNames.size() << " matching parameters\n"
53  << "in the configuration.\n";
54  }
55  }
56  }
std::string parameterTypeEnumToString(ParameterTypes iType)
WildcardValidationCriteria criteria_
optional
Definition: Types.py:239
ParameterTypes type() const

◆ writeCfi_()

void edm::ParameterWildcardBase::writeCfi_ ( std::ostream &  os,
bool  optional,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 149 of file ParameterWildcardBase.cc.

150  {
151  // Until we implement default labels and values there is nothing
152  // to do here.
153  }

Member Data Documentation

◆ criteria_

WildcardValidationCriteria edm::ParameterWildcardBase::criteria_
private

Definition at line 53 of file ParameterWildcardBase.h.

Referenced by criteria(), and validateMatchingNames().

◆ isTracked_

bool edm::ParameterWildcardBase::isTracked_
private

Definition at line 52 of file ParameterWildcardBase.h.

Referenced by isTracked().

◆ type_

ParameterTypes edm::ParameterWildcardBase::type_
private