CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
edm::AllowedLabelsDescriptionBase Class Referenceabstract

#include <AllowedLabelsDescriptionBase.h>

Inheritance diagram for edm::AllowedLabelsDescriptionBase:
edm::ParameterDescriptionNode edm::AllowedLabelsDescription< T > edm::AllowedLabelsDescription< ParameterSetDescription > edm::AllowedLabelsDescription< std::vector< ParameterSet > >

Public Member Functions

bool isTracked () const
 
ParameterTypes type () const
 
virtual ~AllowedLabelsDescriptionBase ()
 
- Public Member Functions inherited from edm::ParameterDescriptionNode
void checkAndGetLabelsAndTypes (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
 
virtual ParameterDescriptionNodeclone () const =0
 
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 ()
 

Protected Member Functions

 AllowedLabelsDescriptionBase (std::string const &label, ParameterTypes iType, bool isTracked)
 
 AllowedLabelsDescriptionBase (char const *label, ParameterTypes iType, bool isTracked)
 
void printNestedContentBase_ (std::ostream &os, bool optional, DocFormatHelper &dfh)
 

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)
 
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
 
virtual void validateAllowedLabel_ (std::string const &allowedLabel, ParameterSet &pset, std::set< std::string > &validatedLabels) const =0
 
virtual void writeCfi_ (std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const
 

Private Attributes

bool isTracked_
 
ParameterDescription
< std::vector< std::string > > 
parameterHoldingLabels_
 
ParameterTypes type_
 

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 16 of file AllowedLabelsDescriptionBase.h.

Constructor & Destructor Documentation

edm::AllowedLabelsDescriptionBase::~AllowedLabelsDescriptionBase ( )
virtual

Definition at line 13 of file AllowedLabelsDescriptionBase.cc.

13 { }
edm::AllowedLabelsDescriptionBase::AllowedLabelsDescriptionBase ( std::string const &  label,
ParameterTypes  iType,
bool  isTracked 
)
protected

Definition at line 16 of file AllowedLabelsDescriptionBase.cc.

16  :
17  parameterHoldingLabels_(label, std::vector<std::string>(), isTracked),
18  type_(iType),
20  }
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
edm::AllowedLabelsDescriptionBase::AllowedLabelsDescriptionBase ( char const *  label,
ParameterTypes  iType,
bool  isTracked 
)
protected

Definition at line 23 of file AllowedLabelsDescriptionBase.cc.

23  :
24  parameterHoldingLabels_(label, std::vector<std::string>(), isTracked),
25  type_(iType),
27  }
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 32 of file AllowedLabelsDescriptionBase.cc.

References edm::ParameterDescriptionNode::checkAndGetLabelsAndTypes(), and parameterHoldingLabels_.

34  {
35 
36  parameterHoldingLabels_.checkAndGetLabelsAndTypes(usedLabels, parameterTypes, wildcardTypes);
37  }
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
void checkAndGetLabelsAndTypes(std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
bool edm::AllowedLabelsDescriptionBase::exists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 171 of file AllowedLabelsDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists(), and parameterHoldingLabels_.

171  {
172  return parameterHoldingLabels_.exists(pset);
173  }
bool exists(ParameterSet const &pset) const
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
bool edm::AllowedLabelsDescriptionBase::hasNestedContent_ ( )
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 119 of file AllowedLabelsDescriptionBase.cc.

119  {
120  return true;
121  }
int edm::AllowedLabelsDescriptionBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 183 of file AllowedLabelsDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

183  {
184  return exists(pset) ? 1 : 0;
185  }
bool exists(ParameterSet const &pset) const
bool edm::AllowedLabelsDescriptionBase::isTracked ( ) const
inline
bool edm::AllowedLabelsDescriptionBase::partiallyExists_ ( ParameterSet const &  pset) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 177 of file AllowedLabelsDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

177  {
178  return exists(pset);
179  }
bool exists(ParameterSet const &pset) const
void edm::AllowedLabelsDescriptionBase::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 73 of file AllowedLabelsDescriptionBase.cc.

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

77  {
78  if (dfh.pass() == 1) {
79 
80  dfh.indent(os);
81  os << parameterHoldingLabels_.label() << " (list of allowed labels)";
82 
83  if (dfh.brief()) {
84 
85  if (optional) os << " optional";
86 
87  if (!writeToCfi) os << " (do not write to cfi)";
88 
89  os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
90  }
91  // not brief
92  else {
93 
94  os << "\n";
95  dfh.indent2(os);
96 
97  if (optional) os << "optional";
98  if (!writeToCfi) 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()) {
108  comment(),
109  dfh.startColumn2(),
110  dfh.commentWidth());
111  }
112  os << "\n";
113  }
114  }
115  }
static void wrapAndPrintText(std::ostream &os, std::string const &text, size_t indent, size_t suggestedWidth)
std::string const & comment() const
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
std::string const & label() const
void edm::AllowedLabelsDescriptionBase::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
privatevirtual

Reimplemented from edm::ParameterDescriptionNode.

Reimplemented in edm::AllowedLabelsDescription< std::vector< ParameterSet > >, and edm::AllowedLabelsDescription< ParameterSetDescription >.

Definition at line 126 of file AllowedLabelsDescriptionBase.cc.

References edm::DocFormatHelper::brief(), and printNestedContentBase_().

128  {
129  printNestedContentBase_(os, optional, dfh);
130  if (!dfh.brief()) os << "\n";
131  }
void printNestedContentBase_(std::ostream &os, bool optional, DocFormatHelper &dfh)
void edm::AllowedLabelsDescriptionBase::printNestedContentBase_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
)
protected

Definition at line 135 of file AllowedLabelsDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), isTracked(), edm::ParameterDescriptionBase::label(), edm::DocFormatHelper::offsetSectionContent(), parameterHoldingLabels_, edm::parameterTypeEnumToString(), edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::print(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setPass(), edm::DocFormatHelper::TOP, and type().

Referenced by printNestedContent_(), and edm::AllowedLabelsDescription< ParameterSetDescription >::printNestedContent_().

137  {
138 
139  int indentation = dfh.indentation();
140  if (dfh.parent() != DocFormatHelper::TOP) {
141  indentation -= DocFormatHelper::offsetSectionContent();
142  }
143 
144  printSpaces(os, indentation);
145  os << "Section " << dfh.section() << "." << dfh.counter()
146  << " " << parameterHoldingLabels_.label()
147  << " - allowed labels description\n";
148  printSpaces(os, indentation);
149  os << "The following parameter contains a list of parameter labels\n";
150  printSpaces(os, indentation);
151  os << "which are allowed to be in the PSet\n";
152  if (!dfh.brief()) os << "\n";
153 
154  DocFormatHelper new_dfh(dfh);
155  new_dfh.init();
156  new_dfh.setPass(1);
157  parameterHoldingLabels_.print(os, optional, true, new_dfh);
158  dfh.indent(os);
159  os << "type of allowed parameters:";
160  if (dfh.brief()) os << " ";
161  else {
162  os << "\n";
163  dfh.indent2(os);
164  }
165  if (!isTracked()) os << "untracked ";
166  os << parameterTypeEnumToString(type()) << "\n";
167  }
std::string parameterTypeEnumToString(ParameterTypes iType)
static int offsetSectionContent()
static void printSpaces(std::ostream &os, int n)
void print(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
std::string const & label() const
ParameterTypes edm::AllowedLabelsDescriptionBase::type ( ) const
inline

Definition at line 21 of file AllowedLabelsDescriptionBase.h.

References type_.

Referenced by cuy.ValElement::__init__(), and printNestedContentBase_().

void edm::AllowedLabelsDescriptionBase::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 41 of file AllowedLabelsDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists(), edm::for_all(), edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), isTracked(), edm::ParameterDescriptionBase::label(), parameterHoldingLabels_, edm::ParameterDescriptionNode::validate(), and validateAllowedLabel_().

43  {
44 
45  parameterHoldingLabels_.validate(pset, validatedLabels, optional);
46  if (parameterHoldingLabels_.exists(pset)) {
47  std::vector<std::string> allowedLabels;
48  if (isTracked()) {
49  allowedLabels = pset.getParameter<std::vector<std::string> >(parameterHoldingLabels_.label());
50  }
51  else {
52  allowedLabels = pset.getUntrackedParameter<std::vector<std::string> >(parameterHoldingLabels_.label());
53  }
55  this,
56  std::placeholders::_1,
57  std::ref(pset),
58  std::ref(validatedLabels)));
59  }
60  }
void validate(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
Definition: Algorithms.h:16
virtual void validateAllowedLabel_(std::string const &allowedLabel, ParameterSet &pset, std::set< std::string > &validatedLabels) const =0
bool exists(ParameterSet const &pset) const
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
std::string const & label() const
virtual void edm::AllowedLabelsDescriptionBase::validateAllowedLabel_ ( std::string const &  allowedLabel,
ParameterSet pset,
std::set< std::string > &  validatedLabels 
) const
privatepure virtual
void edm::AllowedLabelsDescriptionBase::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const
privatevirtual

Implements edm::ParameterDescriptionNode.

Definition at line 64 of file AllowedLabelsDescriptionBase.cc.

References parameterHoldingLabels_, and edm::ParameterDescriptionNode::writeCfi().

67  {
68  parameterHoldingLabels_.writeCfi(os, startWithComma, indentation, wroteSomething);
69  }
ParameterDescription< std::vector< std::string > > parameterHoldingLabels_
void writeCfi(std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const

Member Data Documentation

bool edm::AllowedLabelsDescriptionBase::isTracked_
private

Definition at line 73 of file AllowedLabelsDescriptionBase.h.

Referenced by isTracked().

ParameterDescription<std::vector<std::string> > edm::AllowedLabelsDescriptionBase::parameterHoldingLabels_
private
ParameterTypes edm::AllowedLabelsDescriptionBase::type_
private