49 std::set<std::string>& validatedLabels,
50 bool optional)
const {
62 if(!optional && !exists) {
68 validatedLabels.insert(
label());
78 psetDesc_->validate(*containedPSet);
87 os <<
"see Section " << dfh.
section()
89 if(!writeToCfi) os <<
" (do not write to cfi)";
109 std::stringstream
ss;
114 os <<
"Section " << newSection
115 <<
" " <<
label() <<
" PSet description:\n";
116 if(!dfh.
brief()) os <<
"\n";
124 psetDesc_->print(os, new_dfh);
136 return psetDesc_.operator->();
142 return psetDesc_.operator->();
148 bool startWithComma =
false;
150 psetDesc_->writeCfi(os, startWithComma, indentation);
179 std::vector<ParameterSet>
const& vPset) :
183 partOfDefaultOfVPSet_(
false) {
190 std::vector<ParameterSet>
const& vPset) :
194 partOfDefaultOfVPSet_(
false) {
204 partOfDefaultOfVPSet_(
false) {
214 partOfDefaultOfVPSet_(
false) {
218 ~ParameterDescription() { }
222 parameterSetDescription()
const {
223 return psetDesc_.operator->();
228 parameterSetDescription() {
229 return psetDesc_.operator->();
235 std::set<std::string>& validatedLabels,
236 bool optional)
const {
238 bool exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
241 validatedLabels.insert(
label());
242 }
else if(pset.
existsAs<std::vector<ParameterSet> >(
label(), !isTracked())) {
243 throwParameterWrongTrackiness();
245 throwParameterWrongType();
248 if(!exists && !optional) {
255 validatedLabels.insert(
label());
257 throwMissingRequiredNoDefault();
261 exists = pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
266 for(
unsigned i = 0;
i < vpsetEntry->
size(); ++
i) {
274 printDefault_(std::ostream& os,
277 os <<
"see Section " << dfh.
section()
279 if(!writeToCfi) os <<
" (do not write to cfi)";
286 hasNestedContent_() {
292 printNestedContent_(std::ostream& os,
301 if(!partOfDefaultOfVPSet_) {
302 printSpaces(os, indentation);
304 <<
" " <<
label() <<
" VPSet description:\n";
307 os <<
"All elements will be validated using the PSet description in Section "
310 printSpaces(os, indentation);
312 <<
" " <<
" VPSet description for VPSet that is part of the default of a containing VPSet:\n";
317 unsigned subsectionOffset = 2;
318 if(partOfDefaultOfVPSet_) subsectionOffset = 1;
321 if(vPset_.size() == 0U) os <<
"The default VPSet is empty.\n";
322 else if(vPset_.size() == 1U) os <<
"The default VPSet has 1 element.\n";
323 else os <<
"The default VPSet has " << vPset_.size() <<
" elements.\n";
325 if(vPset_.size() > 0U) {
326 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
328 os <<
"[" << (
i) <<
"]: see Section " << dfh.
section()
329 <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset) <<
"\n";
333 os <<
"Does not have a default VPSet.\n";
336 if(!dfh.
brief()) os <<
"\n";
338 if(!partOfDefaultOfVPSet_) {
340 std::stringstream
ss;
344 printSpaces(os, indentation);
345 os <<
"Section " << newSection <<
" description of PSet used to validate elements of VPSet:\n";
346 if(!dfh.
brief()) os <<
"\n";
354 psetDesc_->print(os, new_dfh);
358 for(
unsigned i = 0;
i < vPset_.size(); ++
i) {
360 std::stringstream
ss;
361 ss << dfh.
section() <<
"." << dfh.
counter() <<
"." << (
i + subsectionOffset);
364 printSpaces(os, indentation);
365 os <<
"Section " << newSection <<
" PSet description of "
366 <<
"default VPSet element [" <<
i <<
"]\n";
367 if(!dfh.
brief()) os <<
"\n";
378 defaultDescription.
print(os, new_dfh);
386 return pset.
existsAs<std::vector<ParameterSet> >(
label(), isTracked());
394 bool& nextOneStartsWithAComma) {
395 if(nextOneStartsWithAComma) os <<
",";
396 nextOneStartsWithAComma =
true;
398 printSpaces(os, indentation + 2);
402 bool startWithComma =
false;
403 int indent = indentation + 4;
407 psetDesc.
writeCfi(os, startWithComma, indent);
414 writeCfi_(std::ostream& os,
int indentation)
const {
415 bool nextOneStartsWithAComma =
false;
416 for_all(vPset_, std::bind(&writeOneElementToCfi,
417 std::placeholders::_1,
420 std::ref(nextOneStartsWithAComma)));
422 printSpaces(os, indentation);
427 writeDoc_(std::ostream&,
int )
const {
447 namespace writeParameterValue {
475 s << std::setprecision(17) <<
value;
478 if(result.size() > 15 && std::string::npos != result.find(
".")) {
480 s << std::setprecision(15) <<
value;
483 if(resultLessPrecision.size() < result.size() - 2) {
484 double test = std::strtod(resultLessPrecision.c_str(), 0);
486 result = resultLessPrecision;
501 value ? os <<
"True" : os <<
"False";
506 os <<
"'" <<
value <<
"'";
512 os <<
value.run() <<
", " <<
value.luminosityBlock() <<
", " <<
value.event();
514 if(
value.luminosityBlock() == 0U) {
517 os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
525 else os <<
value.run() <<
":" <<
value.luminosityBlock();
530 if(
value.startLumi() == 0U) {
532 <<
value.endRun() <<
":" <<
value.endEvent() <<
"'";
533 else os <<
value.startRun() <<
":" <<
value.startEvent() <<
"-"
537 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent() <<
"'";
538 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
":" <<
value.startEvent() <<
"-"
539 <<
value.endRun() <<
":" <<
value.endLumi() <<
":" <<
value.endEvent();
546 <<
value.endRun() <<
":" <<
value.endLumi() <<
"'";
547 else os <<
value.startRun() <<
":" <<
value.startLumi() <<
"-"
554 os <<
"'" <<
value.label() <<
"'";
555 if(!
value.instance().empty() || !
value.process().empty()) {
556 os <<
", '" <<
value.instance() <<
"'";
558 if(!
value.process().empty()) {
559 os <<
", '" <<
value.process() <<
"'";
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();
575 os <<
"'" <<
value.relativePath() <<
"'";
582 writeSingleValue<T>(os, value_,
format);
595 if(
value.luminosityBlock() == 0U) {
597 else os <<
value.run() <<
":" <<
value.event();
600 else os <<
value.run() <<
":" <<
value.luminosityBlock() <<
":" <<
value.event();
607 else os <<
value.run() <<
":" <<
value.luminosityBlock();
612 os <<
"'" <<
value.label();
613 if(!
value.instance().empty() || !
value.process().empty()) {
614 os <<
":" <<
value.instance();
616 if(!
value.process().empty()) {
617 os <<
":" <<
value.process();
626 bool& startWithComma,
629 if(startWithComma && format ==
CFI) os <<
",";
630 startWithComma =
true;
631 os <<
"\n" << std::setw(indentation) <<
"";
632 if(format ==
DOC) os <<
"[" << i <<
"]: ";
640 char oldFill = os.fill();
642 if(value_.size() == 0U && format ==
DOC) {
644 }
else if(value_.size() == 1U && format ==
CFI) {
645 writeValueInVector<T>(os, value_[0],
format);
646 }
else if(value_.size() >= 1U) {
647 if(format ==
DOC) os <<
"(vector size = " << value_.size() <<
")";
648 if(format ==
CFI and value_.size() > 255U) os <<
" *(";
650 bool startWithComma =
false;
652 for_all(value_, std::bind(&writeValueInVectorWithSpace<T>,
653 std::placeholders::_1,
656 std::ref(startWithComma),
659 if(format ==
CFI) os <<
"\n" << std::setw(indentation) <<
"";
660 if(format ==
CFI and value_.size() > 255U) os <<
") ";
667 writeValue<int>(os, value_,
format);
671 writeVector<int>(os, indentation, value_,
format);
675 writeValue<unsigned>(os, value_,
format);
679 writeVector<unsigned>(os, indentation, value_,
format);
683 writeValue<long long>(os, value_,
format);
687 writeVector<long long>(os, indentation, value_,
format);
691 writeValue<unsigned long long>(os, value_,
format);
695 writeVector<unsigned long long>(os, indentation, value_,
format);
699 writeValue<double>(os, value_,
format);
703 writeVector<double>(os, indentation, value_,
format);
707 writeValue<bool>(os, value_,
format);
711 writeValue<std::string>(os, value_,
format);
715 writeVector<std::string>(os, indentation, value_,
format);
719 writeValue<EventID>(os, value_,
format);
723 writeVector<EventID>(os, indentation, value_,
format);
727 writeValue<LuminosityBlockID>(os, value_,
format);
731 writeVector<LuminosityBlockID>(os, indentation, value_,
format);
735 writeValue<LuminosityBlockRange>(os, value_,
format);
739 writeVector<LuminosityBlockRange>(os, indentation, value_,
format);
743 writeValue<EventRange>(os, value_,
format);
747 writeVector<EventRange>(os, indentation, value_,
format);
751 writeValue<InputTag>(os, value_,
format);
755 writeVector<InputTag>(os, indentation, value_,
format);
759 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
bool isRegistered() const
void writeValueInVector< InputTag >(std::ostream &os, InputTag const &value, ValueFormat)
void writeValueInVector(std::ostream &os, T const &value, ValueFormat format)
void invalidateRegistration(std::string const &nameOfTracked)
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