CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::auto_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &node_right)
 
 ANDGroupDescription (ParameterDescriptionNode const &node_left, std::auto_ptr< ParameterDescriptionNode > node_right)
 
 ANDGroupDescription (std::auto_ptr< ParameterDescriptionNode > node_left, std::auto_ptr< ParameterDescriptionNode > node_right)
 
virtual ParameterDescriptionNodeclone () const
 
- 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 ()
 
int howManyXORSubNodesExist (ParameterSet const &pset) const
 
bool partiallyExists (ParameterSet const &pset) const
 
void print (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
 
void printNestedContent (std::ostream &os, bool optional, DocFormatHelper &dfh)
 
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

virtual void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
virtual bool exists_ (ParameterSet const &pset) const
 
virtual bool hasNestedContent_ ()
 
virtual int howManyXORSubNodesExist_ (ParameterSet const &pset) const
 
virtual bool partiallyExists_ (ParameterSet const &pset) const
 
virtual void print_ (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
 
virtual void printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh)
 
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
 
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
 
virtual void writeCfi_ (std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const
 

Private Attributes

edm::value_ptr
< ParameterDescriptionNode
node_left_
 
edm::value_ptr
< ParameterDescriptionNode
node_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 14 of file ANDGroupDescription.cc.

Referenced by clone().

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

Definition at line 21 of file ANDGroupDescription.cc.

22  :
23  node_left_(node_left),
24  node_right_(node_right.clone()) {
25  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::ANDGroupDescription::ANDGroupDescription ( ParameterDescriptionNode const &  node_left,
std::auto_ptr< ParameterDescriptionNode node_right 
)

Definition at line 28 of file ANDGroupDescription.cc.

29  :
30  node_left_(node_left.clone()),
31  node_right_(node_right) {
32  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::ANDGroupDescription::ANDGroupDescription ( std::auto_ptr< ParameterDescriptionNode node_left,
std::auto_ptr< ParameterDescriptionNode node_right 
)

Definition at line 35 of file ANDGroupDescription.cc.

36  :
37  node_left_(node_left),
38  node_right_(node_right) {
39  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 43 of file ANDGroupDescription.cc.

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

45  {
46 
47  std::set<std::string> labelsLeft;
48  std::set<ParameterTypes> parameterTypesLeft;
49  std::set<ParameterTypes> wildcardTypesLeft;
50  node_left_->checkAndGetLabelsAndTypes(labelsLeft, parameterTypesLeft, wildcardTypesLeft);
51 
52  std::set<std::string> labelsRight;
53  std::set<ParameterTypes> parameterTypesRight;
54  std::set<ParameterTypes> wildcardTypesRight;
55  node_right_->checkAndGetLabelsAndTypes(labelsRight, parameterTypesRight, wildcardTypesRight);
56 
57  throwIfDuplicateLabels(labelsLeft, labelsRight);
58  throwIfDuplicateTypes(wildcardTypesLeft, parameterTypesRight);
59  throwIfDuplicateTypes(wildcardTypesRight, parameterTypesLeft);
60 
61  usedLabels.insert(labelsLeft.begin(), labelsLeft.end());
62  usedLabels.insert(labelsRight.begin(), labelsRight.end());
63 
64  parameterTypes.insert(parameterTypesRight.begin(), parameterTypesRight.end());
65  parameterTypes.insert(parameterTypesLeft.begin(), parameterTypesLeft.end());
66 
67  wildcardTypes.insert(wildcardTypesRight.begin(), wildcardTypesRight.end());
68  wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end());
69  }
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
virtual ParameterDescriptionNode* edm::ANDGroupDescription::clone ( void  ) const
inlinevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 32 of file ANDGroupDescription.h.

References ANDGroupDescription().

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

Implements edm::ParameterDescriptionNode.

Definition at line 203 of file ANDGroupDescription.cc.

References node_left_, and node_right_.

203  {
204  return node_left_->exists(pset) && node_right_->exists(pset);
205  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
virtual bool edm::ANDGroupDescription::hasNestedContent_ ( )
inlineprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 56 of file ANDGroupDescription.h.

56  {
57  return true;
58  }
int edm::ANDGroupDescription::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 215 of file ANDGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

215  {
216  return exists(pset) ? 1 : 0;
217  }
bool exists(ParameterSet const &pset) const
bool edm::ANDGroupDescription::partiallyExists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 209 of file ANDGroupDescription.cc.

References node_left_, and node_right_.

209  {
210  return node_left_->partiallyExists(pset) || node_right_->partiallyExists(pset);
211  }
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 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 94 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().

97  {
98 
99  if (dfh.parent() == DocFormatHelper::AND) {
100  dfh.decrementCounter();
101  node_left_->print(os, false, true, dfh);
102  node_right_->print(os, false, true, dfh);
103  return;
104  }
105 
106  if (dfh.pass() == 1) {
107 
108  dfh.indent(os);
109  os << "AND group:";
110 
111  if (dfh.brief()) {
112 
113  if (optional) os << " optional";
114 
115  if (!writeToCfi) os << " (do not write to cfi)";
116 
117  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
118  }
119  // not brief
120  else {
121 
122  os << "\n";
123  dfh.indent2(os);
124 
125  if (optional) os << "optional";
126  if (!writeToCfi) os << " (do not write to cfi)";
127  if (optional || !writeToCfi) {
128  os << "\n";
129  dfh.indent2(os);
130  }
131 
132  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
133 
134  if (!comment().empty()) {
136  comment(),
137  dfh.startColumn2(),
138  dfh.commentWidth());
139  }
140  os << "\n";
141  }
142  }
143  }
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 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 147 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(), contentValuesCheck::ss, AlCaHLTBitMon_QueryRunRegistry::string, and edm::DocFormatHelper::TOP.

149  {
150 
151  if (dfh.parent() == DocFormatHelper::AND) {
152  dfh.decrementCounter();
153  node_left_->printNestedContent(os, false, dfh);
154  node_right_->printNestedContent(os, false, dfh);
155  return;
156  }
157 
158  int indentation = dfh.indentation();
159  if (dfh.parent() != DocFormatHelper::TOP) {
160  indentation -= DocFormatHelper::offsetSectionContent();
161  }
162 
163  std::stringstream ss;
164  ss << dfh.section() << "." << dfh.counter();
165  std::string newSection = ss.str();
166 
167  printSpaces(os, indentation);
168  os << "Section " << newSection
169  << " AND group description:\n";
170  printSpaces(os, indentation);
171  if (optional) {
172  os << "This optional AND group requires all or none of the following to be in the PSet\n";
173  }
174  else {
175  os << "This AND group requires all of the following to be in the PSet\n";
176  }
177  if (!dfh.brief()) os << "\n";
178 
179  DocFormatHelper new_dfh(dfh);
180  new_dfh.init();
181  new_dfh.setSection(newSection);
182  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
183  new_dfh.setParent(DocFormatHelper::AND);
184 
185  node_left_->print(os, false, true, new_dfh);
186  node_right_->print(os, false, true, new_dfh);
187 
188  new_dfh.setPass(1);
189  new_dfh.setCounter(0);
190 
191  node_left_->print(os, false, true, new_dfh);
192  node_right_->print(os, false, true, new_dfh);
193 
194  new_dfh.setPass(2);
195  new_dfh.setCounter(0);
196 
197  node_left_->printNestedContent(os, false, new_dfh);
198  node_right_->printNestedContent(os, false, new_dfh);
199  }
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 221 of file ANDGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

222  {
223 
224  std::set<std::string> duplicateLabels;
225  std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
226  std::set_intersection(labelsLeft.begin(), labelsLeft.end(),
227  labelsRight.begin(), labelsRight.end(),
228  insertIter);
229  if (!duplicateLabels.empty()) {
230  std::stringstream ss;
231  for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(),
232  iEnd = duplicateLabels.end();
233  iter != iEnd;
234  ++iter) {
235  ss << " \"" << *iter << "\"\n";
236  }
238  << "Labels used in different nodes of a ParameterSetDescription\n"
239  << "\"and\" expression must be unique. The following duplicate\n"
240  << "labels were detected:\n"
241  << ss.str()
242  << "\n";
243  }
244  }
void edm::ANDGroupDescription::throwIfDuplicateTypes ( std::set< ParameterTypes > const &  types1,
std::set< ParameterTypes > const &  types2 
) const
private

Definition at line 248 of file ANDGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

250  {
251  if (!types1.empty()) {
252  std::set<ParameterTypes> duplicateTypes;
253  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
254  std::set_intersection(types1.begin(), types1.end(),
255  types2.begin(), types2.end(),
256  insertIter);
257  if (!duplicateTypes.empty()) {
258  std::stringstream ss;
259  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(),
260  iEnd = duplicateTypes.end();
261  iter != iEnd;
262  ++iter) {
263  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
264  }
266  << "Types used for wildcards in different nodes of a ParameterSetDescription\n"
267  << "\"and\" expression must be different from types used for other parameters.\n"
268  << "The following duplicate types were detected:\n"
269  << ss.str()
270  << "\n";
271  }
272  }
273  }
std::string parameterTypeEnumToString(ParameterTypes iType)
void edm::ANDGroupDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 73 of file ANDGroupDescription.cc.

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

75  {
76  if (partiallyExists(pset) || !optional) {
77  node_left_->validate(pset, validatedLabels, false);
78  node_right_->validate(pset, validatedLabels, false);
79  }
80  }
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
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 84 of file ANDGroupDescription.cc.

References node_left_, and node_right_.

87  {
88  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
89  node_right_->writeCfi(os, startWithComma, indentation, wroteSomething);
90  }
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