CMS 3D CMS Logo

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

#include <ORGroupDescription.h>

Inheritance diagram for edm::ORGroupDescription:
edm::ParameterDescriptionNode

Public Member Functions

ParameterDescriptionNodeclone () const override
 
 ORGroupDescription (ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
 
 ORGroupDescription (ParameterDescriptionNode const &node_left, std::unique_ptr< ParameterDescriptionNode > node_right)
 
 ORGroupDescription (std::unique_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &node_right)
 
 ORGroupDescription (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 (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 ()
 

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 ORGroupDescription.h.

Constructor & Destructor Documentation

◆ ORGroupDescription() [1/4]

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

Definition at line 13 of file ORGroupDescription.cc.

15  : node_left_(node_left.clone()), node_right_(node_right.clone()) {}

Referenced by clone().

◆ ORGroupDescription() [2/4]

edm::ORGroupDescription::ORGroupDescription ( std::unique_ptr< ParameterDescriptionNode node_left,
ParameterDescriptionNode const &  node_right 
)

Definition at line 17 of file ORGroupDescription.cc.

19  : node_left_(std::move(node_left)), node_right_(node_right.clone()) {}

◆ ORGroupDescription() [3/4]

edm::ORGroupDescription::ORGroupDescription ( ParameterDescriptionNode const &  node_left,
std::unique_ptr< ParameterDescriptionNode node_right 
)

Definition at line 21 of file ORGroupDescription.cc.

23  : node_left_(node_left.clone()), node_right_(std::move(node_right)) {}

◆ ORGroupDescription() [4/4]

edm::ORGroupDescription::ORGroupDescription ( std::unique_ptr< ParameterDescriptionNode node_left,
std::unique_ptr< ParameterDescriptionNode node_right 
)

Definition at line 25 of file ORGroupDescription.cc.

27  : node_left_(std::move(node_left)), node_right_(std::move(node_right)) {}

Member Function Documentation

◆ checkAndGetLabelsAndTypes_()

void edm::ORGroupDescription::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 ORGroupDescription.cc.

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  }

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

◆ clone()

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

Implements edm::ParameterDescriptionNode.

Definition at line 29 of file ORGroupDescription.h.

29 { return new ORGroupDescription(*this); }

References ORGroupDescription().

◆ exists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 177 of file ORGroupDescription.cc.

177  {
178  return node_left_->exists(pset) || node_right_->exists(pset);
179  }

References node_left_, node_right_, and muonDTDigis_cfi::pset.

◆ hasNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 43 of file ORGroupDescription.h.

43 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 183 of file ORGroupDescription.cc.

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

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

◆ partiallyExists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 181 of file ORGroupDescription.cc.

181 { return exists(pset); }

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

◆ print_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 79 of file ORGroupDescription.cc.

79  {
80  if (dfh.parent() == DocFormatHelper::OR) {
81  dfh.decrementCounter();
82  node_left_->print(os, false, true, dfh);
83  node_right_->print(os, false, true, dfh);
84  return;
85  }
86 
87  if (dfh.pass() == 1) {
88  dfh.indent(os);
89  os << "OR group:";
90 
91  if (dfh.brief()) {
92  if (optional)
93  os << " optional";
94 
95  if (!writeToCfi)
96  os << " (do not write to cfi)";
97 
98  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
99  }
100  // not brief
101  else {
102  os << "\n";
103  dfh.indent2(os);
104 
105  if (optional)
106  os << "optional";
107  if (!writeToCfi)
108  os << " (do not write to cfi)";
109  if (optional || !writeToCfi) {
110  os << "\n";
111  dfh.indent2(os);
112  }
113 
114  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
115 
116  if (!comment().empty()) {
117  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
118  }
119  os << "\n";
120  }
121  }
122  }

References edm::DocFormatHelper::brief(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::decrementCounter(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), node_left_, node_right_, Types::optional, edm::DocFormatHelper::OR, edm::DocFormatHelper::parent(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

◆ printNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 124 of file ORGroupDescription.cc.

124  {
125  if (dfh.parent() == DocFormatHelper::OR) {
126  dfh.decrementCounter();
127  node_left_->printNestedContent(os, false, dfh);
128  node_right_->printNestedContent(os, false, dfh);
129  return;
130  }
131 
132  int indentation = dfh.indentation();
133  if (dfh.parent() != DocFormatHelper::TOP) {
135  }
136 
137  std::stringstream ss;
138  ss << dfh.section() << "." << dfh.counter();
139  std::string newSection = ss.str();
140 
142  os << "Section " << newSection << " OR group description:\n";
144  if (optional) {
145  // An optional OR group is kind of pointless, it would be
146  // easier just make the parameters be independent optional parameters
147  // I only allow it to make the behavior analogous to the other groups
148  os << "This optional OR group requires at least one or none of the following to be in the PSet\n";
149  } else {
150  os << "This OR group requires at least one of the following to be in the PSet\n";
151  }
152  if (!dfh.brief())
153  os << "\n";
154 
155  DocFormatHelper new_dfh(dfh);
156  new_dfh.init();
157  new_dfh.setSection(newSection);
158  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
159  new_dfh.setParent(DocFormatHelper::OR);
160 
161  node_left_->print(os, false, true, new_dfh);
162  node_right_->print(os, false, true, new_dfh);
163 
164  new_dfh.setPass(1);
165  new_dfh.setCounter(0);
166 
167  node_left_->print(os, false, true, new_dfh);
168  node_right_->print(os, false, true, new_dfh);
169 
170  new_dfh.setPass(2);
171  new_dfh.setCounter(0);
172 
173  node_left_->printNestedContent(os, false, new_dfh);
174  node_right_->printNestedContent(os, false, new_dfh);
175  }

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::decrementCounter(), printContent_cfi::indentation, edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), node_left_, node_right_, edm::DocFormatHelper::offsetSectionContent(), Types::optional, edm::DocFormatHelper::OR, 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.

◆ throwIfDuplicateLabels()

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

Definition at line 185 of file ORGroupDescription.cc.

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

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

Referenced by checkAndGetLabelsAndTypes_().

◆ throwIfDuplicateTypes()

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

Definition at line 205 of file ORGroupDescription.cc.

206  {
207  if (!types1.empty()) {
208  std::set<ParameterTypes> duplicateTypes;
209  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
210  std::set_intersection(types1.begin(), types1.end(), types2.begin(), types2.end(), insertIter);
211  if (!duplicateTypes.empty()) {
212  std::stringstream ss;
213  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(), iEnd = duplicateTypes.end();
214  iter != iEnd;
215  ++iter) {
216  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
217  }
219  << "Types used for wildcards in a node of a ParameterSetDescription\n"
220  << "\"or\" expression must be different from types used for other parameters\n"
221  << "in other nodes. The following duplicate types were detected:\n"
222  << ss.str() << "\n";
223  }
224  }
225  }

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

Referenced by checkAndGetLabelsAndTypes_().

◆ validate_()

void edm::ORGroupDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 56 of file ORGroupDescription.cc.

56  {
57  bool leftExists = node_left_->exists(pset);
58  bool rightExists = node_right_->exists(pset);
59 
60  if (leftExists || rightExists) {
61  if (leftExists)
62  node_left_->validate(pset, validatedLabels, false);
63  if (rightExists)
64  node_right_->validate(pset, validatedLabels, false);
65  return;
66  }
67 
68  if (optional)
69  return;
70 
71  node_left_->validate(pset, validatedLabels, false);
72  }

References node_left_, node_right_, Types::optional, and muonDTDigis_cfi::pset.

◆ writeCfi_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 74 of file ORGroupDescription.cc.

75  {
76  node_left_->writeCfi(os, optional, startWithComma, indentation, wroteSomething);
77  }

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

Member Data Documentation

◆ node_left_

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

◆ node_right_

edm::value_ptr<ParameterDescriptionNode> edm::ORGroupDescription::node_right_
private
edm::DocFormatHelper::TOP
Definition: DocFormatHelper.h:17
edm::ParameterDescriptionNode::exists
bool exists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:134
edm::ORGroupDescription::ORGroupDescription
ORGroupDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
Definition: ORGroupDescription.cc:13
edm::errors::LogicError
Definition: EDMException.h:37
edm::ORGroupDescription::throwIfDuplicateTypes
void throwIfDuplicateTypes(std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
Definition: ORGroupDescription.cc:205
Types.optional
optional
Definition: Types.py:167
edm::DocFormatHelper::OR
Definition: DocFormatHelper.h:17
edm::parameterTypeEnumToString
std::string parameterTypeEnumToString(ParameterTypes iType)
Definition: ParameterDescriptionNode.cc:64
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::ORGroupDescription::node_right_
edm::value_ptr< ParameterDescriptionNode > node_right_
Definition: ORGroupDescription.h:59
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::DocFormatHelper::wrapAndPrintText
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
Definition: DocFormatHelper.cc:97
edm::ORGroupDescription::node_left_
edm::value_ptr< ParameterDescriptionNode > node_left_
Definition: ORGroupDescription.h:58
edm::ParameterDescriptionNode::printSpaces
static void printSpaces(std::ostream &os, int n)
Definition: ParameterDescriptionNode.cc:124
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::DocFormatHelper::offsetSectionContent
static int offsetSectionContent()
Definition: DocFormatHelper.h:83
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
edm::ORGroupDescription::throwIfDuplicateLabels
void throwIfDuplicateLabels(std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
Definition: ORGroupDescription.cc:185
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ParameterDescriptionNode::comment
std::string const & comment() const
Definition: ParameterDescriptionNode.h:92
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27