21 #include "boost/bind.hpp"
31 anythingAllowed_(
false),
61 std::auto_ptr<ParameterDescriptionNode> clonedNode(node.
clone());
62 return addNode(clonedNode,
false,
true);
68 return addNode(node,
false,
true);
74 std::auto_ptr<ParameterDescriptionNode> clonedNode(node.
clone());
75 return addNode(clonedNode,
true, writeToCfi);
81 return addNode(node,
true, writeToCfi);
90 std::set<std::string> nodeLabels;
91 std::set<ParameterTypes> nodeParameterTypes;
92 std::set<ParameterTypes> nodeWildcardTypes;
111 std::set<std::string> validatedLabels;
116 if (validatedLabels.size() != parameterNames.size()) {
123 std::string module_label(
"@module_label");
124 if (pset.
exists(module_label)) {
125 validatedLabels.insert(module_label);
128 std::string module_type(
"@module_type");
129 if (pset.
exists(module_type)) {
130 validatedLabels.insert(module_type);
133 std::string module_edm_type(
"@module_edm_type");
134 if (pset.
exists(module_edm_type)) {
135 validatedLabels.insert(module_edm_type);
138 std::string service_type(
"@service_type");
139 if (pset.
exists(service_type)) {
140 validatedLabels.insert(service_type);
144 if (validatedLabels.size() != parameterNames.size()) {
154 int indentation)
const {
155 bool wroteSomething =
false;
160 boost::ref(startWithComma),
162 boost::ref(wroteSomething)));
164 if (wroteSomething) {
165 char oldFill = os.fill();
166 os <<
"\n" << std::setfill(
' ') << std::setw(indentation - 2) <<
"";
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 and requires nothing.\n";
193 os <<
"The configured PSet will not be validated.\n";
194 if (!dfh.
brief()) os <<
"\n";
199 os <<
"Description is empty\n";
200 if (!dfh.
brief()) os <<
"\n";
232 std::vector<std::string>
const& parameterNames,
233 std::set<std::string>
const& validatedLabels) {
235 std::set<std::string> parNames(parameterNames.begin(), parameterNames.end());
238 std::set<std::string> diffNames;
239 std::insert_iterator<std::set<std::string> > insertIter(diffNames, diffNames.begin());
240 std::set_difference(parNames.begin(), parNames.end(),
241 validatedLabels.begin(), validatedLabels.end(),
244 std::stringstream ss;
245 for (std::set<std::string>::const_iterator iter = diffNames.begin(),
246 iEnd = diffNames.end();
249 ss <<
" \"" << *iter <<
"\"\n";
251 if (diffNames.size() == 1U) {
253 <<
"Illegal parameter found in configuration. The parameter is named:\n"
255 <<
"You could be trying to use a parameter name that is not\n"
256 <<
"allowed for this plugin or it could be misspelled.\n";
260 <<
"Illegal parameters found in configuration. The parameters are named:\n"
262 <<
"You could be trying to use parameter names that are not\n"
263 <<
"allowed for this plugin or they could be misspelled.\n";
270 bool & startWithComma,
272 bool & wroteSomething) {
274 entry.
node()->writeCfi(os, startWithComma, indentation, wroteSomething);
282 if (dfh.
pass() < 2) {
286 entry.
node()->printNestedContent(os, entry.
optional(), dfh);
294 std::set<std::string> duplicateLabels;
295 std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
296 std::set_intersection(nodeLabels.begin(), nodeLabels.end(),
299 if (duplicateLabels.empty()) {
300 usedLabels_.insert(nodeLabels.begin(), nodeLabels.end());
304 std::stringstream ss;
305 for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(),
306 iEnd = duplicateLabels.end();
309 ss <<
" \"" << *iter <<
"\"\n";
312 <<
"Labels used in different nodes of a ParameterSetDescription\n"
313 <<
"must be unique. The following duplicate labels were detected:\n"
322 std::set<ParameterTypes>
const& nodeWildcardTypes) {
335 if (!nodeWildcardTypes.empty()) {
337 std::set<ParameterTypes> duplicateTypes1;
338 std::insert_iterator<std::set<ParameterTypes> > insertIter1(duplicateTypes1, duplicateTypes1.begin());
340 nodeWildcardTypes.begin(), nodeWildcardTypes.end(),
343 if (!duplicateTypes1.empty()) {
345 std::stringstream ss;
346 for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes1.begin(),
347 iEnd = duplicateTypes1.end();
353 <<
"Within a ParameterSetDescription, the type used for a wildcard must\n"
354 <<
"not be the same as the type used for other parameters. This rule\n"
355 <<
"is violated for the following types:\n"
363 std::set<ParameterTypes> duplicateTypes2;
364 std::insert_iterator<std::set<ParameterTypes> > insertIter2(duplicateTypes2, duplicateTypes2.begin());
366 nodeParameterTypes.begin(), nodeParameterTypes.end(),
369 if (!duplicateTypes2.empty()) {
371 std::stringstream ss;
372 for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes2.begin(),
373 iEnd = duplicateTypes2.end();
379 <<
"Within a ParameterSetDescription, the type used for a wildcard must\n"
380 <<
"not be the same as the type used for other parameters. This rule is\n"
381 <<
"violated for the following types :\n"
395 bool optional,
bool writeToCfi) {
397 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
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)
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()