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
 
virtual bool isWildcard () 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 ()
 

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

◆ IfExistsDescription() [1/4]

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_

◆ IfExistsDescription() [2/4]

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

◆ IfExistsDescription() [3/4]

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

◆ IfExistsDescription() [4/4]

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

◆ checkAndGetLabelsAndTypes_()

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().

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 throwIfDuplicateTypes(std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
void throwIfDuplicateLabels(std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

◆ clone()

ParameterDescriptionNode* edm::IfExistsDescription::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 31 of file IfExistsDescription.h.

References IfExistsDescription().

31 { return new IfExistsDescription(*this); }
IfExistsDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)

◆ exists_()

bool edm::IfExistsDescription::exists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 165 of file IfExistsDescription.cc.

References node_left_, node_right_, and muonDTDigis_cfi::pset.

165  {
166  bool leftExists = node_left_->exists(pset);
167  bool rightExists = node_right_->exists(pset);
168 
169  if (leftExists && rightExists)
170  return true;
171  else if (!leftExists && !rightExists)
172  return true;
173  return false;
174  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

◆ hasNestedContent_()

bool edm::IfExistsDescription::hasNestedContent_ ( ) const
inlineoverrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 45 of file IfExistsDescription.h.

45 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 178 of file IfExistsDescription.cc.

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

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

◆ partiallyExists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 176 of file IfExistsDescription.cc.

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

176 { return exists(pset); }
bool exists(ParameterSet const &pset) const

◆ print_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 81 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(), Types::optional, edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

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

◆ printNestedContent_()

void edm::IfExistsDescription::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 119 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), printContent_cfi::indentation, edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), node_left_, node_right_, edm::DocFormatHelper::offsetSectionContent(), Types::optional, 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(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and edm::DocFormatHelper::TOP.

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

◆ throwIfDuplicateLabels()

void edm::IfExistsDescription::throwIfDuplicateLabels ( std::set< std::string > const &  labelsLeft,
std::set< std::string > const &  labelsRight 
) const
private

Definition at line 180 of file IfExistsDescription.cc.

References Exception, edm::errors::LogicError, DBoxMetadataHelper::set_intersection(), and contentValuesCheck::ss.

Referenced by checkAndGetLabelsAndTypes_().

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

◆ throwIfDuplicateTypes()

void edm::IfExistsDescription::throwIfDuplicateTypes ( std::set< ParameterTypes > const &  types1,
std::set< ParameterTypes > const &  types2 
) const
private

Definition at line 200 of file IfExistsDescription.cc.

References Exception, edm::errors::LogicError, edm::parameterTypeEnumToString(), DBoxMetadataHelper::set_intersection(), and contentValuesCheck::ss.

Referenced by checkAndGetLabelsAndTypes_().

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

◆ validate_()

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_, node_right_, Types::optional, and muonDTDigis_cfi::pset.

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_
optional
Definition: Types.py:245

◆ writeCfi_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 75 of file IfExistsDescription.cc.

References printContent_cfi::indentation, node_left_, node_right_, and Types::optional.

76  {
77  node_left_->writeCfi(os, optional, startWithComma, indentation, wroteSomething);
78  node_right_->writeCfi(os, optional, startWithComma, indentation, wroteSomething);
79  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
optional
Definition: Types.py:245

Member Data Documentation

◆ node_left_

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

◆ node_right_

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