18 #include "boost/bind.hpp"
26 void matchLabel(std::pair<std::string, edm::ParameterSetDescription>
const& thePair,
29 if (thePair.first == moduleLabel) {
30 psetDesc = &thePair.second;
39 defaultDescDefined_(
false)
55 std::string labelString(label);
56 add(labelString, psetDescription);
64 if (label != std::string(
"source")) {
66 "ConfigurationDescriptions::add, when adding a ParameterSetDescription for a source the label must be \"source\"\n");
71 "ConfigurationDescriptions::add, for a source only 1 ParameterSetDescription may be added\n");
74 else if (
baseType_ == std::string(
"Service")) {
78 "ConfigurationDescriptions::add, for a service only 1 ParameterSetDescription may be added\n");
84 std::pair<std::string, ParameterSetDescription> pairWithEmptyDescription;
86 std::pair<std::string, ParameterSetDescription> & pair =
descriptions_.back();
89 pair.second = psetDescription;
99 "ConfigurationDescriptions::addDefault, for a source or service only 1 ParameterSetDescription may be added\n");
114 boost::cref(moduleLabel),
115 boost::ref(psetDesc)));
135 std::string
const& pluginName)
const {
139 boost::cref(baseType),
140 boost::cref(pluginName)));
146 std::string
const& baseType,
147 std::string
const& pluginName)
149 if (baseType == std::string(
"Service") && labelAndDesc.first != pluginName) {
151 "ConfigurationDescriptions::writeCfiForLabel\nFor a service the label and the plugin name must be the same.\n")
152 <<
"This error probably is caused by an incorrect label being passed\nto the ConfigurationDescriptions::add function earlier.\n"
153 <<
"plugin name = \"" << pluginName <<
"\" label name = \"" << labelAndDesc.first <<
"\"\n";
156 std::string cfi_filename;
157 if (baseType == std::string(
"Source")) {
158 cfi_filename = pluginName +
"_cfi.py";
161 cfi_filename = labelAndDesc.first +
"_cfi.py";
163 std::ofstream outFile(cfi_filename.c_str());
166 outFile <<
"import FWCore.ParameterSet.Config as cms\n\n";
167 outFile << labelAndDesc.first <<
" = cms." << baseType <<
"('" << pluginName <<
"'";
169 bool startWithComma =
true;
171 labelAndDesc.second.writeCfi(outFile, startWithComma, indentation);
177 if (baseType == std::string(
"Source")) {
188 bool printOnlyLabels,
199 char oldFill = os.fill();
202 os << std::setfill(
' ') << std::setw(indentation) <<
"";
203 os <<
"There are no PSet descriptions defined for this plugin.\n";
204 os << std::setfill(
' ') << std::setw(indentation) <<
"";
205 os <<
"PSets will not be validated and no cfi files will be generated.\n";
206 if (!brief) os <<
"\n";
213 os << std::setfill(
' ') << std::setw(indentation) <<
"";
214 os <<
"This plugin has not implemented the function which defines its\n";
215 os << std::setfill(
' ') << std::setw(indentation) <<
"";
216 os <<
"configuration descriptions yet. No descriptions are available.\n";
217 os << std::setfill(
' ') << std::setw(indentation) <<
"";
218 os <<
"Its PSets will not be validated, and no cfi files will be generated.\n";
219 if (!brief) os <<
"\n";
225 std::stringstream ss;
228 ss <<
"This plugin has only one PSet description. "
229 <<
"This description is always used to validate configurations. "
230 <<
"Because this configuration has no label, no cfi files will be generated.";
233 ss <<
"This plugin has " << (
descriptions_.size() + 1U) <<
" PSet descriptions. "
234 <<
"The description used to validate a configuration is selected by "
235 <<
"matching the module labels. If none match, then the last description, "
236 <<
"which has no label, is selected. "
237 <<
"A cfi file will be generated for each configuration with a module label.";
242 ss <<
"This plugin has " <<
descriptions_.size() <<
" PSet description. "
243 <<
"This description is always used to validate configurations. "
244 <<
"The label below is used when generating the cfi file.";
247 ss <<
"This plugin has " <<
descriptions_.size() <<
" PSet descriptions. "
248 <<
"The description used to validate a configuration is selected by "
249 <<
"matching the module labels. If none match the first description below is used. "
250 <<
"The module labels below are also used when generating the cfi files.";
268 boost::cref(moduleLabel),
273 boost::ref(counter)));
277 std::string(
"@default"),
293 bool printOnlyLabels,
311 std::string
const&
label,
315 bool printOnlyLabels,
321 if (!moduleLabel.empty() && label !=
moduleLabel)
return;
324 std::stringstream ss;
326 std::string section = ss.str();
328 char oldFill = os.fill();
329 os << std::setfill(
' ') << std::setw(indentation) <<
"";
331 os << section <<
" ";
332 if (label == std::string(
"@default")) {
333 os <<
"description without a module label\n";
341 os <<
"module label: ";
348 if (!description.
comment().empty()) {
353 if (printOnlyLabels)
return;
362 description.
print(os, dfh);
void writeCfis(std::string const &baseType, std::string const &pluginName) const
~ConfigurationDescriptions()
void printForLabel(std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentationn, DescriptionCounter &counter) const
void validate(ParameterSet &pset) const
static void writeCfiForLabel(std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::string const &baseType, std::string const &pluginName)
ConfigurationDescriptions(std::string const &baseType)
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
void addDefault(ParameterSetDescription const &psetDescription)
std::vector< std::pair< std::string, ParameterSetDescription > > descriptions_
void print(std::ostream &os, DocFormatHelper &dfh) const
void setComment(std::string const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
void print(std::ostream &os, std::string const &moduleLabel, bool brief, bool printOnlyLabels, size_t lineWidth, int indentation, int iPlugin) const
void validate(ParameterSet &pset, std::string const &moduleLabel) const
std::string const & comment() const
std::string const & comment() const
ParameterSetDescription defaultDesc_
const std::string * moduleLabel() const