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

Referenced by clone().

15  : node_left_(node_left.clone()), node_right_(node_right.clone()) {}
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_

◆ 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()) {}
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
def move(src, dest)
Definition: eostools.py:511

◆ 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)) {}
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
def move(src, dest)
Definition: eostools.py:511

◆ 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)) {}
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
def move(src, dest)
Definition: eostools.py:511

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.

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  }
edm::value_ptr< ParameterDescriptionNode > node_left_
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_

◆ clone()

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

Implements edm::ParameterDescriptionNode.

Definition at line 29 of file ORGroupDescription.h.

References ORGroupDescription().

29 { return new ORGroupDescription(*this); }
ORGroupDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)

◆ exists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 181 of file ORGroupDescription.cc.

References node_left_, node_right_, and muonDTDigis_cfi::pset.

181  {
182  return node_left_->exists(pset) || node_right_->exists(pset);
183  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_

◆ hasNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 47 of file ORGroupDescription.h.

47 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 187 of file ORGroupDescription.cc.

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

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

◆ partiallyExists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 185 of file ORGroupDescription.cc.

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

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

◆ print_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 83 of file ORGroupDescription.cc.

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, l1tGTMenu_BTagSeeds_cff::os, edm::DocFormatHelper::parent(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

83  {
84  if (dfh.parent() == DocFormatHelper::OR) {
85  dfh.decrementCounter();
86  node_left_->print(os, false, true, dfh);
87  node_right_->print(os, false, true, dfh);
88  return;
89  }
90 
91  if (dfh.pass() == 1) {
92  dfh.indent(os);
93  os << "OR group:";
94 
95  if (dfh.brief()) {
96  if (optional)
97  os << " optional";
98 
99  if (!writeToCfi)
100  os << " (do not write to cfi)";
101 
102  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
103  }
104  // not brief
105  else {
106  os << "\n";
107  dfh.indent2(os);
108 
109  if (optional)
110  os << "optional";
111  if (!writeToCfi)
112  os << " (do not write to cfi)";
113  if (optional || !writeToCfi) {
114  os << "\n";
115  dfh.indent2(os);
116  }
117 
118  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
119 
120  if (!comment().empty()) {
121  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
122  }
123  os << "\n";
124  }
125  }
126  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
edm::value_ptr< ParameterDescriptionNode > node_left_
optional
Definition: Types.py:245
std::string const & comment() const
edm::value_ptr< ParameterDescriptionNode > node_right_

◆ printNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 128 of file ORGroupDescription.cc.

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, l1tGTMenu_BTagSeeds_cff::os, 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.

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

◆ throwIfDuplicateLabels()

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

Definition at line 189 of file ORGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

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

◆ throwIfDuplicateTypes()

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

Definition at line 209 of file ORGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

210  {
211  if (!types1.empty()) {
212  std::set<ParameterTypes> duplicateTypes;
213  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
214  std::set_intersection(types1.begin(), types1.end(), types2.begin(), types2.end(), insertIter);
215  if (!duplicateTypes.empty()) {
216  std::stringstream ss;
217  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(), iEnd = duplicateTypes.end();
218  iter != iEnd;
219  ++iter) {
220  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
221  }
223  << "Types used for wildcards in a node of a ParameterSetDescription\n"
224  << "\"or\" expression must be different from types used for other parameters\n"
225  << "in other nodes. The following duplicate types were detected:\n"
226  << ss.str() << "\n";
227  }
228  }
229  }
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::ORGroupDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 56 of file ORGroupDescription.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  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  }
edm::value_ptr< ParameterDescriptionNode > node_left_
optional
Definition: Types.py:245
edm::value_ptr< ParameterDescriptionNode > node_right_

◆ writeCfi_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 74 of file ORGroupDescription.cc.

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

79  {
80  node_left_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething);
81  }
edm::value_ptr< ParameterDescriptionNode > node_left_
optional
Definition: Types.py:245

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