22 #include "boost/bind.hpp"
32 anythingAllowed_(
false),
62 std::auto_ptr<ParameterDescriptionNode> clonedNode(node.
clone());
63 return addNode(clonedNode,
false,
true);
69 return addNode(node,
false,
true);
75 std::auto_ptr<ParameterDescriptionNode> clonedNode(node.
clone());
76 return addNode(clonedNode,
true, writeToCfi);
82 return addNode(node,
true, writeToCfi);
91 std::set<std::string> nodeLabels;
92 std::set<ParameterTypes> nodeParameterTypes;
93 std::set<ParameterTypes> nodeWildcardTypes;
102 return entries_.back().setNode(node);
110 std::set<std::string> validatedLabels;
115 if (validatedLabels.size() != parameterNames.size()) {
123 if (pset.
exists(module_label)) {
124 validatedLabels.insert(module_label);
128 if (pset.
exists(module_type)) {
129 validatedLabels.insert(module_type);
133 if (pset.
exists(module_edm_type)) {
134 validatedLabels.insert(module_edm_type);
138 if (pset.
exists(service_type)) {
139 validatedLabels.insert(service_type);
143 if (validatedLabels.size() != parameterNames.size()) {
155 int indentation)
const {
156 bool wroteSomething =
false;
161 boost::ref(startWithComma),
163 boost::ref(wroteSomething)));
165 if (wroteSomething) {
166 char oldFill = os.fill();
167 os <<
"\n" << std::setfill(
' ') << std::setw(indentation - 2) <<
"" << std::setfill(oldFill);
174 std::set<std::string> & validatedLabels) {
175 entry.
node()->validate(pset, validatedLabels, entry.
optional());
183 os <<
"Description is unknown. The configured PSet will not be validated\n";
185 os <<
"because the plugin has not defined this parameter set description.\n";
186 if (!dfh.
brief()) os <<
"\n";
191 os <<
"Description allows anything. If the configured PSet contains illegal parameters,\n";
193 os <<
"then validation will ignore them instead of throwing an exception.\n";
194 if (!dfh.
brief()) os <<
"\n";
199 os <<
"Description is empty\n";
200 if (!dfh.
brief()) os <<
"\n";
238 std::vector<std::string>
const& parameterNames,
239 std::set<std::string>
const& validatedLabels) {
241 std::set<std::string> parNames(parameterNames.begin(), parameterNames.end());
244 std::set<std::string> diffNames;
245 std::insert_iterator<std::set<std::string> > insertIter(diffNames, diffNames.begin());
246 std::set_difference(parNames.begin(), parNames.end(),
247 validatedLabels.begin(), validatedLabels.end(),
250 std::stringstream ss;
251 for (std::set<std::string>::const_iterator iter = diffNames.begin(),
252 iEnd = diffNames.end();
255 ss <<
" '" << *iter <<
"'\n";
257 if (diffNames.size() == 1U) {
259 <<
"Illegal parameter found in configuration. The parameter is named:\n"
261 <<
"You could be trying to use a parameter name that is not\n"
262 <<
"allowed for this plugin or it could be misspelled.\n";
266 <<
"Illegal parameters found in configuration. The parameters are named:\n"
268 <<
"You could be trying to use parameter names that are not\n"
269 <<
"allowed for this plugin or they could be misspelled.\n";
276 bool & startWithComma,
278 bool & wroteSomething) {
280 entry.
node()->writeCfi(os, startWithComma, indentation, wroteSomething);
288 if (dfh.
pass() < 2) {
292 entry.
node()->printNestedContent(os, entry.
optional(), dfh);
300 std::set<std::string> duplicateLabels;
301 std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
302 std::set_intersection(nodeLabels.begin(), nodeLabels.end(),
305 if (duplicateLabels.empty()) {
306 usedLabels_.insert(nodeLabels.begin(), nodeLabels.end());
310 std::stringstream ss;
311 for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(),
312 iEnd = duplicateLabels.end();
315 ss <<
" \"" << *iter <<
"\"\n";
318 <<
"Labels used in different nodes of a ParameterSetDescription\n"
319 <<
"must be unique. The following duplicate labels were detected:\n"
328 std::set<ParameterTypes>
const& nodeWildcardTypes) {
341 if (!nodeWildcardTypes.empty()) {
343 std::set<ParameterTypes> duplicateTypes1;
344 std::insert_iterator<std::set<ParameterTypes> > insertIter1(duplicateTypes1, duplicateTypes1.begin());
346 nodeWildcardTypes.begin(), nodeWildcardTypes.end(),
349 if (!duplicateTypes1.empty()) {
351 std::stringstream ss;
352 for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes1.begin(),
353 iEnd = duplicateTypes1.end();
359 <<
"Within a ParameterSetDescription, the type used for a wildcard must\n"
360 <<
"not be the same as the type used for other parameters. This rule\n"
361 <<
"is violated for the following types:\n"
369 std::set<ParameterTypes> duplicateTypes2;
370 std::insert_iterator<std::set<ParameterTypes> > insertIter2(duplicateTypes2, duplicateTypes2.begin());
372 nodeParameterTypes.begin(), nodeParameterTypes.end(),
375 if (!duplicateTypes2.empty()) {
377 std::stringstream ss;
378 for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes2.begin(),
379 iEnd = duplicateTypes2.end();
385 <<
"Within a ParameterSetDescription, the type used for a wildcard must\n"
386 <<
"not be the same as the type used for other parameters. This rule is\n"
387 <<
"violated for the following types :\n"
401 bool optional,
bool writeToCfi) {
403 return addNode(pdIfExists, optional, writeToCfi);
SetDescriptionEntries entries_
virtual ParameterDescriptionNode * clone() const =0
static void throwIllegalParameters(std::vector< std::string > const ¶meterNames, std::set< std::string > const &validatedNames)
edm::value_ptr< ParameterDescriptionNode > const & node() const
void setOptional(bool value)
void throwIfWildcardCollision(std::set< ParameterTypes > const &nodeParameterTypes, std::set< ParameterTypes > const &nodeWildcardTypes)
void setAllowAnything()
allow any parameter label/value pairs
void validate(ParameterSet &pset) const
void setWriteToCfi(bool value)
std::set< std::string > usedLabels_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
static bool throwAnException()
ParameterDescriptionNode * ifExists(ParameterDescriptionNode const &node1, ParameterDescriptionNode const &node2)
ParameterDescriptionNode * addNode(ParameterDescriptionNode const &node)
static void writeNode(SetDescriptionEntry const &entry, std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething)
void writeCfi(std::ostream &os, bool startWithComma, int indentation) const
std::string parameterTypeEnumToString(ParameterTypes iType)
std::set< ParameterTypes > typesUsedForParameters_
Func for_all(ForwardSequence &s, Func f)
wrapper for std::for_each
void setComment(std::string const &value)
bool anythingAllowed() const
void throwIfLabelsAlreadyUsed(std::set< std::string > const &nodeLabels)
std::pair< std::string, MonitorElement * > entry
void print(std::ostream &os, DocFormatHelper &dfh) const
ParameterDescriptionNode * addOptionalNode(ParameterDescriptionNode const &node, bool writeToCfi)
bool isLabelUnused(std::string const &label) const
std::vector< std::string > getParameterNames() const
static void validateNode(SetDescriptionEntry const &entry, ParameterSet &pset, std::set< std::string > &validatedNames)
static void printNode(SetDescriptionEntry const &entry, std::ostream &os, DocFormatHelper &dfh)
ParameterSetDescription()
static const uint16_t unknown_
std::set< ParameterTypes > typesUsedForWildcards_
void checkAndGetLabelsAndTypes(std::set< std::string > &usedLabels, std::set< ParameterTypes > ¶meterTypes, std::set< ParameterTypes > &wildcardTypes) const
virtual ~ParameterSetDescription()