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
 
virtual bool isWildcard () 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 optional, bool &startWithComma, int indentation, CfiOptions &options, 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, CfiOptions &, 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.

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_

◆ 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()) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511

◆ 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)) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511

◆ 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)) {}
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
def move(src, dest)
Definition: eostools.py:511

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.

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

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 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
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

◆ clone()

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

Implements edm::ParameterDescriptionNode.

Definition at line 31 of file ANDGroupDescription.h.

References ANDGroupDescription().

31 { return new ANDGroupDescription(*this); }
ANDGroupDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)

◆ exists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 168 of file ANDGroupDescription.cc.

References node_left_, node_right_, and muonDTDigis_cfi::pset.

168  {
169  return node_left_->exists(pset) && node_right_->exists(pset);
170  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

◆ hasNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 49 of file ANDGroupDescription.h.

49 { return true; }

◆ howManyXORSubNodesExist_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 176 of file ANDGroupDescription.cc.

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

176 { return exists(pset) ? 1 : 0; }
bool exists(ParameterSet const &pset) const

◆ partiallyExists_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 172 of file ANDGroupDescription.cc.

References node_left_, node_right_, and muonDTDigis_cfi::pset.

172  {
173  return node_left_->partiallyExists(pset) || node_right_->partiallyExists(pset);
174  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

◆ print_()

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

Reimplemented from edm::ParameterDescriptionNode.

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

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

◆ printNestedContent_()

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 118 of file ANDGroupDescription.cc.

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, l1tGTMenu_BTagSeeds_cff::os, 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.

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

◆ throwIfDuplicateLabels()

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

Definition at line 178 of file ANDGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

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

◆ throwIfDuplicateTypes()

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

Definition at line 197 of file ANDGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

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

◆ 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.

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

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_
optional
Definition: Types.py:245
bool partiallyExists(ParameterSet const &pset) const

◆ writeCfi_()

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

Implements edm::ParameterDescriptionNode.

Definition at line 63 of file ANDGroupDescription.cc.

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

68  {
69  node_left_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething);
70  node_right_->writeCfi(os, optional, startWithComma, indentation, options, wroteSomething);
71  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
optional
Definition: Types.py:245

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