CMS 3D CMS Logo

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

#include <IfExistsDescription.h>

Inheritance diagram for edm::IfExistsDescription:
edm::ParameterDescriptionNode

Public Member Functions

ParameterDescriptionNodeclone () const override
 
 IfExistsDescription (ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
 
 IfExistsDescription (std::unique_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &node_right)
 
 IfExistsDescription (ParameterDescriptionNode const &node_left, std::unique_ptr< ParameterDescriptionNode > node_right)
 
 IfExistsDescription (std::unique_ptr< ParameterDescriptionNode > node_left, std::unique_ptr< ParameterDescriptionNode > node_right)
 
- Public Member Functions inherited from edm::ParameterDescriptionNode
void checkAndGetLabelsAndTypes (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
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 ()
 

Private Member Functions

void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const override
 
bool exists_ (ParameterSet const &pset) const override
 
bool hasNestedContent_ () 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 printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh) const override
 
void throwIfDuplicateLabels (std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
 
void throwIfDuplicateTypes (std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
 
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
 

Private Attributes

edm::value_ptr< ParameterDescriptionNodenode_left_
 
edm::value_ptr< ParameterDescriptionNodenode_right_
 

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 18 of file IfExistsDescription.h.

Constructor & Destructor Documentation

edm::IfExistsDescription::IfExistsDescription ( ParameterDescriptionNode const &  node_left,
ParameterDescriptionNode const &  node_right 
)

Definition at line 13 of file IfExistsDescription.cc.

Referenced by clone().

15  : node_left_(node_left.clone()), node_right_(node_right.clone()) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::IfExistsDescription::IfExistsDescription ( std::unique_ptr< ParameterDescriptionNode node_left,
ParameterDescriptionNode const &  node_right 
)

Definition at line 17 of file IfExistsDescription.cc.

19  : node_left_(std::move(node_left)), node_right_(node_right.clone()) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511
edm::IfExistsDescription::IfExistsDescription ( ParameterDescriptionNode const &  node_left,
std::unique_ptr< ParameterDescriptionNode node_right 
)

Definition at line 21 of file IfExistsDescription.cc.

23  : node_left_(node_left.clone()), node_right_(std::move(node_right)) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511
edm::IfExistsDescription::IfExistsDescription ( std::unique_ptr< ParameterDescriptionNode node_left,
std::unique_ptr< ParameterDescriptionNode node_right 
)

Definition at line 25 of file IfExistsDescription.cc.

27  : node_left_(std::move(node_left)), node_right_(std::move(node_right)) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 29 of file IfExistsDescription.cc.

References node_left_, node_right_, throwIfDuplicateLabels(), and throwIfDuplicateTypes().

Referenced by clone().

31  {
32  std::set<std::string> labelsLeft;
33  std::set<ParameterTypes> parameterTypesLeft;
34  std::set<ParameterTypes> wildcardTypesLeft;
35  node_left_->checkAndGetLabelsAndTypes(labelsLeft, parameterTypesLeft, wildcardTypesLeft);
36 
37  std::set<std::string> labelsRight;
38  std::set<ParameterTypes> parameterTypesRight;
39  std::set<ParameterTypes> wildcardTypesRight;
40  node_right_->checkAndGetLabelsAndTypes(labelsRight, parameterTypesRight, wildcardTypesRight);
41 
42  throwIfDuplicateLabels(labelsLeft, labelsRight);
43  throwIfDuplicateTypes(wildcardTypesLeft, parameterTypesRight);
44  throwIfDuplicateTypes(wildcardTypesRight, parameterTypesLeft);
45 
46  usedLabels.insert(labelsLeft.begin(), labelsLeft.end());
47  usedLabels.insert(labelsRight.begin(), labelsRight.end());
48 
49  parameterTypes.insert(parameterTypesRight.begin(), parameterTypesRight.end());
50  parameterTypes.insert(parameterTypesLeft.begin(), parameterTypesLeft.end());
51 
52  wildcardTypes.insert(wildcardTypesRight.begin(), wildcardTypesRight.end());
53  wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end());
54  }
void throwIfDuplicateLabels(std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
void throwIfDuplicateTypes(std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
ParameterDescriptionNode* edm::IfExistsDescription::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 31 of file IfExistsDescription.h.

References checkAndGetLabelsAndTypes_(), IfExistsDescription(), print_(), muonDTDigis_cfi::pset, validate_(), and writeCfi_().

31 { return new IfExistsDescription(*this); }
IfExistsDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
bool edm::IfExistsDescription::exists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 167 of file IfExistsDescription.cc.

References node_left_, and node_right_.

Referenced by hasNestedContent_().

167  {
168  bool leftExists = node_left_->exists(pset);
169  bool rightExists = node_right_->exists(pset);
170 
171  if (leftExists && rightExists)
172  return true;
173  else if (!leftExists && !rightExists)
174  return true;
175  return false;
176  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
bool edm::IfExistsDescription::hasNestedContent_ ( ) const
inlineoverrideprivatevirtual
int edm::IfExistsDescription::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 180 of file IfExistsDescription.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by hasNestedContent_().

180 { return exists(pset) ? 1 : 0; }
bool exists(ParameterSet const &pset) const
bool edm::IfExistsDescription::partiallyExists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 178 of file IfExistsDescription.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by hasNestedContent_().

178 { return exists(pset); }
bool exists(ParameterSet const &pset) const
void edm::IfExistsDescription::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 83 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

Referenced by clone().

83  {
84  if (dfh.pass() == 1) {
85  dfh.indent(os);
86  os << "IfExists pair:";
87 
88  if (dfh.brief()) {
89  if (optional)
90  os << " optional";
91 
92  if (!writeToCfi)
93  os << " (do not write to cfi)";
94 
95  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
96  }
97  // not brief
98  else {
99  os << "\n";
100  dfh.indent2(os);
101 
102  if (optional)
103  os << "optional";
104  if (!writeToCfi)
105  os << " (do not write to cfi)";
106  if (optional || !writeToCfi) {
107  os << "\n";
108  dfh.indent2(os);
109  }
110 
111  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
112 
113  if (!comment().empty()) {
114  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
115  }
116  os << "\n";
117  }
118  }
119  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
std::string const & comment() const
void edm::IfExistsDescription::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 121 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), node_left_, node_right_, edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::OTHER, edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setCounter(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setParent(), edm::DocFormatHelper::setPass(), edm::DocFormatHelper::setSection(), AlCaHLTBitMon_QueryRunRegistry::string, and edm::DocFormatHelper::TOP.

Referenced by hasNestedContent_().

121  {
122  int indentation = dfh.indentation();
123  if (dfh.parent() != DocFormatHelper::TOP) {
124  indentation -= DocFormatHelper::offsetSectionContent();
125  }
126 
127  std::stringstream ss;
128  ss << dfh.section() << "." << dfh.counter();
129  std::string newSection = ss.str();
130 
131  printSpaces(os, indentation);
132  os << "Section " << newSection;
133  if (optional)
134  os << " optional";
135  os << " IfExists pair description:\n";
136  printSpaces(os, indentation);
137  if (optional) {
138  os << "If the first parameter exists, then the second is allowed to exist\n";
139  } else {
140  os << "If the first parameter exists, then the second is required to exist\n";
141  }
142  if (!dfh.brief())
143  os << "\n";
144 
145  DocFormatHelper new_dfh(dfh);
146  new_dfh.init();
147  new_dfh.setSection(newSection);
148  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
149  new_dfh.setParent(DocFormatHelper::OTHER);
150 
151  node_left_->print(os, false, true, new_dfh);
152  node_right_->print(os, false, true, new_dfh);
153 
154  new_dfh.setPass(1);
155  new_dfh.setCounter(0);
156 
157  node_left_->print(os, false, true, new_dfh);
158  node_right_->print(os, false, true, new_dfh);
159 
160  new_dfh.setPass(2);
161  new_dfh.setCounter(0);
162 
163  node_left_->printNestedContent(os, false, new_dfh);
164  node_right_->printNestedContent(os, false, new_dfh);
165  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
void edm::IfExistsDescription::throwIfDuplicateLabels ( std::set< std::string > const &  labelsLeft,
std::set< std::string > const &  labelsRight 
) const
private

Definition at line 182 of file IfExistsDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_(), and hasNestedContent_().

183  {
184  std::set<std::string> duplicateLabels;
185  std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
186  std::set_intersection(labelsLeft.begin(), labelsLeft.end(), labelsRight.begin(), labelsRight.end(), insertIter);
187  if (!duplicateLabels.empty()) {
188  std::stringstream ss;
189  for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(), iEnd = duplicateLabels.end();
190  iter != iEnd;
191  ++iter) {
192  ss << " \"" << *iter << "\"\n";
193  }
194  throw edm::Exception(errors::LogicError) << "Labels used in a node of a ParameterSetDescription\n"
195  << "\"ifExists\" expression must be not be the same as labels used\n"
196  << "in other nodes of the expression. The following duplicate\n"
197  << "labels were detected:\n"
198  << ss.str() << "\n";
199  }
200  }
void edm::IfExistsDescription::throwIfDuplicateTypes ( std::set< ParameterTypes > const &  types1,
std::set< ParameterTypes > const &  types2 
) const
private

Definition at line 202 of file IfExistsDescription.cc.

References Exception, edm::errors::LogicError, and edm::parameterTypeEnumToString().

Referenced by checkAndGetLabelsAndTypes_(), and hasNestedContent_().

203  {
204  if (!types1.empty()) {
205  std::set<ParameterTypes> duplicateTypes;
206  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
207  std::set_intersection(types1.begin(), types1.end(), types2.begin(), types2.end(), insertIter);
208  if (!duplicateTypes.empty()) {
209  std::stringstream ss;
210  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(), iEnd = duplicateTypes.end();
211  iter != iEnd;
212  ++iter) {
213  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
214  }
216  << "Types used for wildcards in a node of a ParameterSetDescription\n"
217  << "\"ifExists\" expression must be different from types used for other parameters\n"
218  << "in other nodes. The following duplicate types were detected:\n"
219  << ss.str() << "\n";
220  }
221  }
222  }
std::string parameterTypeEnumToString(ParameterTypes iType)
void edm::IfExistsDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 56 of file IfExistsDescription.cc.

References node_left_, and node_right_.

Referenced by clone().

56  {
57  bool leftExists = node_left_->exists(pset);
58  bool rightExists = node_right_->exists(pset);
59 
60  if (!leftExists && !rightExists) {
61  return;
62  } else if (leftExists && rightExists) {
63  node_left_->validate(pset, validatedLabels, false);
64  node_right_->validate(pset, validatedLabels, false);
65  } else if (leftExists && !rightExists) {
66  node_left_->validate(pset, validatedLabels, false);
67  if (!optional)
68  node_right_->validate(pset, validatedLabels, false);
69  } else if (!leftExists && rightExists) {
70  node_left_->validate(pset, validatedLabels, false);
71  node_right_->validate(pset, validatedLabels, false);
72  }
73  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
void edm::IfExistsDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 75 of file IfExistsDescription.cc.

References node_left_, and node_right_.

Referenced by clone().

78  {
79  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
80  node_right_->writeCfi(os, startWithComma, indentation, wroteSomething);
81  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

Member Data Documentation

edm::value_ptr<ParameterDescriptionNode> edm::IfExistsDescription::node_left_
private
edm::value_ptr<ParameterDescriptionNode> edm::IfExistsDescription::node_right_
private