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 11 of file XORGroupDescription.cc.

Referenced by clone().

13  : node_left_(node_left.clone()), node_right_(node_right.clone()) {}
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 15 of file XORGroupDescription.cc.

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

Definition at line 19 of file XORGroupDescription.cc.

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

Definition at line 23 of file XORGroupDescription.cc.

25  : node_left_(std::move(node_left)), node_right_(std::move(node_right)) {}
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511
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 27 of file XORGroupDescription.cc.

References node_left_, and node_right_.

Referenced by clone().

29  {
30  std::set<std::string> labelsLeft;
31  std::set<ParameterTypes> parameterTypesLeft;
32  std::set<ParameterTypes> wildcardTypesLeft;
33  node_left_->checkAndGetLabelsAndTypes(labelsLeft, parameterTypesLeft, wildcardTypesLeft);
34 
35  std::set<std::string> labelsRight;
36  std::set<ParameterTypes> parameterTypesRight;
37  std::set<ParameterTypes> wildcardTypesRight;
38  node_right_->checkAndGetLabelsAndTypes(labelsRight, parameterTypesRight, wildcardTypesRight);
39 
40  usedLabels.insert(labelsLeft.begin(), labelsLeft.end());
41  usedLabels.insert(labelsRight.begin(), labelsRight.end());
42 
43  parameterTypes.insert(parameterTypesRight.begin(), parameterTypesRight.end());
44  parameterTypes.insert(parameterTypesLeft.begin(), parameterTypesLeft.end());
45 
46  wildcardTypes.insert(wildcardTypesRight.begin(), wildcardTypesRight.end());
47  wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end());
48  }
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 31 of file XORGroupDescription.h.

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

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

Implements edm::ParameterDescriptionNode.

Definition at line 183 of file XORGroupDescription.cc.

References node_left_, and node_right_.

Referenced by hasNestedContent_().

183  {
184  int nTotal = node_left_->howManyXORSubNodesExist(pset) + node_right_->howManyXORSubNodesExist(pset);
185  return nTotal == 1;
186  }
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 190 of file XORGroupDescription.cc.

References node_left_, and node_right_.

Referenced by hasNestedContent_().

190  {
191  return node_left_->howManyXORSubNodesExist(pset) + node_right_->howManyXORSubNodesExist(pset);
192  }
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 188 of file XORGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by hasNestedContent_().

188 { return exists(pset); }
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 88 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(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), edm::DocFormatHelper::wrapAndPrintText(), and edm::DocFormatHelper::XOR.

Referenced by clone().

88  {
89  if (dfh.parent() == DocFormatHelper::XOR) {
90  dfh.decrementCounter();
91  node_left_->print(os, false, true, dfh);
92  node_right_->print(os, false, true, dfh);
93  return;
94  }
95 
96  if (dfh.pass() == 1) {
97  dfh.indent(os);
98  os << "XOR group:";
99 
100  if (dfh.brief()) {
101  if (optional)
102  os << " optional";
103 
104  if (!writeToCfi)
105  os << " (do not write to cfi)";
106 
107  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
108  }
109  // not brief
110  else {
111  os << "\n";
112  dfh.indent2(os);
113 
114  if (optional)
115  os << "optional";
116  if (!writeToCfi)
117  os << " (do not write to cfi)";
118  if (optional || !writeToCfi) {
119  os << "\n";
120  dfh.indent2(os);
121  }
122 
123  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
124 
125  if (!comment().empty()) {
126  DocFormatHelper::wrapAndPrintText(os, comment(), dfh.startColumn2(), dfh.commentWidth());
127  }
128  os << "\n";
129  }
130  }
131  }
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 133 of file XORGroupDescription.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::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_().

133  {
134  if (dfh.parent() == DocFormatHelper::XOR) {
135  dfh.decrementCounter();
136  node_left_->printNestedContent(os, false, dfh);
137  node_right_->printNestedContent(os, false, dfh);
138  return;
139  }
140 
141  int indentation = dfh.indentation();
142  if (dfh.parent() != DocFormatHelper::TOP) {
143  indentation -= DocFormatHelper::offsetSectionContent();
144  }
145 
146  std::stringstream ss;
147  ss << dfh.section() << "." << dfh.counter();
148  std::string newSection = ss.str();
149 
150  printSpaces(os, indentation);
151  os << "Section " << newSection << " XOR group description:\n";
152  printSpaces(os, indentation);
153  if (optional) {
154  os << "This optional XOR group requires exactly one or none of the following to be in the PSet\n";
155  } else {
156  os << "This XOR group requires exactly one of the following to be in the PSet\n";
157  }
158  if (!dfh.brief())
159  os << "\n";
160 
161  DocFormatHelper new_dfh(dfh);
162  new_dfh.init();
163  new_dfh.setSection(newSection);
164  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
165  new_dfh.setParent(DocFormatHelper::XOR);
166 
167  node_left_->print(os, false, true, new_dfh);
168  node_right_->print(os, false, true, new_dfh);
169 
170  new_dfh.setPass(1);
171  new_dfh.setCounter(0);
172 
173  node_left_->print(os, false, true, new_dfh);
174  node_right_->print(os, false, true, new_dfh);
175 
176  new_dfh.setPass(2);
177  new_dfh.setCounter(0);
178 
179  node_left_->printNestedContent(os, false, new_dfh);
180  node_right_->printNestedContent(os, false, new_dfh);
181  }
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 206 of file XORGroupDescription.cc.

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

Referenced by hasNestedContent_(), and validate_().

206  {
207  // Need to expand this error message to print more information
208  // I guess I need to print out the entire node structure of
209  // of the xor node and all the nodes it contains.
211  << "Exactly one parameter can exist in a ParameterSet from a list of\n"
212  << "parameters described by an \"xor\" operator in a ParameterSetDescription.\n"
213  << "This rule also applies in a more general sense to the other types\n"
214  << "of nodes that can appear within a ParameterSetDescription. Only one\n"
215  << "can pass validation as \"existing\". This error has occurred after an\n"
216  << "attempt to insert missing parameters to fix the problem.\n";
217  }
void edm::XORGroupDescription::throwMoreThanOneParameter ( ) const
private

Definition at line 194 of file XORGroupDescription.cc.

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

Referenced by hasNestedContent_(), and validate_().

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

Implements edm::ParameterDescriptionNode.

Definition at line 50 of file XORGroupDescription.cc.

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

Referenced by clone().

50  {
51  int nExistLeft = node_left_->howManyXORSubNodesExist(pset);
52  int nExistRight = node_right_->howManyXORSubNodesExist(pset);
53  int nTotal = nExistLeft + nExistRight;
54 
55  if (nTotal == 0 && optional)
56  return;
57 
58  if (nTotal > 1) {
60  }
61 
62  if (nExistLeft == 1) {
63  node_left_->validate(pset, validatedLabels, false);
64  } else if (nExistRight == 1) {
65  node_right_->validate(pset, validatedLabels, false);
66  } else if (nTotal == 0) {
67  node_left_->validate(pset, validatedLabels, false);
68 
69  // When missing parameters get inserted, both nodes could
70  // be affected so we have to recheck both nodes.
71  nExistLeft = node_left_->howManyXORSubNodesExist(pset);
72  nExistRight = node_right_->howManyXORSubNodesExist(pset);
73  nTotal = nExistLeft + nExistRight;
74 
75  if (nTotal != 1) {
77  }
78  }
79  }
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 81 of file XORGroupDescription.cc.

References node_left_.

Referenced by clone().

84  {
85  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
86  }
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