17 #include "boost/bind.hpp"
51 std::set<std::string>& validatedLabels,
52 bool optional)
const {
64 if(!optional && !exists) {
70 validatedLabels.insert(
label());
77 psetDesc_->validate(*containedPSet);
86 os <<
"see Section " << dfh.
section()
88 if(!writeToCfi) os <<
" (do not write to cfi)";
108 std::stringstream ss;
113 os <<
"Section " << newSection
114 <<
" " <<
label() <<
" PSet description:\n";
115 if(!dfh.
brief()) os <<
"\n";
123 psetDesc_->print(os, new_dfh);
135 return psetDesc_.operator->();
141 return psetDesc_.operator->();
147 bool startWithComma =
false;
149 psetDesc_->writeCfi(os, startWithComma, indentation);
178 std::vector<ParameterSet>
const& vPset) :
182 partOfDefaultOfVPSet_(
false) {
189 std::vector<ParameterSet>
const& vPset) :
193 partOfDefaultOfVPSet_(
false) {
203 partOfDefaultOfVPSet_(
false) {
213 partOfDefaultOfVPSet_(
false) {
217 ~ParameterDescription() { }
221 parameterSetDescription()
const {
222 return psetDesc_.operator->();
227 parameterSetDescription() {
228 return psetDesc_.operator->();
234 std::set<std::string>& validatedLabels,
235 bool optional)
const {
237 bool exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
240 validatedLabels.insert(
label());
241 }
else if(pset.
existsAs<std::vector<ParameterSet> >(
label(), !isTracked())) {
242 throwParameterWrongTrackiness();
244 throwParameterWrongType();
247 if(!exists && !optional) {
254 validatedLabels.insert(
label());
256 throwMissingRequiredNoDefault();
260 exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
265 for(
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
273 printDefault_(std::ostream& os,
276 os <<
"see Section " << dfh.
section()
278 if(!writeToCfi) os <<
" (do not write to cfi)";
285 hasNestedContent_() {
291 printNestedContent_(std::ostream& os,
300 if(!partOfDefaultOfVPSet_) {
301 printSpaces(os, indentation);
303 <<
" " <<
label() <<
" VPSet description:\n";
306 os <<
"All elements will be validated using the PSet description in Section "
309 printSpaces(os, indentation);
311 <<
" " <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
316 unsigned subsectionOffset = 2;
317 if(partOfDefaultOfVPSet_) subsectionOffset = 1;
320 if(vPset_.size() == 0U) os <<
"The default VPSet is empty.\n";
321 else if(vPset_.size() == 1U) os <<
"The default VPSet has 1 element.\n";
322 else os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
324 if(vPset_.size() > 0U) {
325 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
327 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section()
328 <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset) <<
"\n";
332 os <<
"Does not have a default VPSet.\n";
335 if(!dfh.
brief()) os <<
"\n";
337 if(!partOfDefaultOfVPSet_) {
339 std::stringstream ss;
343 printSpaces(os, indentation);
344 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
345 if(!dfh.
brief()) os <<
"\n";
353 psetDesc_->print(os, new_dfh);
357 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
359 std::stringstream ss;
360 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
363 printSpaces(os, indentation);
364 os <<
"Section " << newSection <<
" PSet description of "
365 <<
"default VPSet element [" <<
i <<
"]\n";
366 if(!dfh.
brief()) os <<
"\n";
377 defaultDescription.
print(os, new_dfh);
385 return pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
393 bool& nextOneStartsWithAComma) {
394 if(nextOneStartsWithAComma) os <<
",";
395 nextOneStartsWithAComma =
true;
397 printSpaces(os, indentation + 2);
401 bool startWithComma =
false;
402 int indent = indentation + 4;
406 psetDesc.
writeCfi(os, startWithComma, indent);
413 writeCfi_(std::ostream& os,
int indentation)
const {
414 bool nextOneStartsWithAComma =
false;
415 for_all(vPset_, boost::bind(&writeOneElementToCfi,
419 boost::ref(nextOneStartsWithAComma)));
421 printSpaces(os, indentation);
426 writeDoc_(std::ostream&,
int )
const {
446 namespace writeParameterValue {
474 s << std::setprecision(17) <<
value;
477 if(result.size() > 15 && std::string::npos != result.find(
".")) {
479 s << std::setprecision(15) <<
value;
482 if(resultLessPrecision.size() < result.size() - 2) {
483 double test = std::strtod(resultLessPrecision.c_str(), 0);
485 result = resultLessPrecision;
500 value ? os <<
"True" : os <<
"False";
505 os <<
"'" <<
value <<
"'";
511 os <<
value.run() <<
", " <<
value.luminosityBlock() <<
", " <<
value.event();
513 if(
value.luminosityBlock() == 0U) {
516 os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
524 else os <<
value.run() <<
":" <<
value.luminosityBlock();
529 if(
value.startLumi() == 0U) {
531 <<
value.endRun() <<
":" <<
value.endEvent() <<
"'";
532 else os <<
value.startRun() <<
":" <<
value.startEvent() <<
"-"
536 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent() <<
"'";
537 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
":" <<
value.startEvent() <<
"-"
538 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent();
545 <<
value.endRun() <<
":" <<
value.endLumi() <<
"'";
546 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
"-"
553 os <<
"'" <<
value.label() <<
"'";
554 if(!
value.instance().empty() || !
value.process().empty()) {
555 os <<
", '" <<
value.instance() <<
"'";
557 if(!
value.process().empty()) {
558 os <<
", '" <<
value.process() <<
"'";
561 os <<
"'" <<
value.label();
562 if(!
value.instance().empty() || !
value.process().empty()) {
563 os <<
":" <<
value.instance();
565 if(!
value.process().empty()) {
566 os <<
":" <<
value.process();
574 os <<
"'" <<
value.relativePath() <<
"'";
579 std::ios_base::fmtflags
ff = os.flags(std::ios_base::dec);
581 writeSingleValue<T>(os, value_,
format);
594 if(
value.luminosityBlock() == 0U) {
596 else os <<
value.run() <<
":" <<
value.event();
599 else os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
606 else os <<
value.run() <<
":" <<
value.luminosityBlock();
611 os <<
"'" <<
value.label();
612 if(!
value.instance().empty() || !
value.process().empty()) {
613 os <<
":" <<
value.instance();
615 if(!
value.process().empty()) {
616 os <<
":" <<
value.process();
625 bool& startWithComma,
628 if(startWithComma && format ==
CFI) os <<
",";
629 startWithComma =
true;
630 os <<
"\n" << std::setw(indentation) <<
"";
631 if(format ==
DOC) os <<
"[" << i <<
"]: ";
638 std::ios_base::fmtflags
ff = os.flags(std::ios_base::dec);
639 char oldFill = os.fill();
641 if(value_.size() == 0U && format ==
DOC) {
643 }
else if(value_.size() == 1U && format ==
CFI) {
644 writeValueInVector<T>(os, value_[0],
format);
645 }
else if(value_.size() >= 1U) {
646 if(format ==
DOC) os <<
"(vector size = " << value_.size() <<
")";
648 bool startWithComma =
false;
650 for_all(value_, boost::bind(&writeValueInVectorWithSpace<T>,
654 boost::ref(startWithComma),
657 if(format ==
CFI) os <<
"\n" << std::setw(indentation) <<
"";
664 writeValue<int>(os, value_,
format);
668 writeVector<int>(os, indentation, value_,
format);
672 writeValue<unsigned>(os, value_,
format);
676 writeVector<unsigned>(os, indentation, value_,
format);
680 writeValue<long long>(os, value_,
format);
684 writeVector<long long>(os, indentation, value_,
format);
688 writeValue<unsigned long long>(os, value_,
format);
692 writeVector<unsigned long long>(os, indentation, value_,
format);
696 writeValue<double>(os, value_,
format);
700 writeVector<double>(os, indentation, value_,
format);
704 writeValue<bool>(os, value_,
format);
708 writeValue<std::string>(os, value_,
format);
712 writeVector<std::string>(os, indentation, value_,
format);
716 writeValue<EventID>(os, value_,
format);
720 writeVector<EventID>(os, indentation, value_,
format);
724 writeValue<LuminosityBlockID>(os, value_,
format);
728 writeVector<LuminosityBlockID>(os, indentation, value_,
format);
732 writeValue<LuminosityBlockRange>(os, value_,
format);
736 writeVector<LuminosityBlockRange>(os, indentation, value_,
format);
740 writeValue<EventRange>(os, value_,
format);
744 writeVector<EventRange>(os, indentation, value_,
format);
748 writeValue<InputTag>(os, value_,
format);
752 writeVector<InputTag>(os, indentation, value_,
format);
756 writeValue<FileInPath>(os, value_,
format);
ParameterDescription(std::string const &iLabel, T const &value, bool isTracked)
void writeValueInVectorWithSpace(T const &value, std::ostream &os, int indentation, bool &startWithComma, ValueFormat format, int &i)
bool existsAs(std::string const ¶meterName, bool trackiness=true) const
checks if a parameter exists as a given type
virtual bool exists_(ParameterSet const &pset) const
virtual ~ParameterDescription()
bool exists(std::string const ¶meterName) const
checks if a parameter exists
void writeSingleValue< double >(std::ostream &os, double const &value, ValueFormat)
void writeSingleValue< bool >(std::ostream &os, bool const &value, ValueFormat)
void insert(bool ok_to_replace, char const *, Entry const &)
void writeCfi(std::ostream &os, bool startWithComma, int indentation) const
void fillDescriptionFromPSet(ParameterSet const &pset, ParameterSetDescription &desc)
void writeSingleValue< FileInPath >(std::ostream &os, FileInPath const &value, ValueFormat)
void writeVector(std::ostream &os, int indentation, std::vector< T > const &value_, ValueFormat format)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
virtual void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
virtual void printDefault_(std::ostream &os, bool writeToCfi, DocFormatHelper &dfh)
VParameterSetEntry * getPSetVectorForUpdate(std::string const &name)
void writeSingleValue< EventID >(std::ostream &os, EventID const &value, ValueFormat format)
void addParameter(std::string const &name, T const &value)
void writeSingleValue< EventRange >(std::ostream &os, EventRange const &value, ValueFormat format)
void writeValueInVector< EventID >(std::ostream &os, EventID const &value, ValueFormat format)
void print(std::ostream &os, DocFormatHelper &dfh) const
void throwParameterWrongType() const
void writeSingleValue(std::ostream &os, T const &value, ValueFormat)
virtual void insertDefault_(ParameterSet &pset) const
void writeValueInVector< InputTag >(std::ostream &os, InputTag const &value, ValueFormat)
void writeValueInVector(std::ostream &os, T const &value, ValueFormat format)
static void printSpaces(std::ostream &os, int n)
bool exists(ParameterSet const &pset) const
void writeValueInVector< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void addUntrackedParameter(std::string const &name, T const &value)
void throwParameterWrongTrackiness() const
virtual ParameterSetDescription const * parameterSetDescription() const
void writeValue(std::ostream &os, int indentation, int const &value_, ValueFormat format)
std::vector< ParameterSet >::size_type size() const
virtual void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh)
void formatDouble(double value, std::string &result)
void writeSingleValue< InputTag >(std::ostream &os, InputTag const &value, ValueFormat format)
ParameterSet & psetInVector(int i)
bool hasNestedContent(int const &value)
virtual void writeDoc_(std::ostream &os, int indentation) const
void writeSingleValue< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void writeSingleValue< LuminosityBlockRange >(std::ostream &os, LuminosityBlockRange const &value, ValueFormat format)
virtual bool hasNestedContent_()
virtual void writeCfi_(std::ostream &os, int indentation) const
ParameterSet * getPSetForUpdate(std::string const &name, bool &isTracked)
std::string const & label() const