18 #include "boost/bind.hpp" 27 void matchLabel(std::pair<std::string, edm::ParameterSetDescription>
const& thePair,
30 if (thePair.first == moduleLabel) {
31 psetDesc = &thePair.second;
36 static const char*
const kSource =
"Source";
44 defaultDescDefined_(
false)
61 add(labelString, psetDescription);
69 if (0!=strcmp(label.c_str(),
k_source)) {
71 "ConfigurationDescriptions::add, when adding a ParameterSetDescription for a source the label must be \"source\"\n");
76 "ConfigurationDescriptions::add, for a source only 1 ParameterSetDescription may be added\n");
83 "ConfigurationDescriptions::add, for a service only 1 ParameterSetDescription may be added\n");
89 std::pair<std::string, ParameterSetDescription> pairWithEmptyDescription;
91 std::pair<std::string, ParameterSetDescription> & pair =
descriptions_.back();
94 pair.second = psetDescription;
105 "ConfigurationDescriptions::addDefault, for a source or service only 1 ParameterSetDescription may be added\n");
135 std::placeholders::_1,
136 std::cref(moduleLabel),
137 std::ref(psetDesc)));
160 std::placeholders::_1,
162 std::cref(pluginName)));
171 if (0 == strcmp(baseType.c_str(),
kService) && labelAndDesc.first != pluginName) {
173 "ConfigurationDescriptions::writeCfiForLabel\nFor a service the label and the plugin name must be the same.\n")
174 <<
"This error probably is caused by an incorrect label being passed\nto the ConfigurationDescriptions::add function earlier.\n" 175 <<
"plugin name = \"" << pluginName <<
"\" label name = \"" << labelAndDesc.first <<
"\"\n";
179 if (0 == strcmp(baseType.c_str(),
kSource)) {
180 cfi_filename = pluginName +
"_cfi.py";
183 cfi_filename = labelAndDesc.first +
"_cfi.py";
185 std::ofstream
outFile(cfi_filename.c_str());
188 outFile <<
"import FWCore.ParameterSet.Config as cms\n\n";
189 outFile << labelAndDesc.first <<
" = cms." << baseType <<
"('" << pluginName <<
"'";
191 bool startWithComma =
true;
193 labelAndDesc.second.writeCfi(outFile, startWithComma, indentation);
199 if (0 == strcmp(baseType.c_str(),
kSource)) {
210 bool printOnlyLabels,
222 char oldFill = os.fill();
224 os << std::setfill(
' ') << std::setw(indentation) <<
"";
225 os <<
"There are no PSet descriptions defined for this plugin.\n";
226 os << std::setfill(
' ') << std::setw(indentation) <<
"";
227 os <<
"PSets will not be validated and no cfi files will be generated.\n";
228 os << std::setfill(oldFill);
229 if (!brief) os <<
"\n";
235 char oldFill = os.fill();
236 os << std::setfill(
' ') << std::setw(indentation) <<
"";
237 os <<
"This plugin has not implemented the function which defines its\n";
238 os << std::setfill(
' ') << std::setw(indentation) <<
"";
239 os <<
"configuration descriptions yet. No descriptions are available.\n";
240 os << std::setfill(
' ') << std::setw(indentation) <<
"";
241 os <<
"Its PSets will not be validated, and no cfi files will be generated.\n";
242 os << std::setfill(oldFill);
243 if (!brief) os <<
"\n";
248 std::stringstream ss;
251 ss <<
"This plugin has only one PSet description. " 252 <<
"This description is always used to validate configurations. " 253 <<
"Because this configuration has no label, no cfi files will be generated.";
256 ss <<
"This plugin has " << (
descriptions_.size() + 1
U) <<
" PSet descriptions. " 257 <<
"The description used to validate a configuration is selected by " 258 <<
"matching the module labels. If none match, then the last description, " 259 <<
"which has no label, is selected. " 260 <<
"A cfi file will be generated for each configuration with a module label.";
265 ss <<
"This plugin has " <<
descriptions_.size() <<
" PSet description. " 266 <<
"This description is always used to validate configurations. " 267 <<
"The label below is used when generating the cfi file.";
270 ss <<
"This plugin has " <<
descriptions_.size() <<
" PSet descriptions. " 271 <<
"The description used to validate a configuration is selected by " 272 <<
"matching the module labels. If none match the first description below is used. " 273 <<
"The module labels below are also used when generating the cfi files.";
291 std::cref(moduleLabel),
316 bool printOnlyLabels,
338 bool printOnlyLabels,
344 if (!moduleLabel.empty() && label != moduleLabel)
return;
347 std::stringstream ss;
351 char oldFill = os.fill();
352 os << std::setfill(
' ') << std::setw(indentation) <<
"" << std::setfill(oldFill);
353 os << section <<
" ";
355 os <<
"description without a module label\n";
363 os <<
"module label: ";
370 if (!description.
comment().empty()) {
375 if (printOnlyLabels)
return;
384 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
static const char *const kService
void validate(ParameterSet &pset) const
static void writeCfiForLabel(std::pair< std::string, ParameterSetDescription > const &labelAndDesc, std::string const &baseType, std::string const &pluginName)
ParameterSetDescription * defaultDescription()
Returns 0 if no default has been assigned.
static const char *const kSource
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)
static std::atomic< unsigned int > counter
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
static const char *const k_source
std::vector< std::pair< std::string, ParameterSetDescription > >::iterator iterator
ParameterSetDescription defaultDesc_