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

Constructor & Destructor Documentation

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_
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
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
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

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

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  }
edm::value_ptr< ParameterDescriptionNode > node_left_
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_
ParameterDescriptionNode* edm::ORGroupDescription::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 29 of file ORGroupDescription.h.

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

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

Implements edm::ParameterDescriptionNode.

Definition at line 179 of file ORGroupDescription.cc.

References node_left_, and node_right_.

Referenced by hasNestedContent_().

179  {
180  return node_left_->exists(pset) || node_right_->exists(pset);
181  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
bool edm::ORGroupDescription::hasNestedContent_ ( ) const
inlineoverrideprivatevirtual
int edm::ORGroupDescription::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 185 of file ORGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by hasNestedContent_().

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

Implements edm::ParameterDescriptionNode.

Definition at line 183 of file ORGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by hasNestedContent_().

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

Reimplemented from edm::ParameterDescriptionNode.

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

Referenced by clone().

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 126 of file ORGroupDescription.cc.

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

Referenced by hasNestedContent_().

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

Definition at line 187 of file ORGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_(), and hasNestedContent_().

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

Definition at line 207 of file ORGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_(), and hasNestedContent_().

208  {
209  if (!types1.empty()) {
210  std::set<ParameterTypes> duplicateTypes;
211  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
212  std::set_intersection(types1.begin(), types1.end(), types2.begin(), types2.end(), insertIter);
213  if (!duplicateTypes.empty()) {
214  std::stringstream ss;
215  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(), iEnd = duplicateTypes.end();
216  iter != iEnd;
217  ++iter) {
218  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
219  }
221  << "Types used for wildcards in a node of a ParameterSetDescription\n"
222  << "\"or\" expression must be different from types used for other parameters\n"
223  << "in other nodes. The following duplicate types were detected:\n"
224  << ss.str() << "\n";
225  }
226  }
227  }
std::string parameterTypeEnumToString(ParameterTypes iType)
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_, 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  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_
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::ORGroupDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 74 of file ORGroupDescription.cc.

References node_left_.

Referenced by clone().

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

Member Data Documentation

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