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

#include <IfExistsDescription.h>

Inheritance diagram for edm::IfExistsDescription:
edm::ParameterDescriptionNode

Public Member Functions

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

Constructor & Destructor Documentation

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

Definition at line 14 of file IfExistsDescription.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::IfExistsDescription::IfExistsDescription ( std::auto_ptr< ParameterDescriptionNode node_left,
ParameterDescriptionNode const &  node_right 
)

Definition at line 21 of file IfExistsDescription.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::IfExistsDescription::IfExistsDescription ( ParameterDescriptionNode const &  node_left,
std::auto_ptr< ParameterDescriptionNode node_right 
)

Definition at line 28 of file IfExistsDescription.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::IfExistsDescription::IfExistsDescription ( std::auto_ptr< ParameterDescriptionNode node_left,
std::auto_ptr< ParameterDescriptionNode node_right 
)

Definition at line 35 of file IfExistsDescription.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::IfExistsDescription::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 IfExistsDescription.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 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_
virtual ParameterDescriptionNode* edm::IfExistsDescription::clone ( void  ) const
inlinevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 32 of file IfExistsDescription.h.

References IfExistsDescription().

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

Implements edm::ParameterDescriptionNode.

Definition at line 205 of file IfExistsDescription.cc.

References node_left_, and node_right_.

205  {
206  bool leftExists = node_left_->exists(pset);
207  bool rightExists = node_right_->exists(pset);
208 
209  if (leftExists && rightExists) return true;
210  else if (!leftExists && !rightExists) return true;
211  return false;
212  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
virtual bool edm::IfExistsDescription::hasNestedContent_ ( )
inlineprivatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 56 of file IfExistsDescription.h.

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

Implements edm::ParameterDescriptionNode.

Definition at line 222 of file IfExistsDescription.cc.

References edm::ParameterDescriptionNode::exists().

222  {
223  return exists(pset) ? 1 : 0;
224  }
bool exists(ParameterSet const &pset) const
bool edm::IfExistsDescription::partiallyExists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 216 of file IfExistsDescription.cc.

References edm::ParameterDescriptionNode::exists().

216  {
217  return exists(pset);
218  }
bool exists(ParameterSet const &pset) const
void edm::IfExistsDescription::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 109 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

112  {
113 
114  if (dfh.pass() == 1) {
115 
116  dfh.indent(os);
117  os << "IfExists pair:";
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)
std::string const & comment() const
void edm::IfExistsDescription::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 155 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), node_left_, node_right_, edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::OTHER, edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setCounter(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setParent(), edm::DocFormatHelper::setPass(), edm::DocFormatHelper::setSection(), and edm::DocFormatHelper::TOP.

157  {
158 
159  int indentation = dfh.indentation();
160  if (dfh.parent() != DocFormatHelper::TOP) {
161  indentation -= DocFormatHelper::offsetSectionContent();
162  }
163 
164  std::stringstream ss;
165  ss << dfh.section() << "." << dfh.counter();
166  std::string newSection = ss.str();
167 
168  printSpaces(os, indentation);
169  os << "Section " << newSection;
170  if (optional) os << " optional";
171  os << " IfExists pair description:\n";
172  printSpaces(os, indentation);
173  if (optional) {
174  os << "If the first parameter exists, then the second is allowed to exist\n";
175  }
176  else {
177  os << "If the first parameter exists, then the second is required to exist\n";
178  }
179  if (!dfh.brief()) os << "\n";
180 
181  DocFormatHelper new_dfh(dfh);
182  new_dfh.init();
183  new_dfh.setSection(newSection);
184  new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
185  new_dfh.setParent(DocFormatHelper::OTHER);
186 
187  node_left_->print(os, false, true, new_dfh);
188  node_right_->print(os, false, true, new_dfh);
189 
190  new_dfh.setPass(1);
191  new_dfh.setCounter(0);
192 
193  node_left_->print(os, false, true, new_dfh);
194  node_right_->print(os, false, true, new_dfh);
195 
196  new_dfh.setPass(2);
197  new_dfh.setCounter(0);
198 
199  node_left_->printNestedContent(os, false, new_dfh);
200  node_right_->printNestedContent(os, false , new_dfh);
201  }
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::IfExistsDescription::throwIfDuplicateLabels ( std::set< std::string > const &  labelsLeft,
std::set< std::string > const &  labelsRight 
) const
private

Definition at line 228 of file IfExistsDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

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

Definition at line 256 of file IfExistsDescription.cc.

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

Referenced by checkAndGetLabelsAndTypes_().

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

Implements edm::ParameterDescriptionNode.

Definition at line 73 of file IfExistsDescription.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  return;
82  }
83  else if (leftExists && rightExists) {
84  node_left_->validate(pset, validatedLabels, false);
85  node_right_->validate(pset, validatedLabels, false);
86  }
87  else if (leftExists && !rightExists) {
88  node_left_->validate(pset, validatedLabels, false);
89  if (!optional) node_right_->validate(pset, validatedLabels, false);
90  }
91  else if (!leftExists && rightExists) {
92  node_left_->validate(pset, validatedLabels, false);
93  node_right_->validate(pset, validatedLabels, false);
94  }
95  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
void edm::IfExistsDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 99 of file IfExistsDescription.cc.

References node_left_, and node_right_.

102  {
103  node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
104  node_right_->writeCfi(os, startWithComma, indentation, wroteSomething);
105  }
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_

Member Data Documentation

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