CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/FWCore/ParameterSet/src/ParameterDescription.cc

Go to the documentation of this file.
00001 
00002 #include "FWCore/ParameterSet/interface/ParameterDescription.h"
00003 
00004 #include "DataFormats/Provenance/interface/EventID.h"
00005 #include "DataFormats/Provenance/interface/EventRange.h"
00006 #include "DataFormats/Provenance/interface/LuminosityBlockID.h"
00007 #include "DataFormats/Provenance/interface/LuminosityBlockRange.h"
00008 #include "FWCore/ParameterSet/interface/DocFormatHelper.h"
00009 #include "FWCore/ParameterSet/interface/FileInPath.h"
00010 #include "FWCore/ParameterSet/interface/FillDescriptionFromPSet.h"
00011 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
00012 #include "FWCore/ParameterSet/interface/VParameterSetEntry.h"
00013 #include "FWCore/Utilities/interface/Algorithms.h"
00014 #include "FWCore/Utilities/interface/EDMException.h"
00015 #include "FWCore/Utilities/interface/InputTag.h"
00016 
00017 #include "boost/bind.hpp"
00018 
00019 #include <cassert>
00020 #include <cstdlib>
00021 #include <iomanip>
00022 #include <ostream>
00023 #include <sstream>
00024 
00025 namespace edm {
00026 
00027   // =================================================================
00028 
00029   ParameterDescription<ParameterSetDescription>::
00030   ParameterDescription(std::string const& iLabel,
00031                        ParameterSetDescription const& value,
00032                        bool isTracked) :
00033       ParameterDescriptionBase(iLabel, k_PSet, isTracked, true),
00034       psetDesc_(new ParameterSetDescription(value)) {
00035   }
00036 
00037   ParameterDescription<ParameterSetDescription>::
00038   ParameterDescription(char const* iLabel,
00039                        ParameterSetDescription const& value,
00040                        bool isTracked) :
00041       ParameterDescriptionBase(iLabel, k_PSet, isTracked, true),
00042       psetDesc_(new ParameterSetDescription(value)) {
00043   }
00044 
00045   ParameterDescription<ParameterSetDescription>::
00046   ~ParameterDescription() { }
00047 
00048   void
00049   ParameterDescription<ParameterSetDescription>::
00050   validate_(ParameterSet& pset,
00051            std::set<std::string>& validatedLabels,
00052            bool optional) const {
00053 
00054     bool exists = pset.existsAs<ParameterSet>(label(), isTracked());
00055 
00056     if(exists) {
00057       validatedLabels.insert(label());
00058     } else if(pset.existsAs<ParameterSet>(label(), !isTracked())) {
00059       throwParameterWrongTrackiness();
00060     } else if(pset.exists(label())) {
00061       throwParameterWrongType();
00062     }
00063 
00064     if(!optional && !exists) {
00065       if(isTracked()) {
00066         pset.addParameter(label(), ParameterSet());
00067       } else {
00068         pset.addUntrackedParameter(label(), ParameterSet());
00069       }
00070       validatedLabels.insert(label());
00071     }
00072 
00073     exists = pset.existsAs<ParameterSet>(label(), isTracked());
00074 
00075     if(exists) {
00076       ParameterSet * containedPSet = pset.getPSetForUpdate(label());
00077       psetDesc_->validate(*containedPSet);
00078     }
00079   }
00080 
00081   void
00082   ParameterDescription<ParameterSetDescription>::
00083   printDefault_(std::ostream& os,
00084                   bool writeToCfi,
00085                   DocFormatHelper& dfh) {
00086     os << "see Section " << dfh.section()
00087        << "." << dfh.counter();
00088     if(!writeToCfi) os << " (do not write to cfi)";
00089     os << "\n";
00090   }
00091 
00092   bool
00093   ParameterDescription<ParameterSetDescription>::
00094   hasNestedContent_() {
00095     return true;
00096   }
00097 
00098   void
00099   ParameterDescription<ParameterSetDescription>::
00100   printNestedContent_(std::ostream& os,
00101                       bool /*optional*/,
00102                       DocFormatHelper& dfh) {
00103     int indentation = dfh.indentation();
00104     if(dfh.parent() != DocFormatHelper::TOP) {
00105       indentation -= DocFormatHelper::offsetSectionContent();
00106     }
00107 
00108     std::stringstream ss;
00109     ss << dfh.section() << "." << dfh.counter();
00110     std::string newSection = ss.str();
00111 
00112     printSpaces(os, indentation);
00113     os << "Section " << newSection
00114        << " " << label() << " PSet description:\n";
00115     if(!dfh.brief()) os << "\n";
00116 
00117     DocFormatHelper new_dfh(dfh);
00118     new_dfh.init();
00119     new_dfh.setSection(newSection);
00120     if(dfh.parent() == DocFormatHelper::TOP) {
00121       new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
00122     }
00123     psetDesc_->print(os, new_dfh);
00124   }
00125 
00126   bool
00127   ParameterDescription<ParameterSetDescription>::
00128   exists_(ParameterSet const& pset) const {
00129     return pset.existsAs<ParameterSet>(label(), isTracked());
00130   }
00131 
00132   ParameterSetDescription const*
00133   ParameterDescription<ParameterSetDescription>::
00134   parameterSetDescription() const {
00135     return psetDesc_.operator->();
00136   }
00137 
00138   ParameterSetDescription *
00139   ParameterDescription<ParameterSetDescription>::
00140   parameterSetDescription() {
00141     return psetDesc_.operator->();
00142   }
00143 
00144   void
00145   ParameterDescription<ParameterSetDescription>::
00146   writeCfi_(std::ostream& os, int indentation) const {
00147     bool startWithComma = false;
00148     indentation += 2;
00149     psetDesc_->writeCfi(os, startWithComma, indentation);
00150   }
00151 
00152   void
00153   ParameterDescription<ParameterSetDescription>::
00154   writeDoc_(std::ostream&, int /*indentation*/) const {
00155   }
00156 
00157   // These next two should not be needed for this specialization
00158   bool
00159   ParameterDescription<ParameterSetDescription>::
00160   exists_(ParameterSet const&, bool /*isTracked*/) const {
00161     throw Exception(errors::LogicError);
00162     return true;
00163   }
00164 
00165   void
00166   ParameterDescription<ParameterSetDescription>::
00167   insertDefault_(ParameterSet&) const {
00168     throw Exception(errors::LogicError);
00169     return;
00170   }
00171 
00172   // =================================================================
00173 
00174   ParameterDescription<std::vector<ParameterSet> >::
00175   ParameterDescription(std::string const& iLabel,
00176                        ParameterSetDescription const& psetDesc,
00177                        bool isTracked,
00178                        std::vector<ParameterSet> const& vPset) :
00179       ParameterDescriptionBase(iLabel, k_VPSet, isTracked, true),
00180       psetDesc_(new ParameterSetDescription(psetDesc)),
00181       vPset_(vPset),
00182       partOfDefaultOfVPSet_(false) {
00183   }
00184 
00185   ParameterDescription<std::vector<ParameterSet> >::
00186   ParameterDescription(char const* iLabel,
00187                        ParameterSetDescription const& psetDesc,
00188                        bool isTracked,
00189                        std::vector<ParameterSet> const& vPset) :
00190       ParameterDescriptionBase(iLabel, k_VPSet, isTracked, true),
00191       psetDesc_(new ParameterSetDescription(psetDesc)),
00192       vPset_(vPset),
00193       partOfDefaultOfVPSet_(false) {
00194   }
00195 
00196   ParameterDescription<std::vector<ParameterSet> >::
00197   ParameterDescription(std::string const& iLabel,
00198                        ParameterSetDescription const& psetDesc,
00199                        bool isTracked) :
00200       ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false),
00201       psetDesc_(new ParameterSetDescription(psetDesc)),
00202       vPset_(),
00203       partOfDefaultOfVPSet_(false) {
00204   }
00205 
00206   ParameterDescription<std::vector<ParameterSet> >::
00207   ParameterDescription(char const* iLabel,
00208                        ParameterSetDescription const& psetDesc,
00209                        bool isTracked) :
00210       ParameterDescriptionBase(iLabel, k_VPSet, isTracked, false),
00211       psetDesc_(new ParameterSetDescription(psetDesc)),
00212       vPset_(),
00213       partOfDefaultOfVPSet_(false) {
00214   }
00215 
00216   ParameterDescription<std::vector<ParameterSet> >::
00217   ~ParameterDescription() { }
00218 
00219   ParameterSetDescription const*
00220   ParameterDescription<std::vector<ParameterSet> >::
00221   parameterSetDescription() const {
00222     return psetDesc_.operator->();
00223   }
00224 
00225   ParameterSetDescription *
00226   ParameterDescription<std::vector<ParameterSet> >::
00227   parameterSetDescription() {
00228     return psetDesc_.operator->();
00229   }
00230 
00231   void
00232   ParameterDescription<std::vector<ParameterSet> >::
00233   validate_(ParameterSet& pset,
00234             std::set<std::string>& validatedLabels,
00235             bool optional) const {
00236 
00237     bool exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
00238 
00239     if(exists) {
00240       validatedLabels.insert(label());
00241     } else if(pset.existsAs<std::vector<ParameterSet> >(label(), !isTracked())) {
00242       throwParameterWrongTrackiness();
00243     } else if(pset.exists(label())) {
00244       throwParameterWrongType();
00245     }
00246 
00247     if(!exists && !optional) {
00248       if(hasDefault()) {
00249         if(isTracked()) {
00250           pset.addParameter(label(), vPset_);
00251         } else {
00252           pset.addUntrackedParameter(label(), vPset_);
00253         }
00254         validatedLabels.insert(label());
00255       } else {
00256         throwMissingRequiredNoDefault();
00257       }
00258     }
00259 
00260     exists = pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
00261     if(exists) {
00262       VParameterSetEntry * vpsetEntry = pset.getPSetVectorForUpdate(label());
00263       assert(vpsetEntry);
00264 
00265       for(unsigned i = 0; i < vpsetEntry->size(); ++i) {
00266         psetDesc_->validate(vpsetEntry->psetInVector(i));
00267       }
00268     }
00269   }
00270 
00271   void
00272   ParameterDescription<std::vector<ParameterSet> >::
00273   printDefault_(std::ostream& os,
00274                 bool writeToCfi,
00275                 DocFormatHelper& dfh) {
00276     os << "see Section " << dfh.section()
00277        << "." << dfh.counter();
00278     if(!writeToCfi) os << " (do not write to cfi)";
00279     os << "\n";
00280   }
00281 
00282 
00283   bool
00284   ParameterDescription<std::vector<ParameterSet> >::
00285   hasNestedContent_() {
00286     return true;
00287   }
00288 
00289   void
00290   ParameterDescription<std::vector<ParameterSet> >::
00291   printNestedContent_(std::ostream& os,
00292                       bool /*optional*/,
00293                       DocFormatHelper& dfh) {
00294 
00295     int indentation = dfh.indentation();
00296     if(dfh.parent() != DocFormatHelper::TOP) {
00297       indentation -= DocFormatHelper::offsetSectionContent();
00298     }
00299 
00300     if(!partOfDefaultOfVPSet_) {
00301       printSpaces(os, indentation);
00302       os << "Section " << dfh.section() << "." << dfh.counter()
00303          << " " << label() << " VPSet description:\n";
00304 
00305       printSpaces(os, indentation + DocFormatHelper::offsetSectionContent());
00306       os << "All elements will be validated using the PSet description in Section "
00307          << dfh.section() << "." << dfh.counter() << ".1.\n";
00308     } else {
00309       printSpaces(os, indentation);
00310       os << "Section " << dfh.section() << "." << dfh.counter()
00311          << " " << " VPSet description for VPSet that is part of the default of a containing VPSet:\n";
00312     }
00313 
00314     printSpaces(os, indentation + DocFormatHelper::offsetSectionContent());
00315 
00316     unsigned subsectionOffset = 2;
00317     if(partOfDefaultOfVPSet_) subsectionOffset = 1;
00318 
00319     if(hasDefault()) {
00320       if(vPset_.size() == 0U) os << "The default VPSet is empty.\n";
00321       else if(vPset_.size() == 1U) os << "The default VPSet has 1 element.\n";
00322       else os << "The default VPSet has " << vPset_.size() << " elements.\n";
00323 
00324       if(vPset_.size() > 0U) {
00325         for(unsigned i = 0; i < vPset_.size(); ++i) {
00326           printSpaces(os, indentation + DocFormatHelper::offsetSectionContent());
00327           os << "[" << (i) << "]: see Section " << dfh.section()
00328              << "." << dfh.counter() << "." << (i + subsectionOffset) << "\n";
00329         }
00330       }
00331     } else {
00332       os << "Does not have a default VPSet.\n";
00333     }
00334 
00335     if(!dfh.brief()) os << "\n";
00336 
00337     if(!partOfDefaultOfVPSet_) {
00338 
00339       std::stringstream ss;
00340       ss << dfh.section() << "." << dfh.counter() << ".1";
00341       std::string newSection = ss.str();
00342 
00343       printSpaces(os, indentation);
00344       os << "Section " << newSection << " description of PSet used to validate elements of VPSet:\n";
00345       if(!dfh.brief()) os << "\n";
00346 
00347       DocFormatHelper new_dfh(dfh);
00348       new_dfh.init();
00349       new_dfh.setSection(newSection);
00350       if(dfh.parent() == DocFormatHelper::TOP) {
00351          new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
00352       }
00353       psetDesc_->print(os, new_dfh);
00354     }
00355 
00356     if(hasDefault()) {
00357       for(unsigned i = 0; i < vPset_.size(); ++i) {
00358 
00359         std::stringstream ss;
00360         ss << dfh.section() << "." << dfh.counter() << "." << (i + subsectionOffset);
00361         std::string newSection = ss.str();
00362 
00363         printSpaces(os, indentation);
00364         os << "Section " << newSection << " PSet description of "
00365            << "default VPSet element [" << i << "]\n";
00366         if(!dfh.brief()) os << "\n";
00367 
00368         DocFormatHelper new_dfh(dfh);
00369         new_dfh.init();
00370         new_dfh.setSection(newSection);
00371         if(dfh.parent() == DocFormatHelper::TOP) {
00372           new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
00373         }
00374 
00375         ParameterSetDescription defaultDescription;
00376         fillDescriptionFromPSet(vPset_[i], defaultDescription);
00377         defaultDescription.print(os, new_dfh);
00378       }
00379     }
00380   }
00381 
00382   bool
00383   ParameterDescription<std::vector<ParameterSet> >::
00384   exists_(ParameterSet const& pset) const {
00385     return pset.existsAs<std::vector<ParameterSet> >(label(), isTracked());
00386   }
00387 
00388   void
00389   ParameterDescription<std::vector<ParameterSet> >::
00390   writeOneElementToCfi(ParameterSet const& pset,
00391                        std::ostream& os,
00392                        int indentation,
00393                        bool& nextOneStartsWithAComma) {
00394     if(nextOneStartsWithAComma) os << ",";
00395     nextOneStartsWithAComma = true;
00396     os << "\n";
00397     printSpaces(os, indentation + 2);
00398 
00399     os << "cms.PSet(";
00400 
00401     bool startWithComma = false;
00402     int indent = indentation + 4;
00403 
00404     ParameterSetDescription psetDesc;
00405     fillDescriptionFromPSet(pset, psetDesc);
00406     psetDesc.writeCfi(os, startWithComma, indent);
00407 
00408     os << ")";
00409   }
00410 
00411   void
00412   ParameterDescription<std::vector<ParameterSet> >::
00413   writeCfi_(std::ostream& os, int indentation) const {
00414     bool nextOneStartsWithAComma = false;
00415     for_all(vPset_, boost::bind(&writeOneElementToCfi,
00416                                  _1,
00417                                  boost::ref(os),
00418                                  indentation,
00419                                  boost::ref(nextOneStartsWithAComma)));
00420     os << "\n";
00421     printSpaces(os, indentation);
00422   }
00423 
00424   void
00425   ParameterDescription<std::vector<ParameterSet> >::
00426   writeDoc_(std::ostream&, int /*indentation*/) const {
00427   }
00428 
00429   // These next two should not be needed for this specialization
00430   bool
00431   ParameterDescription<std::vector<ParameterSet> >::
00432   exists_(ParameterSet const&, bool /*isTracked*/) const {
00433     throw Exception(errors::LogicError);
00434     return true;
00435   }
00436 
00437   void
00438   ParameterDescription<std::vector<ParameterSet> >::
00439   insertDefault_(ParameterSet&) const {
00440     throw Exception(errors::LogicError);
00441     return;
00442   }
00443 
00444   // =================================================================
00445 
00446   namespace writeParameterValue {
00447 
00448     template<typename T>
00449     void writeSingleValue(std::ostream& os, T const& value, ValueFormat) {
00450       os << value;
00451     }
00452 
00453     // Specialize this for cases where the operator<< does not give
00454     // the proper formatting for a configuration file.
00455 
00456     // Formatting the doubles is a little tricky.  It is a requirement
00457     // that when a value of ***type double*** is added to a ParameterSetDescription
00458     // the EXACT same value of type double will be created and passed to the
00459     // ParameterSet after the cfi files have been read.  The tricky part
00460     // is these values usually appear in the C++ code and cfi file as text
00461     // strings (in decimal form).  We do our best to force the text
00462     // string in the C++ code to be the same as the text string in the
00463     // cfi file by judiciously rounding to smaller precision when possible.
00464     // But it is not always possible to force the text strings to be the
00465     // same.  Generally, there are differences when the text string in the
00466     // C++ code has many digits (probably more than a human will ever type).
00467     // Even in cases where the text strings differ, the values stored in
00468     // memory in variables of type double will be exactly the same.
00469     // The alternative to the approach here is to store the values as strings,
00470     // but that approach was rejected because it would require the
00471     // ParameterSetDescription to know how to parse the strings.
00472     void formatDouble(double value, std::string& result) {
00473       std::stringstream s;
00474       s << std::setprecision(17) << value;
00475       result = s.str();
00476 
00477       if(result.size() > 15 && std::string::npos != result.find(".")) {
00478         std::stringstream s;
00479         s << std::setprecision(15) << value;
00480         std::string resultLessPrecision = s.str();
00481 
00482         if(resultLessPrecision.size() < result.size() - 2) {
00483           double test = std::strtod(resultLessPrecision.c_str(), 0);
00484           if(test == value) {
00485             result = resultLessPrecision;
00486           }
00487         }
00488       }
00489     }
00490 
00491     template<>
00492     void writeSingleValue<double>(std::ostream& os, double const& value, ValueFormat) {
00493       std::string sValue;
00494       formatDouble(value, sValue);
00495       os << sValue;
00496     }
00497 
00498     template<>
00499     void writeSingleValue<bool>(std::ostream& os, bool const& value, ValueFormat) {
00500       value ? os << "True" : os << "False";
00501     }
00502 
00503     template<>
00504     void writeSingleValue<std::string>(std::ostream& os, std::string const& value, ValueFormat) {
00505       os << "'" << value << "'";
00506     }
00507 
00508     template<>
00509     void writeSingleValue<EventID>(std::ostream& os, EventID const& value, ValueFormat format) {
00510       if(format == CFI) {
00511         os << value.run() << ", " << value.luminosityBlock() << ", " << value.event();
00512       } else {
00513         if(value.luminosityBlock() == 0U) {
00514           os << value.run() << ":" << value.event();
00515         } else {
00516           os << value.run() << ":" << value.luminosityBlock() << ":" << value.event();
00517         }
00518       }
00519     }
00520 
00521     template<>
00522     void writeSingleValue<LuminosityBlockID>(std::ostream& os, LuminosityBlockID const& value, ValueFormat format) {
00523       if(format == CFI) os << value.run() << ", " << value.luminosityBlock();
00524       else os << value.run() << ":" << value.luminosityBlock();
00525     }
00526 
00527     template<>
00528     void writeSingleValue<EventRange>(std::ostream& os, EventRange const& value, ValueFormat format) {
00529       if(value.startLumi() == 0U) {
00530         if(format == CFI) os << "'" << value.startRun() << ":" << value.startEvent() << "-"
00531                                      << value.endRun() << ":" << value.endEvent() << "'";
00532         else os << value.startRun() << ":" << value.startEvent() << "-"
00533                 << value.endRun() << ":" << value.endEvent();
00534       } else {
00535         if(format == CFI) os << "'" << value.startRun() << ":" << value.startLumi() << ":" << value.startEvent() << "-"
00536                                      << value.endRun() << ":" << value.endLumi() << ":" << value.endEvent() << "'";
00537         else os << value.startRun() << ":" << value.startLumi() << ":" << value.startEvent() << "-"
00538                 << value.endRun() << ":" << value.endLumi() << ":" << value.endEvent();
00539       }
00540     }
00541 
00542     template<>
00543     void writeSingleValue<LuminosityBlockRange>(std::ostream& os, LuminosityBlockRange const& value, ValueFormat format) {
00544       if(format == CFI) os << "'" << value.startRun() << ":" << value.startLumi() << "-"
00545                             << value.endRun() << ":" << value.endLumi() << "'";
00546       else os << value.startRun() << ":" << value.startLumi() << "-"
00547               << value.endRun() << ":" << value.endLumi();
00548     }
00549 
00550     template<>
00551     void writeSingleValue<InputTag>(std::ostream& os, InputTag const& value, ValueFormat format) {
00552       if(format == CFI) {
00553         os << "'" << value.label() << "'";
00554         if(!value.instance().empty() || !value.process().empty()) {
00555           os << ", '" << value.instance() << "'";
00556         }
00557         if(!value.process().empty()) {
00558           os << ", '" << value.process() << "'";
00559         }
00560       } else {
00561         os << "'" << value.label();
00562         if(!value.instance().empty() || !value.process().empty()) {
00563           os << ":" << value.instance();
00564         }
00565         if(!value.process().empty()) {
00566           os << ":" << value.process();
00567         }
00568         os << "'";
00569       }
00570     }
00571 
00572     template<>
00573     void writeSingleValue<FileInPath>(std::ostream& os, FileInPath const& value, ValueFormat) {
00574       os << "'" << value.relativePath() << "'";
00575     }
00576 
00577     template<typename T>
00578     void writeValue(std::ostream& os, T const& value_, ValueFormat format) {
00579       std::ios_base::fmtflags ff = os.flags(std::ios_base::dec);
00580       os.width(0);
00581       writeSingleValue<T>(os, value_, format);
00582       os.flags(ff);
00583     }
00584 
00585     template<typename T>
00586     void writeValueInVector(std::ostream& os, T const& value, ValueFormat format) {
00587       writeSingleValue<T>(os, value, format);
00588     }
00589 
00590     // Specializations for cases where we write the single values into
00591     // vectors differently than when there is only one not in a vector.
00592     template<>
00593     void writeValueInVector<EventID>(std::ostream& os, EventID const& value, ValueFormat format) {
00594       if(value.luminosityBlock() == 0U) {
00595         if(format == CFI) os << "'" << value.run() << ":" << value.event() << "'";
00596         else os << value.run() << ":" << value.event();
00597       } else {
00598         if(format == CFI) os << "'" << value.run() << ":" << value.luminosityBlock() << ":" << value.event() << "'";
00599         else os << value.run() << ":" << value.luminosityBlock() << ":" << value.event();
00600       }
00601     }
00602 
00603     template<>
00604     void writeValueInVector<LuminosityBlockID>(std::ostream& os, LuminosityBlockID const& value, ValueFormat format) {
00605       if(format == CFI) os << "'" << value.run() << ":" << value.luminosityBlock() << "'";
00606       else os << value.run() << ":" << value.luminosityBlock();
00607     }
00608 
00609     template<>
00610     void writeValueInVector<InputTag>(std::ostream& os, InputTag const& value, ValueFormat) {
00611       os << "'" << value.label();
00612       if(!value.instance().empty() || !value.process().empty()) {
00613         os << ":" << value.instance();
00614       }
00615       if(!value.process().empty()) {
00616         os << ":" << value.process();
00617       }
00618       os << "'";
00619     }
00620 
00621     template<typename T>
00622     void writeValueInVectorWithSpace(T const& value,
00623                                      std::ostream& os,
00624                                      int indentation,
00625                                      bool& startWithComma,
00626                                      ValueFormat format,
00627                                      int& i) {
00628       if(startWithComma && format == CFI) os << ",";
00629       startWithComma = true;
00630       os << "\n" << std::setw(indentation) << "";
00631       if(format == DOC) os << "[" << i << "]: ";
00632       writeValueInVector<T>(os, value, format);
00633       ++i;
00634     }
00635 
00636     template<typename T>
00637     void writeVector(std::ostream& os, int indentation, std::vector<T> const& value_, ValueFormat format) {
00638       std::ios_base::fmtflags ff = os.flags(std::ios_base::dec);
00639       char oldFill = os.fill();
00640       os.width(0);
00641       if(value_.size() == 0U && format == DOC) {
00642         os << "empty";
00643       } else if(value_.size() == 1U && format == CFI) {
00644         writeValueInVector<T>(os, value_[0], format);
00645       } else if(value_.size() >= 1U) {
00646         if(format == DOC) os << "(vector size = " << value_.size() << ")";
00647         os.fill(' ');
00648         bool startWithComma = false;
00649         int i = 0;
00650         for_all(value_, boost::bind(&writeValueInVectorWithSpace<T>,
00651                                     _1,
00652                                     boost::ref(os),
00653                                     indentation + 2,
00654                                     boost::ref(startWithComma),
00655                                     format,
00656                                     boost::ref(i)));
00657         if(format == CFI) os << "\n" << std::setw(indentation) << "";
00658       }
00659       os.flags(ff);
00660       os.fill(oldFill);
00661     }
00662 
00663     void writeValue(std::ostream& os, int, int const& value_, ValueFormat format) {
00664       writeValue<int>(os, value_, format);
00665     }
00666 
00667     void writeValue(std::ostream& os, int indentation, std::vector<int> const& value_, ValueFormat format) {
00668       writeVector<int>(os, indentation, value_, format);
00669     }
00670 
00671     void writeValue(std::ostream& os, int, unsigned const& value_, ValueFormat format) {
00672       writeValue<unsigned>(os, value_, format);
00673     }
00674 
00675     void writeValue(std::ostream& os, int indentation, std::vector<unsigned> const& value_, ValueFormat format) {
00676       writeVector<unsigned>(os, indentation, value_, format);
00677     }
00678 
00679     void writeValue(std::ostream& os, int, long long const& value_, ValueFormat format) {
00680       writeValue<long long>(os, value_, format);
00681     }
00682 
00683     void writeValue(std::ostream& os, int indentation, std::vector<long long> const& value_, ValueFormat format) {
00684       writeVector<long long>(os, indentation, value_, format);
00685     }
00686 
00687     void writeValue(std::ostream& os, int, unsigned long long const& value_, ValueFormat format) {
00688       writeValue<unsigned long long>(os, value_, format);
00689     }
00690 
00691     void writeValue(std::ostream& os, int indentation, std::vector<unsigned long long> const& value_, ValueFormat format) {
00692       writeVector<unsigned long long>(os, indentation, value_, format);
00693     }
00694 
00695     void writeValue(std::ostream& os, int, double const& value_, ValueFormat format) {
00696       writeValue<double>(os, value_, format);
00697     }
00698 
00699     void writeValue(std::ostream& os, int indentation, std::vector<double> const& value_, ValueFormat format) {
00700       writeVector<double>(os, indentation, value_, format);
00701     }
00702 
00703     void writeValue(std::ostream& os, int, bool const& value_, ValueFormat format) {
00704       writeValue<bool>(os, value_, format);
00705     }
00706 
00707     void writeValue(std::ostream& os, int, std::string const& value_, ValueFormat format) {
00708       writeValue<std::string>(os, value_, format);
00709     }
00710 
00711     void writeValue(std::ostream& os, int indentation, std::vector<std::string> const& value_, ValueFormat format) {
00712       writeVector<std::string>(os, indentation, value_, format);
00713     }
00714 
00715     void writeValue(std::ostream& os, int, EventID const& value_, ValueFormat format) {
00716       writeValue<EventID>(os, value_, format);
00717     }
00718 
00719     void writeValue(std::ostream& os, int indentation, std::vector<EventID> const& value_, ValueFormat format) {
00720       writeVector<EventID>(os, indentation, value_, format);
00721     }
00722 
00723     void writeValue(std::ostream& os, int, LuminosityBlockID const& value_, ValueFormat format) {
00724       writeValue<LuminosityBlockID>(os, value_, format);
00725     }
00726 
00727     void writeValue(std::ostream& os, int indentation, std::vector<LuminosityBlockID> const& value_, ValueFormat format) {
00728       writeVector<LuminosityBlockID>(os, indentation, value_, format);
00729     }
00730 
00731     void writeValue(std::ostream& os, int, LuminosityBlockRange const& value_, ValueFormat format) {
00732       writeValue<LuminosityBlockRange>(os, value_, format);
00733     }
00734 
00735     void writeValue(std::ostream& os, int indentation, std::vector<LuminosityBlockRange> const& value_, ValueFormat format) {
00736       writeVector<LuminosityBlockRange>(os, indentation, value_, format);
00737     }
00738 
00739     void writeValue(std::ostream& os, int, EventRange const& value_, ValueFormat format) {
00740       writeValue<EventRange>(os, value_, format);
00741     }
00742 
00743     void writeValue(std::ostream& os, int indentation, std::vector<EventRange> const& value_, ValueFormat format) {
00744       writeVector<EventRange>(os, indentation, value_, format);
00745     }
00746 
00747     void writeValue(std::ostream& os, int, InputTag const& value_, ValueFormat format) {
00748       writeValue<InputTag>(os, value_, format);
00749     }
00750 
00751     void writeValue(std::ostream& os, int indentation, std::vector<InputTag> const& value_, ValueFormat format) {
00752       writeVector<InputTag>(os, indentation, value_, format);
00753     }
00754 
00755     void writeValue(std::ostream& os, int, FileInPath const& value_, ValueFormat format) {
00756       writeValue<FileInPath>(os, value_, format);
00757     }
00758 
00759     bool hasNestedContent(int const&) { return false; }
00760     bool hasNestedContent(std::vector<int> const& value) { return value.size() > 5U; }
00761     bool hasNestedContent(unsigned const&) { return false; }
00762     bool hasNestedContent(std::vector<unsigned> const& value) { return value.size() > 5U; }
00763     bool hasNestedContent(long long const&) { return false; }
00764     bool hasNestedContent(std::vector<long long> const& value) { return value.size() > 5U; }
00765     bool hasNestedContent(unsigned long long const&) { return false; }
00766     bool hasNestedContent(std::vector<unsigned long long> const& value) { return value.size() > 5U; }
00767     bool hasNestedContent(double const&) { return false; }
00768     bool hasNestedContent(std::vector<double> const& value) { return value.size() > 5U; }
00769     bool hasNestedContent(bool const&) { return false; }
00770     bool hasNestedContent(std::string const&) { return false; }
00771     bool hasNestedContent(std::vector<std::string> const& value) { return value.size() > 5U; }
00772     bool hasNestedContent(EventID const&) { return false; }
00773     bool hasNestedContent(std::vector<EventID> const& value) { return value.size() > 5U; }
00774     bool hasNestedContent(LuminosityBlockID const&) { return false; }
00775     bool hasNestedContent(std::vector<LuminosityBlockID> const& value) { return value.size() > 5U; }
00776     bool hasNestedContent(LuminosityBlockRange const&) { return false; }
00777     bool hasNestedContent(std::vector<LuminosityBlockRange> const& value) { return value.size() > 5U; }
00778     bool hasNestedContent(EventRange const&) { return false; }
00779     bool hasNestedContent(std::vector<EventRange> const& value) { return value.size() > 5U; }
00780     bool hasNestedContent(InputTag const&) { return false; }
00781     bool hasNestedContent(std::vector<InputTag> const& value) { return value.size() > 5U; }
00782     bool hasNestedContent(FileInPath const&) { return false; }
00783   }
00784 }