CMS 3D CMS Logo

ParameterDescription.h
Go to the documentation of this file.
1 #ifndef FWCore_ParameterSet_ParameterDescription_h
2 #define FWCore_ParameterSet_ParameterDescription_h
3 // -*- C++ -*-
4 //
5 // Package: ParameterSet
6 // Class : ParameterDescription
7 //
16 //
17 // Original Author: Chris Jones
18 // Created: Thu Aug 2 15:33:51 EDT 2007
19 //
20 
25 
26 #include <string>
27 #include <vector>
28 #include <iosfwd>
29 #include <set>
30 
31 namespace edm {
32 
34 
35  class EventID;
36  class LuminosityBlockID;
38  class EventRange;
39  class InputTag;
40  class ESInputTag;
41  class FileInPath;
42  class DocFormatHelper;
43 
44  namespace writeParameterValue {
45 
46  enum ValueFormat { CFI, DOC };
47 
48  void writeValue(std::ostream& os, int indentation, int const& value_, ValueFormat format);
49  void writeValue(std::ostream& os, int indentation, std::vector<int> const& value_, ValueFormat format);
50  void writeValue(std::ostream& os, int indentation, unsigned const& value_, ValueFormat format);
51  void writeValue(std::ostream& os, int indentation, std::vector<unsigned> const& value_, ValueFormat format);
52  void writeValue(std::ostream& os, int indentation, long long const& value_, ValueFormat format);
53  void writeValue(std::ostream& os, int indentation, std::vector<long long> const& value_, ValueFormat format);
54  void writeValue(std::ostream& os, int indentation, unsigned long long const& value_, ValueFormat format);
55  void writeValue(std::ostream& os,
56  int indentation,
57  std::vector<unsigned long long> const& value_,
59  void writeValue(std::ostream& os, int indentation, double const& value_, ValueFormat format);
60  void writeValue(std::ostream& os, int indentation, std::vector<double> const& value_, ValueFormat format);
61  void writeValue(std::ostream& os, int indentation, bool const& value_, ValueFormat format);
62  void writeValue(std::ostream& os, int indentation, std::string const& value_, ValueFormat format);
63  void writeValue(std::ostream& os, int indentation, std::vector<std::string> const& value_, ValueFormat format);
64  void writeValue(std::ostream& os, int indentation, EventID const& value_, ValueFormat format);
65  void writeValue(std::ostream& os, int indentation, std::vector<EventID> const& value_, ValueFormat format);
66  void writeValue(std::ostream& os, int indentation, LuminosityBlockID const& value_, ValueFormat format);
67  void writeValue(std::ostream& os, int indentation, std::vector<LuminosityBlockID> const& value_, ValueFormat format);
68  void writeValue(std::ostream& os, int indentation, LuminosityBlockRange const& value_, ValueFormat format);
69  void writeValue(std::ostream& os,
70  int indentation,
71  std::vector<LuminosityBlockRange> const& value_,
73  void writeValue(std::ostream& os, int indentation, EventRange const& value_, ValueFormat format);
74  void writeValue(std::ostream& os, int indentation, std::vector<EventRange> const& value_, ValueFormat format);
75  void writeValue(std::ostream& os, int indentation, InputTag const& value_, ValueFormat format);
76  void writeValue(std::ostream& os, int indentation, std::vector<InputTag> const& value_, ValueFormat format);
77  void writeValue(std::ostream& os, int indentation, ESInputTag const& value_, ValueFormat format);
78  void writeValue(std::ostream& os, int indentation, std::vector<ESInputTag> const& value_, ValueFormat format);
79  void writeValue(std::ostream& os, int indentation, FileInPath const& value_, ValueFormat format);
80 
81  bool hasNestedContent(int const& value);
82  bool hasNestedContent(std::vector<int> const& value);
83  bool hasNestedContent(unsigned const& value);
84  bool hasNestedContent(std::vector<unsigned> const& value);
85  bool hasNestedContent(long long const& value);
86  bool hasNestedContent(std::vector<long long> const& value);
87  bool hasNestedContent(unsigned long long const& value);
88  bool hasNestedContent(std::vector<unsigned long long> const& value);
89  bool hasNestedContent(double const& value);
90  bool hasNestedContent(std::vector<double> const& value);
91  bool hasNestedContent(bool const& value);
92  bool hasNestedContent(std::string const& value);
93  bool hasNestedContent(std::vector<std::string> const& value);
94  bool hasNestedContent(EventID const& value);
95  bool hasNestedContent(std::vector<EventID> const& value);
97  bool hasNestedContent(std::vector<LuminosityBlockID> const& value);
99  bool hasNestedContent(std::vector<LuminosityBlockRange> const& value);
100  bool hasNestedContent(EventRange const& value);
101  bool hasNestedContent(std::vector<EventRange> const& value);
102  bool hasNestedContent(InputTag const& value);
103  bool hasNestedContent(std::vector<InputTag> const& value);
104  bool hasNestedContent(ESInputTag const& value);
105  bool hasNestedContent(std::vector<ESInputTag> const& value);
106  bool hasNestedContent(FileInPath const& value);
107  } // namespace writeParameterValue
108 
109  template <typename T>
111  public:
112  ParameterDescription(std::string const& iLabel, T const& value, bool isTracked, Comment const& iComment = Comment())
113  : // WARNING: the toEnum function is intentionally undefined if the template
114  // parameter is ParameterSet or vector<ParameterSet>. Both of these cases
115  // are handled by full template specializations below. In the first case.
116  // ParameterSetDescription should be used instead of ParameterSet.
117  // In the second case the function arguments are completely different.
118  // Note that this template parameter is most often passed through from
119  // an add*<T> function of class ParameterSetDescription. For vector<ParameterSet>
120  // use the addVPSet* versions of those functions.
121  ParameterDescriptionBase(iLabel, ParameterTypeToEnum::toEnum<T>(), isTracked, true, iComment),
122  value_(value) {}
123 
124  ParameterDescription(char const* iLabel, T const& value, bool isTracked, Comment const& iComment = Comment())
125  : // WARNING: the toEnum function is intentionally undefined if the template
126  // parameter is ParameterSet or vector<ParameterSet>. Both of these cases
127  // are handled by full template specializations below. In the first case.
128  // ParameterSetDescription should be used instead of ParameterSet.
129  // In the second case the function arguments are completely different.
130  // Note that this template parameter is most often passed through from
131  // an add*<T> function of class ParameterSetDescription. For vector<ParameterSet>
132  // use the addVPSet* versions of those functions.
133  ParameterDescriptionBase(iLabel, ParameterTypeToEnum::toEnum<T>(), isTracked, true, iComment),
134  value_(value) {}
135 
136  ParameterDescription(std::string const& iLabel, bool isTracked, Comment const& iComment = Comment())
137  : // WARNING: the toEnum function is intentionally undefined if the template
138  // parameter is ParameterSet or vector<ParameterSet>. Both of these cases
139  // are handled by full template specializations below. In the first case.
140  // ParameterSetDescription should be used instead of ParameterSet.
141  // In the second case the function arguments are completely different.
142  // Note that this template parameter is most often passed through from
143  // an add*<T> function of class ParameterSetDescription. For vector<ParameterSet>
144  // use the addVPSet* versions of those functions.
145  ParameterDescriptionBase(iLabel, ParameterTypeToEnum::toEnum<T>(), isTracked, false, iComment),
146  value_() {}
147 
148  ParameterDescription(char const* iLabel, bool isTracked, Comment const& iComment = Comment())
149  : // WARNING: the toEnum function is intentionally undefined if the template
150  // parameter is ParameterSet or vector<ParameterSet>. Both of these cases
151  // are handled by full template specializations below. In the first case.
152  // ParameterSetDescription should be used instead of ParameterSet.
153  // In the second case the function arguments are completely different.
154  // Note that this template parameter is most often passed through from
155  // an add*<T> function of class ParameterSetDescription. For vector<ParameterSet>
156  // use the addVPSet* versions of those functions.
157  ParameterDescriptionBase(iLabel, ParameterTypeToEnum::toEnum<T>(), isTracked, false, iComment),
158  value_() {}
159 
160  ~ParameterDescription() override {}
161 
162  ParameterDescriptionNode* clone() const override { return new ParameterDescription(*this); }
163 
164  T getDefaultValue() const { return value_; }
165 
166  private:
167  bool exists_(ParameterSet const& pset) const override { return pset.existsAs<T>(label(), isTracked()); }
168 
169  bool hasNestedContent_() const override {
170  if (!hasDefault())
171  return false;
173  }
174 
175  void writeCfi_(std::ostream& os, int indentation) const override {
177  }
178 
179  void writeDoc_(std::ostream& os, int indentation) const override {
181  }
182 
183  bool exists_(ParameterSet const& pset, bool isTracked) const override {
184  return pset.existsAs<T>(label(), isTracked);
185  }
186 
187  void insertDefault_(ParameterSet& pset) const override {
188  if (isTracked()) {
189  pset.addParameter(label(), value_);
190  } else {
191  pset.addUntrackedParameter(label(), value_);
192  }
193  }
194 
196  };
197 
198  template <>
200  public:
201  ParameterDescription(std::string const& iLabel,
203  bool isTracked,
204  Comment const& iComment = Comment());
205 
206  ParameterDescription(char const* iLabel,
208  bool isTracked,
209  Comment const& iComment = Comment());
210 
211  ~ParameterDescription() override;
212 
213  ParameterSetDescription const* parameterSetDescription() const override;
215 
216  ParameterDescriptionNode* clone() const override { return new ParameterDescription(*this); }
217 
218  private:
219  void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
220 
221  void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const override;
222 
223  bool hasNestedContent_() const override;
224 
225  void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const override;
226 
227  bool exists_(ParameterSet const& pset) const override;
228 
229  void writeCfi_(std::ostream& os, int indentation) const override;
230 
231  void writeDoc_(std::ostream& os, int indentation) const override;
232 
233  bool exists_(ParameterSet const& pset, bool isTracked) const override;
234 
235  void insertDefault_(ParameterSet& pset) const override;
236 
238  };
239 
240  template <>
241  class ParameterDescription<std::vector<ParameterSet> > : public ParameterDescriptionBase {
242  public:
243  ParameterDescription(std::string const& iLabel,
244  ParameterSetDescription const& psetDesc,
245  bool isTracked,
246  std::vector<ParameterSet> const& vPset,
247  Comment const& iComment = Comment());
248 
249  ParameterDescription(char const* iLabel,
250  ParameterSetDescription const& psetDesc,
251  bool isTracked,
252  std::vector<ParameterSet> const& vPset,
253  Comment const& iComment = Comment());
254 
255  ParameterDescription(std::string const& iLabel,
256  ParameterSetDescription const& psetDesc,
257  bool isTracked,
258  Comment const& iComment = Comment());
259 
260  ParameterDescription(char const* iLabel,
261  ParameterSetDescription const& psetDesc,
262  bool isTracked,
263  Comment const& iComment = Comment());
264 
265  ~ParameterDescription() override;
266 
267  ParameterSetDescription const* parameterSetDescription() const override;
269 
270  ParameterDescriptionNode* clone() const override { return new ParameterDescription(*this); }
271 
272  void setPartOfDefaultOfVPSet(bool value) { partOfDefaultOfVPSet_ = value; }
273 
274  private:
275  void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
276 
277  void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const override;
278 
279  bool hasNestedContent_() const override;
280 
281  void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const override;
282 
283  bool exists_(ParameterSet const& pset) const override;
284 
285  void writeCfi_(std::ostream& os, int indentation) const override;
286 
287  void writeDoc_(std::ostream& os, int indentation) const override;
288 
289  bool exists_(ParameterSet const& pset, bool isTracked) const override;
290 
291  void insertDefault_(ParameterSet& pset) const override;
292 
293  static void writeOneElementToCfi(ParameterSet const& pset,
294  std::ostream& os,
295  int indentation,
296  bool& nextOneStartsWithAComma);
297 
299  std::vector<ParameterSet> vPset_;
301  };
302 } // namespace edm
303 #endif
edm::ParameterDescriptionBase::printNestedContent_
void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const override
Definition: ParameterDescriptionBase.cc:236
edm::ParameterDescription::exists_
bool exists_(ParameterSet const &pset, bool isTracked) const override
Definition: ParameterDescription.h:183
ParameterSetDescriptionTraits.h
edm::ESInputTag
Definition: ESInputTag.h:87
edm::ParameterDescription::ParameterDescription
ParameterDescription(char const *iLabel, T const &value, bool isTracked, Comment const &iComment=Comment())
Definition: ParameterDescription.h:124
funct::false
false
Definition: Factorize.h:29
edm::writeParameterValue::ValueFormat
ValueFormat
Definition: ParameterDescription.h:46
edm::ParameterDescription::hasNestedContent_
bool hasNestedContent_() const override
Definition: ParameterDescription.h:169
edm::ParameterDescriptionBase::label
std::string const & label() const
Definition: ParameterDescriptionBase.h:37
ESInputTag
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::ParameterDescription< std::vector< ParameterSet > >::vPset_
std::vector< ParameterSet > vPset_
Definition: ParameterDescription.h:299
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
Types.optional
optional
Definition: Types.py:199
edm::writeParameterValue::hasNestedContent
bool hasNestedContent(int const &value)
Definition: ParameterDescription.cc:752
edm::writeParameterValue::DOC
Definition: ParameterDescription.h:46
edm::ParameterDescriptionBase::hasDefault
bool hasDefault() const
Definition: ParameterDescriptionBase.h:40
edm::ParameterDescription< ParameterSetDescription >::psetDesc_
value_ptr< ParameterSetDescription > psetDesc_
Definition: ParameterDescription.h:237
edm::ParameterDescription< std::vector< ParameterSet > >::partOfDefaultOfVPSet_
bool partOfDefaultOfVPSet_
Definition: ParameterDescription.h:300
edm::FileInPath
Definition: FileInPath.h:64
edm::DocFormatHelper
Definition: DocFormatHelper.h:15
edm::ParameterDescription< ParameterSetDescription >::clone
ParameterDescriptionNode * clone() const override
Definition: ParameterDescription.h:216
edm::ParameterDescriptionBase::parameterSetDescription
virtual ParameterSetDescription const * parameterSetDescription() const
Definition: ParameterDescriptionBase.h:42
edm::writeParameterValue::CFI
Definition: ParameterDescription.h:46
edm::LuminosityBlockID
Definition: LuminosityBlockID.h:31
ParameterDescriptionBase.h
edm::ParameterDescriptionBase::printDefault_
virtual void printDefault_(std::ostream &os, bool writeToCfi, DocFormatHelper &dfh) const
Definition: ParameterDescriptionBase.cc:215
value_ptr.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
funct::true
true
Definition: Factorize.h:173
edm::ParameterDescription::ParameterDescription
ParameterDescription(char const *iLabel, bool isTracked, Comment const &iComment=Comment())
Definition: ParameterDescription.h:148
edm::ParameterDescription::writeCfi_
void writeCfi_(std::ostream &os, int indentation) const override
Definition: ParameterDescription.h:175
edm::ParameterDescription::exists_
bool exists_(ParameterSet const &pset) const override
Definition: ParameterDescription.h:167
edm::ParameterSet
Definition: ParameterSet.h:47
edm::Comment
Definition: ParameterDescriptionNode.h:71
edm::ParameterDescription::ParameterDescription
ParameterDescription(std::string const &iLabel, bool isTracked, Comment const &iComment=Comment())
Definition: ParameterDescription.h:136
edm::ParameterDescriptionBase::validate_
void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const override
Definition: ParameterDescriptionBase.cc:98
edm::value_ptr
Definition: value_ptr.h:63
edm::ParameterDescription::insertDefault_
void insertDefault_(ParameterSet &pset) const override
Definition: ParameterDescription.h:187
value
Definition: value.py:1
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
edm::ParameterDescriptionBase
Definition: ParameterDescriptionBase.h:33
edm::ParameterDescription::writeDoc_
void writeDoc_(std::ostream &os, int indentation) const override
Definition: ParameterDescription.h:179
LuminosityBlockRange
edm::ParameterDescription< std::vector< ParameterSet > >::clone
ParameterDescriptionNode * clone() const override
Definition: ParameterDescription.h:270
std
Definition: JetResolutionObject.h:76
edm::ParameterDescriptionBase::isTracked
bool isTracked() const
Definition: ParameterDescriptionBase.h:39
edm::ParameterDescription::getDefaultValue
T getDefaultValue() const
Definition: ParameterDescription.h:164
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ParameterDescription< std::vector< ParameterSet > >::psetDesc_
value_ptr< ParameterSetDescription > psetDesc_
Definition: ParameterDescription.h:298
relativeConstraints.value
value
Definition: relativeConstraints.py:53
edm::ParameterDescription< std::vector< ParameterSet > >::setPartOfDefaultOfVPSet
void setPartOfDefaultOfVPSet(bool value)
Definition: ParameterDescription.h:272
format
ParameterSetDescription
printContent_cfi.indentation
indentation
Definition: printContent_cfi.py:10
edm::ParameterDescription::~ParameterDescription
~ParameterDescription() override
Definition: ParameterDescription.h:160
ParameterSet.h
edm::ParameterDescription::value_
T value_
Definition: ParameterDescription.h:195
edm::EventID
Definition: EventID.h:31
edm::ParameterDescription::ParameterDescription
ParameterDescription(std::string const &iLabel, T const &value, bool isTracked, Comment const &iComment=Comment())
Definition: ParameterDescription.h:112
edm::EventRange
Definition: EventRange.h:31
edm::ParameterTypeToEnum
Definition: ParameterDescriptionNode.h:66
edm::ParameterDescriptionNode
Definition: ParameterDescriptionNode.h:82
edm::ParameterDescription
Definition: ParameterDescription.h:110
edm::InputTag
Definition: InputTag.h:15
edm::writeParameterValue::writeValue
void writeValue(std::ostream &os, int indentation, int const &value_, ValueFormat format)
Definition: ParameterDescription.cc:639
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
edm::LuminosityBlockRange
Definition: LuminosityBlockRange.h:32
edm::ParameterDescription::clone
ParameterDescriptionNode * clone() const override
Definition: ParameterDescription.h:162