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 (ParameterDescriptionNode const &node_left, std::unique_ptr< ParameterDescriptionNode > node_right)
 
 ANDGroupDescription (std::unique_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &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 (char const *value)
 
void setComment (std::string 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, 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, 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

◆ ANDGroupDescription() [1/4]

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

Definition at line 13 of file ANDGroupDescription.cc.

15  : node_left_(node_left.clone()), node_right_(node_right.clone()) {}

Referenced by clone().

◆ ANDGroupDescription() [2/4]

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()) {}

◆ ANDGroupDescription() [3/4]

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)) {}

◆ ANDGroupDescription() [4/4]

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)) {}

Member Function Documentation

◆ checkAndGetLabelsAndTypes_()

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.

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  }

References node_left_, node_right_, throwIfDuplicateLabels(), and throwIfDuplicateTypes().

◆ clone()

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

Implements edm::ParameterDescriptionNode.

Definition at line 31 of file ANDGroupDescription.h.

31 { return new ANDGroupDescription(*this); }

References ANDGroupDescription().

◆ exists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 164 of file ANDGroupDescription.cc.

164  {
165  return node_left_->exists(pset) && node_right_->exists(pset);
166  }

References node_left_, node_right_, and muonDTDigis_cfi::pset.

◆ hasNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 45 of file ANDGroupDescription.h.

45 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 172 of file ANDGroupDescription.cc.

172 { return exists(pset) ? 1 : 0; }

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

◆ partiallyExists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 168 of file ANDGroupDescription.cc.

168  {
169  return node_left_->partiallyExists(pset) || node_right_->partiallyExists(pset);
170  }

References node_left_, node_right_, and muonDTDigis_cfi::pset.

◆ print_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 69 of file ANDGroupDescription.cc.

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

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

◆ printNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 114 of file ANDGroupDescription.cc.

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

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

◆ throwIfDuplicateLabels()

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

Definition at line 174 of file ANDGroupDescription.cc.

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

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

Referenced by checkAndGetLabelsAndTypes_().

◆ throwIfDuplicateTypes()

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

Definition at line 193 of file ANDGroupDescription.cc.

194  {
195  if (!types1.empty()) {
196  std::set<ParameterTypes> duplicateTypes;
197  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
198  std::set_intersection(types1.begin(), types1.end(), types2.begin(), types2.end(), insertIter);
199  if (!duplicateTypes.empty()) {
200  std::stringstream ss;
201  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(), iEnd = duplicateTypes.end();
202  iter != iEnd;
203  ++iter) {
204  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
205  }
207  << "Types used for wildcards in different nodes of a ParameterSetDescription\n"
208  << "\"and\" expression must be different from types used for other parameters.\n"
209  << "The following duplicate types were detected:\n"
210  << ss.str() << "\n";
211  }
212  }
213  }

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

Referenced by checkAndGetLabelsAndTypes_().

◆ validate_()

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.

56  {
57  if (partiallyExists(pset) || !optional) {
58  node_left_->validate(pset, validatedLabels, false);
59  node_right_->validate(pset, validatedLabels, false);
60  }
61  }

References node_left_, node_right_, Types::optional, edm::ParameterDescriptionNode::partiallyExists(), and muonDTDigis_cfi::pset.

◆ writeCfi_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 63 of file ANDGroupDescription.cc.

64  {
65  node_left_->writeCfi(os, optional, startWithComma, indentation, wroteSomething);
66  node_right_->writeCfi(os, optional, startWithComma, indentation, wroteSomething);
67  }

References printContent_cfi::indentation, node_left_, node_right_, and Types::optional.

Member Data Documentation

◆ node_left_

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

◆ node_right_

edm::value_ptr<ParameterDescriptionNode> edm::ANDGroupDescription::node_right_
private
edm::DocFormatHelper::TOP
Definition: DocFormatHelper.h:17
edm::ParameterDescriptionNode::exists
bool exists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:134
edm::ANDGroupDescription::node_right_
edm::value_ptr< ParameterDescriptionNode > node_right_
Definition: ANDGroupDescription.h:61
edm::errors::LogicError
Definition: EDMException.h:37
edm::ANDGroupDescription::ANDGroupDescription
ANDGroupDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
Definition: ANDGroupDescription.cc:13
Types.optional
optional
Definition: Types.py:167
edm::parameterTypeEnumToString
std::string parameterTypeEnumToString(ParameterTypes iType)
Definition: ParameterDescriptionNode.cc:64
edm::ANDGroupDescription::node_left_
edm::value_ptr< ParameterDescriptionNode > node_left_
Definition: ANDGroupDescription.h:60
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
edm::ANDGroupDescription::throwIfDuplicateLabels
void throwIfDuplicateLabels(std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
Definition: ANDGroupDescription.cc:174
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::DocFormatHelper::wrapAndPrintText
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
Definition: DocFormatHelper.cc:97
edm::ParameterDescriptionNode::printSpaces
static void printSpaces(std::ostream &os, int n)
Definition: ParameterDescriptionNode.cc:124
eostools.move
def move(src, dest)
Definition: eostools.py:511
edm::DocFormatHelper::offsetSectionContent
static int offsetSectionContent()
Definition: DocFormatHelper.h:83
edm::ParameterDescriptionNode::partiallyExists
bool partiallyExists(ParameterSet const &pset) const
Definition: ParameterDescriptionNode.h:140
relativeConstraints.empty
bool empty
Definition: relativeConstraints.py:46
Exception
Definition: hltDiff.cc:246
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ANDGroupDescription::throwIfDuplicateTypes
void throwIfDuplicateTypes(std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
Definition: ANDGroupDescription.cc:193
edm::DocFormatHelper::AND
Definition: DocFormatHelper.h:17
edm::ParameterDescriptionNode::comment
std::string const & comment() const
Definition: ParameterDescriptionNode.h:92
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27