49 std::set<std::string>& validatedLabels,
50 bool optional)
const {
62 if(!optional && !exists) {
68 validatedLabels.insert(
label());
75 psetDesc_->validate(*containedPSet);
84 os <<
"see Section " << dfh.
section()
86 if(!writeToCfi) os <<
" (do not write to cfi)";
106 std::stringstream
ss;
111 os <<
"Section " << newSection
112 <<
" " <<
label() <<
" PSet description:\n";
113 if(!dfh.
brief()) os <<
"\n";
121 psetDesc_->print(os, new_dfh);
133 return psetDesc_.operator->();
139 return psetDesc_.operator->();
145 bool startWithComma =
false;
147 psetDesc_->writeCfi(os, startWithComma, indentation);
176 std::vector<ParameterSet>
const& vPset) :
180 partOfDefaultOfVPSet_(
false) {
187 std::vector<ParameterSet>
const& vPset) :
191 partOfDefaultOfVPSet_(
false) {
201 partOfDefaultOfVPSet_(
false) {
211 partOfDefaultOfVPSet_(
false) {
215 ~ParameterDescription() { }
219 parameterSetDescription()
const {
220 return psetDesc_.operator->();
225 parameterSetDescription() {
226 return psetDesc_.operator->();
232 std::set<std::string>& validatedLabels,
233 bool optional)
const {
235 bool exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
238 validatedLabels.insert(
label());
239 }
else if(pset.
existsAs<std::vector<ParameterSet> >(
label(), !isTracked())) {
240 throwParameterWrongTrackiness();
242 throwParameterWrongType();
245 if(!exists && !optional) {
252 validatedLabels.insert(
label());
254 throwMissingRequiredNoDefault();
258 exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
263 for(
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
271 printDefault_(std::ostream& os,
274 os <<
"see Section " << dfh.
section()
276 if(!writeToCfi) os <<
" (do not write to cfi)";
283 hasNestedContent_() {
289 printNestedContent_(std::ostream& os,
298 if(!partOfDefaultOfVPSet_) {
299 printSpaces(os, indentation);
301 <<
" " <<
label() <<
" VPSet description:\n";
304 os <<
"All elements will be validated using the PSet description in Section "
307 printSpaces(os, indentation);
309 <<
" " <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
314 unsigned subsectionOffset = 2;
315 if(partOfDefaultOfVPSet_) subsectionOffset = 1;
318 if(vPset_.size() == 0U) os <<
"The default VPSet is empty.\n";
319 else if(vPset_.size() == 1U) os <<
"The default VPSet has 1 element.\n";
320 else os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
322 if(vPset_.size() > 0U) {
323 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
325 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section()
326 <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset) <<
"\n";
330 os <<
"Does not have a default VPSet.\n";
333 if(!dfh.
brief()) os <<
"\n";
335 if(!partOfDefaultOfVPSet_) {
337 std::stringstream
ss;
341 printSpaces(os, indentation);
342 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
343 if(!dfh.
brief()) os <<
"\n";
351 psetDesc_->print(os, new_dfh);
355 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
357 std::stringstream
ss;
358 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
361 printSpaces(os, indentation);
362 os <<
"Section " << newSection <<
" PSet description of "
363 <<
"default VPSet element [" <<
i <<
"]\n";
364 if(!dfh.
brief()) os <<
"\n";
375 defaultDescription.
print(os, new_dfh);
383 return pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
391 bool& nextOneStartsWithAComma) {
392 if(nextOneStartsWithAComma) os <<
",";
393 nextOneStartsWithAComma =
true;
395 printSpaces(os, indentation + 2);
399 bool startWithComma =
false;
400 int indent = indentation + 4;
404 psetDesc.
writeCfi(os, startWithComma, indent);
411 writeCfi_(std::ostream& os,
int indentation)
const {
412 bool nextOneStartsWithAComma =
false;
413 for_all(vPset_, std::bind(&writeOneElementToCfi,
414 std::placeholders::_1,
417 std::ref(nextOneStartsWithAComma)));
419 printSpaces(os, indentation);
424 writeDoc_(std::ostream&,
int )
const {
444 namespace writeParameterValue {
472 s << std::setprecision(17) <<
value;
475 if(result.size() > 15 && std::string::npos != result.find(
".")) {
477 s << std::setprecision(15) <<
value;
480 if(resultLessPrecision.size() < result.size() - 2) {
481 double test = std::strtod(resultLessPrecision.c_str(), 0);
483 result = resultLessPrecision;
498 value ? os <<
"True" : os <<
"False";
503 os <<
"'" <<
value <<
"'";
509 os <<
value.run() <<
", " <<
value.luminosityBlock() <<
", " <<
value.event();
511 if(
value.luminosityBlock() == 0U) {
514 os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
522 else os <<
value.run() <<
":" <<
value.luminosityBlock();
527 if(
value.startLumi() == 0U) {
529 <<
value.endRun() <<
":" <<
value.endEvent() <<
"'";
530 else os <<
value.startRun() <<
":" <<
value.startEvent() <<
"-"
534 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent() <<
"'";
535 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
":" <<
value.startEvent() <<
"-"
536 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent();
543 <<
value.endRun() <<
":" <<
value.endLumi() <<
"'";
544 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
"-"
551 os <<
"'" <<
value.label() <<
"'";
552 if(!
value.instance().empty() || !
value.process().empty()) {
553 os <<
", '" <<
value.instance() <<
"'";
555 if(!
value.process().empty()) {
556 os <<
", '" <<
value.process() <<
"'";
559 os <<
"'" <<
value.label();
560 if(!
value.instance().empty() || !
value.process().empty()) {
561 os <<
":" <<
value.instance();
563 if(!
value.process().empty()) {
564 os <<
":" <<
value.process();
572 os <<
"'" <<
value.relativePath() <<
"'";
579 writeSingleValue<T>(os, value_,
format);
592 if(
value.luminosityBlock() == 0U) {
594 else os <<
value.run() <<
":" <<
value.event();
597 else os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
604 else os <<
value.run() <<
":" <<
value.luminosityBlock();
609 os <<
"'" <<
value.label();
610 if(!
value.instance().empty() || !
value.process().empty()) {
611 os <<
":" <<
value.instance();
613 if(!
value.process().empty()) {
614 os <<
":" <<
value.process();
623 bool& startWithComma,
626 if(startWithComma && format ==
CFI) os <<
",";
627 startWithComma =
true;
628 os <<
"\n" << std::setw(indentation) <<
"";
629 if(format ==
DOC) os <<
"[" << i <<
"]: ";
637 char oldFill = os.fill();
639 if(value_.size() == 0U && format ==
DOC) {
641 }
else if(value_.size() == 1U && format ==
CFI) {
642 writeValueInVector<T>(os, value_[0],
format);
643 }
else if(value_.size() >= 1U) {
644 if(format ==
DOC) os <<
"(vector size = " << value_.size() <<
")";
646 bool startWithComma =
false;
648 for_all(value_, std::bind(&writeValueInVectorWithSpace<T>,
649 std::placeholders::_1,
652 std::ref(startWithComma),
655 if(format ==
CFI) os <<
"\n" << std::setw(indentation) <<
"";
662 writeValue<int>(os, value_,
format);
666 writeVector<int>(os, indentation, value_,
format);
670 writeValue<unsigned>(os, value_,
format);
674 writeVector<unsigned>(os, indentation, value_,
format);
678 writeValue<long long>(os, value_,
format);
682 writeVector<long long>(os, indentation, value_,
format);
686 writeValue<unsigned long long>(os, value_,
format);
690 writeVector<unsigned long long>(os, indentation, value_,
format);
694 writeValue<double>(os, value_,
format);
698 writeVector<double>(os, indentation, value_,
format);
702 writeValue<bool>(os, value_,
format);
706 writeValue<std::string>(os, value_,
format);
710 writeVector<std::string>(os, indentation, value_,
format);
714 writeValue<EventID>(os, value_,
format);
718 writeVector<EventID>(os, indentation, value_,
format);
722 writeValue<LuminosityBlockID>(os, value_,
format);
726 writeVector<LuminosityBlockID>(os, indentation, value_,
format);
730 writeValue<LuminosityBlockRange>(os, value_,
format);
734 writeVector<LuminosityBlockRange>(os, indentation, value_,
format);
738 writeValue<EventRange>(os, value_,
format);
742 writeVector<EventRange>(os, indentation, value_,
format);
746 writeValue<InputTag>(os, value_,
format);
750 writeVector<InputTag>(os, indentation, value_,
format);
754 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 &)
string format
Some error handling for the usage.
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)
volatile std::atomic< bool > shutdown_flag false
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