17 #include "boost/bind.hpp"
51 std::set<std::string>& validatedLabels,
52 bool optional)
const {
66 if (!optional && !exists) {
73 validatedLabels.insert(
label());
80 psetDesc_->validate(*containedPSet);
89 os <<
"see Section " << dfh.
section()
91 if (!writeToCfi) os <<
" (do not write to cfi)";
111 std::stringstream ss;
113 std::string newSection = ss.str();
116 os <<
"Section " << newSection
117 <<
" " <<
label() <<
" PSet description:\n";
118 if (!dfh.
brief()) os <<
"\n";
126 psetDesc_->print(os, new_dfh);
138 return psetDesc_.operator->();
144 return psetDesc_.operator->();
150 bool startWithComma =
false;
152 psetDesc_->writeCfi(os, startWithComma, indentation);
181 std::vector<ParameterSet>
const& vPset) :
185 partOfDefaultOfVPSet_(
false) {
192 std::vector<ParameterSet>
const& vPset) :
196 partOfDefaultOfVPSet_(
false) {
206 partOfDefaultOfVPSet_(
false) {
216 partOfDefaultOfVPSet_(
false) {
220 ~ParameterDescription() { }
224 parameterSetDescription()
const {
225 return psetDesc_.operator->();
230 parameterSetDescription() {
231 return psetDesc_.operator->();
237 std::set<std::string>& validatedLabels,
238 bool optional)
const {
240 bool exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
243 validatedLabels.insert(
label());
245 else if (pset.
existsAs<std::vector<ParameterSet> >(
label(), !isTracked())) {
246 throwParameterWrongTrackiness();
249 throwParameterWrongType();
252 if (!exists && !optional) {
260 validatedLabels.insert(
label());
263 throwMissingRequiredNoDefault();
267 exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
272 for (
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
280 printDefault_(std::ostream& os,
283 os <<
"see Section " << dfh.
section()
285 if (!writeToCfi) os <<
" (do not write to cfi)";
292 hasNestedContent_() {
298 printNestedContent_(std::ostream& os,
307 if (!partOfDefaultOfVPSet_) {
308 printSpaces(os, indentation);
310 <<
" " <<
label() <<
" VPSet description:\n";
313 os <<
"All elements will be validated using the PSet description in Section "
317 printSpaces(os, indentation);
319 <<
" " <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
324 unsigned subsectionOffset = 2;
325 if (partOfDefaultOfVPSet_) subsectionOffset = 1;
328 if (vPset_.size() == 0U) os <<
"The default VPSet is empty.\n";
329 else if (vPset_.size() == 1U) os <<
"The default VPSet has 1 element.\n";
330 else os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
332 if (vPset_.size() > 0U) {
333 for (
unsigned i = 0;
i < vPset_.size(); ++
i) {
335 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section()
336 <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset) <<
"\n";
341 os <<
"Does not have a default VPSet.\n";
344 if (!dfh.
brief()) os <<
"\n";
346 if (!partOfDefaultOfVPSet_) {
348 std::stringstream ss;
350 std::string newSection = ss.str();
352 printSpaces(os, indentation);
353 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
354 if (!dfh.
brief()) os <<
"\n";
362 psetDesc_->print(os, new_dfh);
366 for (
unsigned i = 0;
i < vPset_.size(); ++
i) {
368 std::stringstream ss;
369 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
370 std::string newSection = ss.str();
372 printSpaces(os, indentation);
373 os <<
"Section " << newSection <<
" PSet description of "
374 <<
"default VPSet element [" <<
i <<
"]\n";
375 if (!dfh.
brief()) os <<
"\n";
386 defaultDescription.
print(os, new_dfh);
394 return pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
402 bool& nextOneStartsWithAComma) {
403 if (nextOneStartsWithAComma) os <<
",";
404 nextOneStartsWithAComma =
true;
406 printSpaces(os, indentation + 2);
410 bool startWithComma =
false;
411 int indent = indentation + 4;
415 psetDesc.
writeCfi(os, startWithComma, indent);
422 writeCfi_(std::ostream& os,
int indentation)
const {
423 bool nextOneStartsWithAComma =
false;
424 for_all(vPset_, boost::bind(&writeOneElementToCfi,
428 boost::ref(nextOneStartsWithAComma)));
430 printSpaces(os, indentation);
435 writeDoc_(std::ostream& os,
int indentation)
const {
455 namespace writeParameterValue {
483 s << std::setprecision(17) <<
value;
486 if (result.size() > 15 && std::string::npos != result.find(
".")) {
488 s << std::setprecision(15) <<
value;
489 std::string resultLessPrecision = s.str();
491 if (resultLessPrecision.size() < result.size() - 2) {
492 double test = std::strtod(resultLessPrecision.c_str(), 0);
494 result = resultLessPrecision;
509 value ? os <<
"True" : os <<
"False";
514 os <<
"'" <<
value <<
"'";
520 os <<
value.run() <<
", " <<
value.luminosityBlock() <<
", " <<
value.event();
522 if (
value.luminosityBlock() == 0U) {
525 os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
533 else os <<
value.run() <<
":" <<
value.luminosityBlock();
538 if (
value.startLumi() == 0U) {
540 <<
value.endRun() <<
":" <<
value.endEvent() <<
"'";
541 else os <<
value.startRun() <<
":" <<
value.startEvent() <<
"-"
545 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent() <<
"'";
546 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
":" <<
value.startEvent() <<
"-"
547 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent();
554 <<
value.endRun() <<
":" <<
value.endLumi() <<
"'";
555 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
"-"
562 os <<
"'" <<
value.label() <<
"'";
563 if (!
value.instance().empty() || !
value.process().empty()) {
564 os <<
", '" <<
value.instance() <<
"'";
566 if (!
value.process().empty()) {
567 os <<
", '" <<
value.process() <<
"'";
571 os <<
"'" <<
value.label();
572 if (!
value.instance().empty() || !
value.process().empty()) {
573 os <<
":" <<
value.instance();
575 if (!
value.process().empty()) {
576 os <<
":" <<
value.process();
584 os <<
"'" <<
value.relativePath() <<
"'";
589 std::ios_base::fmtflags
ff = os.flags(std::ios_base::dec);
591 writeSingleValue<T>(os, value_,
format);
604 if (
value.luminosityBlock() == 0U) {
606 else os <<
value.run() <<
":" <<
value.event();
609 else os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
616 else os <<
value.run() <<
":" <<
value.luminosityBlock();
621 os <<
"'" <<
value.label();
622 if (!
value.instance().empty() || !
value.process().empty()) {
623 os <<
":" <<
value.instance();
625 if (!
value.process().empty()) {
626 os <<
":" <<
value.process();
635 bool& startWithComma,
638 if (startWithComma && format ==
CFI) os <<
",";
639 startWithComma =
true;
640 os <<
"\n" << std::setw(indentation) <<
"";
641 if (format ==
DOC) os <<
"[" << i <<
"]: ";
648 std::ios_base::fmtflags
ff = os.flags(std::ios_base::dec);
649 char oldFill = os.fill();
651 if (value_.size() == 0U && format ==
DOC) {
654 else if (value_.size() == 1U && format ==
CFI) {
655 writeValueInVector<T>(os, value_[0],
format);
657 else if (value_.size() >= 1U) {
658 if (format ==
DOC) os <<
"(vector size = " << value_.size() <<
")";
660 bool startWithComma =
false;
662 for_all(value_, boost::bind(&writeValueInVectorWithSpace<T>,
666 boost::ref(startWithComma),
669 if (format ==
CFI) os <<
"\n" << std::setw(indentation) <<
"";
676 writeValue<int>(os, value_,
format);
680 writeVector<int>(os, indentation, value_,
format);
684 writeValue<unsigned>(os, value_,
format);
688 writeVector<unsigned>(os, indentation, value_,
format);
692 writeValue<long long>(os, value_,
format);
696 writeVector<long long>(os, indentation, value_,
format);
700 writeValue<unsigned long long>(os, value_,
format);
704 writeVector<unsigned long long>(os, indentation, value_,
format);
708 writeValue<double>(os, value_,
format);
712 writeVector<double>(os, indentation, value_,
format);
716 writeValue<bool>(os, value_,
format);
720 writeValue<std::string>(os, value_,
format);
724 writeVector<std::string>(os, indentation, value_,
format);
728 writeValue<EventID>(os, value_,
format);
732 writeVector<EventID>(os, indentation, value_,
format);
736 writeValue<LuminosityBlockID>(os, value_,
format);
740 writeVector<LuminosityBlockID>(os, indentation, value_,
format);
744 writeValue<LuminosityBlockRange>(os, value_,
format);
748 writeVector<LuminosityBlockRange>(os, indentation, value_,
format);
752 writeValue<EventRange>(os, value_,
format);
756 writeVector<EventRange>(os, indentation, value_,
format);
760 writeValue<InputTag>(os, value_,
format);
764 writeVector<InputTag>(os, indentation, value_,
format);
768 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
void writeSingleValue< double >(std::ostream &os, double const &value, ValueFormat format)
virtual ~ParameterDescription()
void writeSingleValue< FileInPath >(std::ostream &os, FileInPath const &value, ValueFormat format)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
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 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< bool >(std::ostream &os, bool const &value, ValueFormat format)
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
virtual void insertDefault_(ParameterSet &pset) const
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 writeSingleValue(std::ostream &os, T const &value, ValueFormat format)
void writeValueInVector< LuminosityBlockID >(std::ostream &os, LuminosityBlockID const &value, ValueFormat format)
void writeValueInVector< InputTag >(std::ostream &os, InputTag 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