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::ORGroupDescription Class Reference

#include <ORGroupDescription.h>

Inheritance diagram for edm::ORGroupDescription:
edm::ParameterDescriptionNode

Public Member Functions

virtual ParameterDescriptionNodeclone () const
 
 ORGroupDescription (ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
 
 ORGroupDescription (std::auto_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &node_right)
 
 ORGroupDescription (ParameterDescriptionNode const &node_left, std::auto_ptr< ParameterDescriptionNode > node_right)
 
 ORGroupDescription (std::auto_ptr< ParameterDescriptionNode > node_left, std::auto_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 ()
 
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 ORGroupDescription.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file ORGroupDescription.cc.

Referenced by clone().

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

Definition at line 21 of file ORGroupDescription.cc.

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

Definition at line 28 of file ORGroupDescription.cc.

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

Definition at line 35 of file ORGroupDescription.cc.

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

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 32 of file ORGroupDescription.h.

References ORGroupDescription().

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

Implements edm::ParameterDescriptionNode.

Definition at line 214 of file ORGroupDescription.cc.

References node_left_, and node_right_.

214  {
215  return node_left_->exists(pset) ||
216  node_right_->exists(pset);
217  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
virtual bool edm::ORGroupDescription::hasNestedContent_ ( )
inlineprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 56 of file ORGroupDescription.h.

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

Implements edm::ParameterDescriptionNode.

Definition at line 227 of file ORGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

227  {
228  return exists(pset) ? 1 : 0;
229  }
bool exists(ParameterSet const &pset) const
bool edm::ORGroupDescription::partiallyExists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 221 of file ORGroupDescription.cc.

References edm::ParameterDescriptionNode::exists().

221  {
222  return exists(pset);
223  }
bool exists(ParameterSet const &pset) const
void edm::ORGroupDescription::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 102 of file ORGroupDescription.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::OR, edm::DocFormatHelper::parent(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

105  {
106 
107  if (dfh.parent() == DocFormatHelper::OR) {
108  dfh.decrementCounter();
109  node_left_->print(os, false, true, dfh);
110  node_right_->print(os, false, true, dfh);
111  return;
112  }
113 
114  if (dfh.pass() == 1) {
115 
116  dfh.indent(os);
117  os << "OR group:";
118 
119  if (dfh.brief()) {
120 
121  if (optional) os << " optional";
122 
123  if (!writeToCfi) os << " (do not write to cfi)";
124 
125  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
126  }
127  // not brief
128  else {
129 
130  os << "\n";
131  dfh.indent2(os);
132 
133  if (optional) os << "optional";
134  if (!writeToCfi) os << " (do not write to cfi)";
135  if (optional || !writeToCfi) {
136  os << "\n";
137  dfh.indent2(os);
138  }
139 
140  os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";
141 
142  if (!comment().empty()) {
144  comment(),
145  dfh.startColumn2(),
146  dfh.commentWidth());
147  }
148  os << "\n";
149  }
150  }
151  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
edm::value_ptr< ParameterDescriptionNode > node_left_
std::string const & comment() const
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::ORGroupDescription::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 155 of file ORGroupDescription.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::OR, 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.

157  {
158 
159  if (dfh.parent() == DocFormatHelper::OR) {
160  dfh.decrementCounter();
161  node_left_->printNestedContent(os, false, dfh);
162  node_right_->printNestedContent(os, false, dfh);
163  return;
164  }
165 
166  int indentation = dfh.indentation();
167  if (dfh.parent() != DocFormatHelper::TOP) {
168  indentation -= DocFormatHelper::offsetSectionContent();
169  }
170 
171  std::stringstream ss;
172  ss << dfh.section() << "." << dfh.counter();
173  std::string newSection = ss.str();
174 
175  printSpaces(os, indentation);
176  os << "Section " << newSection
177  << " OR group description:\n";
178  printSpaces(os, indentation);
179  if (optional) {
180  // An optional OR group is kind of pointless, it would be
181  // easier just make the parameters be independent optional parameters
182  // I only allow it to make the behavior analogous to the other groups
183  os << "This optional OR group requires at least one or none of the following to be in the PSet\n";
184  }
185  else {
186  os << "This OR group requires at least one of the following to be in the PSet\n";
187  }
188  if (!dfh.brief()) os << "\n";
189 
190  DocFormatHelper new_dfh(dfh);
191  new_dfh.init();
192  new_dfh.setSection(newSection);
193  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
194  new_dfh.setParent(DocFormatHelper::OR);
195 
196  node_left_->print(os, false, true, new_dfh);
197  node_right_->print(os, false, true, new_dfh);
198 
199  new_dfh.setPass(1);
200  new_dfh.setCounter(0);
201 
202  node_left_->print(os, false, true, new_dfh);
203  node_right_->print(os, false, true, new_dfh);
204 
205  new_dfh.setPass(2);
206  new_dfh.setCounter(0);
207 
208  node_left_->printNestedContent(os, false, new_dfh);
209  node_right_->printNestedContent(os, false, new_dfh);
210  }
edm::value_ptr< ParameterDescriptionNode > node_left_
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::ORGroupDescription::throwIfDuplicateLabels ( std::set< std::string > const &  labelsLeft,
std::set< std::string > const &  labelsRight 
) const
private

Definition at line 233 of file ORGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

234  {
235 
236  std::set<std::string> duplicateLabels;
237  std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
238  std::set_intersection(labelsLeft.begin(), labelsLeft.end(),
239  labelsRight.begin(), labelsRight.end(),
240  insertIter);
241  if (!duplicateLabels.empty()) {
242  std::stringstream ss;
243  for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(),
244  iEnd = duplicateLabels.end();
245  iter != iEnd;
246  ++iter) {
247  ss << " \"" << *iter << "\"\n";
248  }
250  << "Labels used in a node of a ParameterSetDescription\n"
251  << "\"or\" expression must be not be the same as labels used\n"
252  << "in other nodes of the expression. The following duplicate\n"
253  << "labels were detected:\n"
254  << ss.str()
255  << "\n";
256  }
257  }
void edm::ORGroupDescription::throwIfDuplicateTypes ( std::set< ParameterTypes > const &  types1,
std::set< ParameterTypes > const &  types2 
) const
private

Definition at line 261 of file ORGroupDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

263  {
264  if (!types1.empty()) {
265  std::set<ParameterTypes> duplicateTypes;
266  std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
267  std::set_intersection(types1.begin(), types1.end(),
268  types2.begin(), types2.end(),
269  insertIter);
270  if (!duplicateTypes.empty()) {
271  std::stringstream ss;
272  for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(),
273  iEnd = duplicateTypes.end();
274  iter != iEnd;
275  ++iter) {
276  ss << " \"" << parameterTypeEnumToString(*iter) << "\"\n";
277  }
279  << "Types used for wildcards in a node of a ParameterSetDescription\n"
280  << "\"or\" expression must be different from types used for other parameters\n"
281  << "in other nodes. The following duplicate types were detected:\n"
282  << ss.str()
283  << "\n";
284  }
285  }
286  }
std::string parameterTypeEnumToString(ParameterTypes iType)
void edm::ORGroupDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 73 of file ORGroupDescription.cc.

References node_left_, and node_right_.

75  {
76 
77  bool leftExists = node_left_->exists(pset);
78  bool rightExists = node_right_->exists(pset);
79 
80  if (leftExists || rightExists) {
81  if (leftExists) node_left_->validate(pset, validatedLabels, false);
82  if (rightExists) node_right_->validate(pset, validatedLabels, false);
83  return;
84  }
85 
86  if (optional) return;
87 
88  node_left_->validate(pset, validatedLabels, false);
89  }
edm::value_ptr< ParameterDescriptionNode > node_left_
edm::value_ptr< ParameterDescriptionNode > node_right_
void edm::ORGroupDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 93 of file ORGroupDescription.cc.

References node_left_.

96  {
97  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
98  }
edm::value_ptr< ParameterDescriptionNode > node_left_

Member Data Documentation

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