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::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
 
virtual ~ParameterWildcardBase ()
 
- 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

 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_ ()
 
virtual void printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh)
 
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const =0
 

Private Member Functions

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

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 24 of file ParameterWildcardBase.h.

Constructor & Destructor Documentation

edm::ParameterWildcardBase::~ParameterWildcardBase ( )
virtual

Definition at line 12 of file ParameterWildcardBase.cc.

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

Definition at line 14 of file ParameterWildcardBase.cc.

17  :type_(iType),
20  { }
WildcardValidationCriteria criteria_
WildcardValidationCriteria criteria() const

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 69 of file ParameterWildcardBase.cc.

References type().

71  {
72  wildcardTypes.insert(type());
73  }
ParameterTypes type() const
WildcardValidationCriteria edm::ParameterWildcardBase::criteria ( ) const
inline
int edm::ParameterWildcardBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 191 of file ParameterWildcardBase.cc.

References edm::ParameterDescriptionNode::exists().

191  {
192  return exists(pset) ? 1 : 0;
193  }
bool exists(ParameterSet const &pset) const
bool edm::ParameterWildcardBase::isTracked ( ) const
inline
bool edm::ParameterWildcardBase::partiallyExists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 185 of file ParameterWildcardBase.cc.

References edm::ParameterDescriptionNode::exists().

185  {
186  return exists(pset);
187  }
bool exists(ParameterSet const &pset) const
void edm::ParameterWildcardBase::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

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

81  {
82  if (dfh.pass() == 0) {
83  dfh.setAtLeast1(11U);
84  if (isTracked()) {
85  dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
86  }
87  else {
88  dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
89  }
90  dfh.setAtLeast3(8U);
91  }
92  else {
93 
94  if (dfh.brief()) {
95 
96  dfh.indent(os);
97  std::ios::fmtflags oldFlags = os.flags();
98  os << std::left << std::setw(dfh.column1()) << "wildcard: *" << " ";
99 
100  if (isTracked()) {
101  os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
102  }
103  else {
104  std::stringstream ss;
105  ss << "untracked " << parameterTypeEnumToString(type());
106  os << ss.str();
107  }
108 
109  os << " ";
110  os << std::setw(dfh.column3());
111  if (optional) os << "optional";
112  else os << "";
113 
114  if (criteria() == RequireZeroOrMore) {
115  os << " (require zero or more)";
116  }
117  else if (criteria() == RequireAtLeastOne) {
118  os << " (require at least one)";
119  }
120  else if (criteria() == RequireExactlyOne) {
121  os << " (require exactly one)";
122  }
123  os << "\n";
124  if (hasNestedContent()) {
125  dfh.indent(os);
126  os << " (see Section " << dfh.section()
127  << "." << dfh.counter() << ")\n";
128  }
129  os.flags(oldFlags);
130  }
131  // not brief
132  else {
133 
134  dfh.indent(os);
135  os << "labels must match this wildcard pattern: *\n";
136 
137  dfh.indent2(os);
138  os << "type: ";
139  if (isTracked()) {
141  }
142  else {
143  os << "untracked " << parameterTypeEnumToString(type());
144  }
145 
146  if (optional) os << " optional";
147  os << "\n";
148 
149  dfh.indent2(os);
150  os << "criteria: ";
151  if (criteria() == RequireZeroOrMore) os << "require zero or more";
152  else if (criteria() == RequireAtLeastOne) os << "require at least one";
153  else if (criteria() == RequireExactlyOne) os << "require exactly one";
154  os << "\n";
155 
156  if (hasNestedContent()) {
157  dfh.indent2(os);
158  os << "(see Section " << dfh.section()
159  << "." << dfh.counter() << ")\n";
160  }
161 
162  if (!comment().empty()) {
164  comment(),
165  dfh.startColumn2(),
166  dfh.commentWidth());
167  }
168  os << "\n";
169  }
170  }
171  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
ParameterTypes type() const
std::string parameterTypeEnumToString(ParameterTypes iType)
std::string const & comment() const
WildcardValidationCriteria criteria() const
tuple size
Write out results.
void edm::ParameterWildcardBase::throwIfInvalidPattern ( char const *  pattern) const
protected
void edm::ParameterWildcardBase::throwIfInvalidPattern ( std::string const &  pattern) const
protected

Definition at line 31 of file ParameterWildcardBase.cc.

References edm::errors::Configuration, edm::hlt::Exception, edm::parameterTypeEnumToString(), and type().

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

Definition at line 29 of file ParameterWildcardBase.h.

References type_.

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

29 { return type_; }
void edm::ParameterWildcardBase::validateMatchingNames ( std::vector< std::string > const &  matchingNames,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
protected

Definition at line 44 of file ParameterWildcardBase.cc.

References edm::errors::Configuration, criteria_, edm::hlt::Exception, edm::parameterTypeEnumToString(), edm::RequireAtLeastOne, edm::RequireExactlyOne, edm::RequireZeroOrMore, and type().

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

46  {
47  validatedLabels.insert(matchingNames.begin(), matchingNames.end());
48  if (criteria_ == RequireZeroOrMore) return;
49  if (criteria_ == RequireAtLeastOne && matchingNames.size() < 1U && !optional) {
51  << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires "
52  << "at least one match\n"
53  << "and there are no parameters in the configuration matching\n"
54  << "that type.\n";
55  }
56  else if (criteria_ == RequireExactlyOne) {
57  if ( (matchingNames.size() < 1U && !optional) ||
58  matchingNames.size() > 1U) {
60  << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires\n"
61  << "exactly one match and there are " << matchingNames.size() << " matching parameters\n"
62  << "in the configuration.\n";
63  }
64  }
65  }
ParameterTypes type() const
std::string parameterTypeEnumToString(ParameterTypes iType)
WildcardValidationCriteria criteria_
void edm::ParameterWildcardBase::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 175 of file ParameterWildcardBase.cc.

178  {
179  // Until we implement default labels and values there is nothing
180  // to do here.
181  }

Member Data Documentation

WildcardValidationCriteria edm::ParameterWildcardBase::criteria_
private

Definition at line 68 of file ParameterWildcardBase.h.

Referenced by criteria(), and validateMatchingNames().

bool edm::ParameterWildcardBase::isTracked_
private

Definition at line 67 of file ParameterWildcardBase.h.

Referenced by isTracked().

ParameterTypes edm::ParameterWildcardBase::type_
private