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 > >

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 (char const *value)
 
void setComment (std::string 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.

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

References type().

◆ 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.

157 { return exists(pset) ? 1 : 0; }

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

◆ isTracked()

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

◆ 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.

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  }

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(), findQualityFiles::size, contentValuesCheck::ss, edm::DocFormatHelper::startColumn2(), type(), mitigatedMETSequence_cff::U, and edm::DocFormatHelper::wrapAndPrintText().

◆ 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.

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  }

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

◆ type()

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

Definition at line 23 of file ParameterWildcardBase.h.

23 { return type_; }

References type_.

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

◆ 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.

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  }

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

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

◆ 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
edm::ParameterWildcardBase::throwIfInvalidPattern
void throwIfInvalidPattern(char const *pattern) const
Definition: ParameterWildcardBase.cc:20
edm::ParameterDescriptionNode::exists
bool exists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:134
Types.optional
optional
Definition: Types.py:167
edm::ParameterWildcardBase::isTracked_
bool isTracked_
Definition: ParameterWildcardBase.h:52
edm::parameterTypeEnumToString
std::string parameterTypeEnumToString(ParameterTypes iType)
Definition: ParameterDescriptionNode.cc:64
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::RequireAtLeastOne
Definition: ParameterWildcardBase.h:17
edm::ParameterWildcardBase::isTracked
bool isTracked() const
Definition: ParameterWildcardBase.h:24
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::RequireExactlyOne
Definition: ParameterWildcardBase.h:17
edm::DocFormatHelper::wrapAndPrintText
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
Definition: DocFormatHelper.cc:97
edm::ParameterDescriptionNode::hasNestedContent
bool hasNestedContent() const
Definition: ParameterDescriptionNode.h:123
topSingleLeptonDQM_PU_cfi.pattern
pattern
Definition: topSingleLeptonDQM_PU_cfi.py:39
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
edm::ParameterDescriptionNode::comment
std::string const & comment() const
Definition: ParameterDescriptionNode.h:92
edm::ParameterWildcardBase::criteria
WildcardValidationCriteria criteria() const
Definition: ParameterWildcardBase.h:25
edm::ParameterWildcardBase::criteria_
WildcardValidationCriteria criteria_
Definition: ParameterWildcardBase.h:53
edm::RequireZeroOrMore
Definition: ParameterWildcardBase.h:17
edm::errors::Configuration
Definition: EDMException.h:36
edm::ParameterWildcardBase::type
ParameterTypes type() const
Definition: ParameterWildcardBase.h:23
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::ParameterWildcardBase::type_
ParameterTypes type_
Definition: ParameterWildcardBase.h:51
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443