CMS 3D CMS Logo

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

#include <ANDGroupDescription.h>

Inheritance diagram for edm::ANDGroupDescription:
edm::ParameterDescriptionNode

Public Member Functions

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

Constructor & Destructor Documentation

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

Definition at line 13 of file ANDGroupDescription.cc.

Referenced by clone().

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

Definition at line 17 of file ANDGroupDescription.cc.

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

Definition at line 21 of file ANDGroupDescription.cc.

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

Definition at line 25 of file ANDGroupDescription.cc.

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

Member Function Documentation

void edm::ANDGroupDescription::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 ANDGroupDescription.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  }
void throwIfDuplicateTypes(std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
void throwIfDuplicateLabels(std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
ParameterDescriptionNode* edm::ANDGroupDescription::clone ( void  ) const
inlineoverridevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 31 of file ANDGroupDescription.h.

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

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

Implements edm::ParameterDescriptionNode.

Definition at line 166 of file ANDGroupDescription.cc.

References node_left_, and node_right_.

Referenced by hasNestedContent_().

166  {
167  return node_left_->exists(pset) && node_right_->exists(pset);
168  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
bool edm::ANDGroupDescription::hasNestedContent_ ( ) const
inlineoverrideprivatevirtual
int edm::ANDGroupDescription::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 174 of file ANDGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

Referenced by hasNestedContent_().

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

Implements edm::ParameterDescriptionNode.

Definition at line 170 of file ANDGroupDescription.cc.

References node_left_, and node_right_.

Referenced by hasNestedContent_().

170  {
171  return node_left_->partiallyExists(pset) || node_right_->partiallyExists(pset);
172  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
void edm::ANDGroupDescription::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) const
overrideprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 71 of file ANDGroupDescription.cc.

References edm::DocFormatHelper::AND, 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(), and edm::DocFormatHelper::wrapAndPrintText().

Referenced by clone().

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 116 of file ANDGroupDescription.cc.

References edm::DocFormatHelper::AND, 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, and edm::DocFormatHelper::TOP.

Referenced by hasNestedContent_().

116  {
117  if (dfh.parent() == DocFormatHelper::AND) {
118  dfh.decrementCounter();
119  node_left_->printNestedContent(os, false, dfh);
120  node_right_->printNestedContent(os, false, dfh);
121  return;
122  }
123 
124  int indentation = dfh.indentation();
125  if (dfh.parent() != DocFormatHelper::TOP) {
126  indentation -= DocFormatHelper::offsetSectionContent();
127  }
128 
129  std::stringstream ss;
130  ss << dfh.section() << "." << dfh.counter();
131  std::string newSection = ss.str();
132 
133  printSpaces(os, indentation);
134  os << "Section " << newSection << " AND group description:\n";
135  printSpaces(os, indentation);
136  if (optional) {
137  os << "This optional AND group requires all or none of the following to be in the PSet\n";
138  } else {
139  os << "This AND group requires all of the following to be in the PSet\n";
140  }
141  if (!dfh.brief())
142  os << "\n";
143 
144  DocFormatHelper new_dfh(dfh);
145  new_dfh.init();
146  new_dfh.setSection(newSection);
147  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
148  new_dfh.setParent(DocFormatHelper::AND);
149 
150  node_left_->print(os, false, true, new_dfh);
151  node_right_->print(os, false, true, new_dfh);
152 
153  new_dfh.setPass(1);
154  new_dfh.setCounter(0);
155 
156  node_left_->print(os, false, true, new_dfh);
157  node_right_->print(os, false, true, new_dfh);
158 
159  new_dfh.setPass(2);
160  new_dfh.setCounter(0);
161 
162  node_left_->printNestedContent(os, false, new_dfh);
163  node_right_->printNestedContent(os, false, new_dfh);
164  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
void edm::ANDGroupDescription::throwIfDuplicateLabels ( std::set< std::string > const &  labelsLeft,
std::set< std::string > const &  labelsRight 
) const
private

Definition at line 176 of file ANDGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_(), and hasNestedContent_().

177  {
178  std::set<std::string> duplicateLabels;
179  std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
180  std::set_intersection(labelsLeft.begin(), labelsLeft.end(), labelsRight.begin(), labelsRight.end(), insertIter);
181  if (!duplicateLabels.empty()) {
182  std::stringstream ss;
183  for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(), iEnd = duplicateLabels.end();
184  iter != iEnd;
185  ++iter) {
186  ss << " \"" << *iter << "\"\n";
187  }
188  throw edm::Exception(errors::LogicError) << "Labels used in different nodes of a ParameterSetDescription\n"
189  << "\"and\" expression must be unique. The following duplicate\n"
190  << "labels were detected:\n"
191  << ss.str() << "\n";
192  }
193  }
void edm::ANDGroupDescription::throwIfDuplicateTypes ( std::set< ParameterTypes > const &  types1,
std::set< ParameterTypes > const &  types2 
) const
private

Definition at line 195 of file ANDGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_(), and hasNestedContent_().

196  {
197  if (!types1.empty()) {
198  std::set<ParameterTypes> duplicateTypes;
199  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
200  std::set_intersection(types1.begin(), types1.end(), types2.begin(), types2.end(), insertIter);
201  if (!duplicateTypes.empty()) {
202  std::stringstream ss;
203  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(), iEnd = duplicateTypes.end();
204  iter != iEnd;
205  ++iter) {
206  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
207  }
209  << "Types used for wildcards in different nodes of a ParameterSetDescription\n"
210  << "\"and\" expression must be different from types used for other parameters.\n"
211  << "The following duplicate types were detected:\n"
212  << ss.str() << "\n";
213  }
214  }
215  }
std::string parameterTypeEnumToString(ParameterTypes iType)
void edm::ANDGroupDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 56 of file ANDGroupDescription.cc.

References node_left_, node_right_, and edm::ParameterDescriptionNode::partiallyExists().

Referenced by clone().

56  {
57  if (partiallyExists(pset) || !optional) {
58  node_left_->validate(pset, validatedLabels, false);
59  node_right_->validate(pset, validatedLabels, false);
60  }
61  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
bool partiallyExists(ParameterSet const &pset) const
void edm::ANDGroupDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
overrideprivatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 63 of file ANDGroupDescription.cc.

References node_left_, and node_right_.

Referenced by clone().

66  {
67  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
68  node_right_->writeCfi(os, startWithComma, indentation, wroteSomething);
69  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

Member Data Documentation

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