CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/FWCore/ParameterSet/src/ParameterDescription.cc

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