CMS 3D CMS Logo

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

#include <XORGroupDescription.h>

Inheritance diagram for edm::XORGroupDescription:
edm::ParameterDescriptionNode

Public Member Functions

ParameterDescriptionNodeclone () const override
 
 XORGroupDescription (ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
 
 XORGroupDescription (std::unique_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &node_right)
 
 XORGroupDescription (ParameterDescriptionNode const &node_left, std::unique_ptr< ParameterDescriptionNode > node_right)
 
 XORGroupDescription (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 throwAfterValidation () const
 
void throwMoreThanOneParameter () 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 XORGroupDescription.h.

Constructor & Destructor Documentation

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

Definition at line 12 of file XORGroupDescription.cc.

Referenced by clone(), and XORGroupDescription().

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

Definition at line 19 of file XORGroupDescription.cc.

References XORGroupDescription().

20  :
21  node_left_(std::move(node_left)),
22  node_right_(node_right.clone()) {
23  }
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:510
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::XORGroupDescription::XORGroupDescription ( ParameterDescriptionNode const &  node_left,
std::unique_ptr< ParameterDescriptionNode node_right 
)

Definition at line 26 of file XORGroupDescription.cc.

References XORGroupDescription().

27  :
28  node_left_(node_left.clone()),
29  node_right_(std::move(node_right)) {
30  }
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:510
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::XORGroupDescription::XORGroupDescription ( std::unique_ptr< ParameterDescriptionNode node_left,
std::unique_ptr< ParameterDescriptionNode node_right 
)

Definition at line 33 of file XORGroupDescription.cc.

References checkAndGetLabelsAndTypes_().

34  :
35  node_left_(std::move(node_left)),
36  node_right_(std::move(node_right)) {
37  }
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:510
edm::value_ptr< ParameterDescriptionNode > node_right_

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 41 of file XORGroupDescription.cc.

References node_left_, node_right_, and validate_().

Referenced by clone(), and XORGroupDescription().

43  {
44 
45  std::set<std::string> labelsLeft;
46  std::set<ParameterTypes> parameterTypesLeft;
47  std::set<ParameterTypes> wildcardTypesLeft;
48  node_left_->checkAndGetLabelsAndTypes(labelsLeft, parameterTypesLeft, wildcardTypesLeft);
49 
50  std::set<std::string> labelsRight;
51  std::set<ParameterTypes> parameterTypesRight;
52  std::set<ParameterTypes> wildcardTypesRight;
53  node_right_->checkAndGetLabelsAndTypes(labelsRight, parameterTypesRight, wildcardTypesRight);
54 
55  usedLabels.insert(labelsLeft.begin(), labelsLeft.end());
56  usedLabels.insert(labelsRight.begin(), labelsRight.end());
57 
58  parameterTypes.insert(parameterTypesRight.begin(), parameterTypesRight.end());
59  parameterTypes.insert(parameterTypesLeft.begin(), parameterTypesLeft.end());
60 
61  wildcardTypes.insert(wildcardTypesRight.begin(), wildcardTypesRight.end());
62  wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end());
63  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
ParameterDescriptionNode* edm::XORGroupDescription::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 32 of file XORGroupDescription.h.

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

32  {
33  return new XORGroupDescription(*this);
34  }
XORGroupDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
bool edm::XORGroupDescription::exists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 222 of file XORGroupDescription.cc.

References node_left_, node_right_, and partiallyExists_().

Referenced by hasNestedContent_(), and printNestedContent_().

222  {
223  int nTotal = node_left_->howManyXORSubNodesExist(pset) +
224  node_right_->howManyXORSubNodesExist(pset);
225  return nTotal == 1;
226  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
bool edm::XORGroupDescription::hasNestedContent_ ( ) const
inlineoverrideprivatevirtual
int edm::XORGroupDescription::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 236 of file XORGroupDescription.cc.

References node_left_, node_right_, and throwMoreThanOneParameter().

Referenced by hasNestedContent_(), and partiallyExists_().

236  {
237  return node_left_->howManyXORSubNodesExist(pset) +
238  node_right_->howManyXORSubNodesExist(pset);
239  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
bool edm::XORGroupDescription::partiallyExists_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 230 of file XORGroupDescription.cc.

References edm::ParameterDescriptionNode::exists(), and howManyXORSubNodesExist_().

Referenced by exists_(), and hasNestedContent_().

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 113 of file XORGroupDescription.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::parent(), edm::DocFormatHelper::pass(), printNestedContent_(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), edm::DocFormatHelper::wrapAndPrintText(), and edm::DocFormatHelper::XOR.

Referenced by clone(), and writeCfi_().

116  {
117 
118  if (dfh.parent() == DocFormatHelper::XOR) {
119  dfh.decrementCounter();
120  node_left_->print(os, false, true, dfh);
121  node_right_->print(os, false, true, dfh);
122  return;
123  }
124 
125  if (dfh.pass() == 1) {
126 
127  dfh.indent(os);
128  os << "XOR group:";
129 
130  if (dfh.brief()) {
131 
132  if (optional) os << " optional";
133 
134  if (!writeToCfi) os << " (do not write to cfi)";
135 
136  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
137  }
138  // not brief
139  else {
140 
141  os << "\n";
142  dfh.indent2(os);
143 
144  if (optional) os << "optional";
145  if (!writeToCfi) os << " (do not write to cfi)";
146  if (optional || !writeToCfi) {
147  os << "\n";
148  dfh.indent2(os);
149  }
150 
151  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
152 
153  if (!comment().empty()) {
155  comment(),
156  dfh.startColumn2(),
157  dfh.commentWidth());
158  }
159  os << "\n";
160  }
161  }
162  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
std::string const & comment() const
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::XORGroupDescription::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 166 of file XORGroupDescription.cc.

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

Referenced by hasNestedContent_(), and print_().

168  {
169 
170  if (dfh.parent() == DocFormatHelper::XOR) {
171  dfh.decrementCounter();
172  node_left_->printNestedContent(os, false, dfh);
173  node_right_->printNestedContent(os, false, dfh);
174  return;
175  }
176 
177  int indentation = dfh.indentation();
178  if (dfh.parent() != DocFormatHelper::TOP) {
179  indentation -= DocFormatHelper::offsetSectionContent();
180  }
181 
182  std::stringstream ss;
183  ss << dfh.section() << "." << dfh.counter();
184  std::string newSection = ss.str();
185 
186  printSpaces(os, indentation);
187  os << "Section " << newSection
188  << " XOR group description:\n";
189  printSpaces(os, indentation);
190  if (optional) {
191  os << "This optional XOR group requires exactly one or none of the following to be in the PSet\n";
192  }
193  else {
194  os << "This XOR group requires exactly one of the following to be in the PSet\n";
195  }
196  if (!dfh.brief()) os << "\n";
197 
198  DocFormatHelper new_dfh(dfh);
199  new_dfh.init();
200  new_dfh.setSection(newSection);
201  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
202  new_dfh.setParent(DocFormatHelper::XOR);
203 
204  node_left_->print(os, false, true, new_dfh);
205  node_right_->print(os, false, true, new_dfh);
206 
207  new_dfh.setPass(1);
208  new_dfh.setCounter(0);
209 
210  node_left_->print(os, false, true, new_dfh);
211  node_right_->print(os, false, true, new_dfh);
212 
213  new_dfh.setPass(2);
214  new_dfh.setCounter(0);
215 
216  node_left_->printNestedContent(os, false, new_dfh);
217  node_right_->printNestedContent(os, false, new_dfh);
218  }
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::XORGroupDescription::throwAfterValidation ( ) const
private

Definition at line 257 of file XORGroupDescription.cc.

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

Referenced by hasNestedContent_(), throwMoreThanOneParameter(), and validate_().

257  {
258  // Need to expand this error message to print more information
259  // I guess I need to print out the entire node structure of
260  // of the xor node and all the nodes it contains.
262  << "Exactly one parameter can exist in a ParameterSet from a list of\n"
263  << "parameters described by an \"xor\" operator in a ParameterSetDescription.\n"
264  << "This rule also applies in a more general sense to the other types\n"
265  << "of nodes that can appear within a ParameterSetDescription. Only one\n"
266  << "can pass validation as \"existing\". This error has occurred after an\n"
267  << "attempt to insert missing parameters to fix the problem.\n";
268  }
void edm::XORGroupDescription::throwMoreThanOneParameter ( ) const
private

Definition at line 243 of file XORGroupDescription.cc.

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

Referenced by hasNestedContent_(), howManyXORSubNodesExist_(), and validate_().

243  {
244  // Need to expand this error message to print more information
245  // I guess I need to print out the entire node structure of
246  // of the xor node and all the nodes it contains.
248  << "Exactly one parameter can exist in a ParameterSet from a list of\n"
249  << "parameters described by an \"xor\" operator in a ParameterSetDescription.\n"
250  << "This rule also applies in a more general sense to the other types\n"
251  << "of nodes that can appear within a ParameterSetDescription. Only one\n"
252  << "can pass validation as \"existing\".\n";
253  }
void edm::XORGroupDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 67 of file XORGroupDescription.cc.

References node_left_, node_right_, throwAfterValidation(), throwMoreThanOneParameter(), and writeCfi_().

Referenced by checkAndGetLabelsAndTypes_(), and clone().

69  {
70 
71  int nExistLeft = node_left_->howManyXORSubNodesExist(pset);
72  int nExistRight = node_right_->howManyXORSubNodesExist(pset);
73  int nTotal = nExistLeft + nExistRight;
74 
75  if (nTotal == 0 && optional) return;
76 
77  if (nTotal > 1) {
79  }
80 
81  if (nExistLeft == 1) {
82  node_left_->validate(pset, validatedLabels, false);
83  }
84  else if (nExistRight == 1) {
85  node_right_->validate(pset, validatedLabels, false);
86  }
87  else if (nTotal == 0) {
88  node_left_->validate(pset, validatedLabels, false);
89 
90  // When missing parameters get inserted, both nodes could
91  // be affected so we have to recheck both nodes.
92  nExistLeft = node_left_->howManyXORSubNodesExist(pset);
93  nExistRight = node_right_->howManyXORSubNodesExist(pset);
94  nTotal = nExistLeft + nExistRight;
95 
96  if (nTotal != 1) {
98  }
99  }
100  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::XORGroupDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 104 of file XORGroupDescription.cc.

References node_left_, and print_().

Referenced by clone(), and validate_().

107  {
108  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
109  }
edm::value_ptr< ParameterDescriptionNode > node_left_

Member Data Documentation

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