16 node_left_(node_left.
clone()),
17 node_right_(node_right.
clone()) {
29 std::unique_ptr<ParameterDescriptionNode> node_right) :
36 std::unique_ptr<ParameterDescriptionNode> node_right) :
44 std::set<ParameterTypes> & parameterTypes,
45 std::set<ParameterTypes> & wildcardTypes)
const {
47 std::set<std::string> labelsLeft;
48 std::set<ParameterTypes> parameterTypesLeft;
49 std::set<ParameterTypes> wildcardTypesLeft;
50 node_left_->checkAndGetLabelsAndTypes(labelsLeft, parameterTypesLeft, wildcardTypesLeft);
52 std::set<std::string> labelsRight;
53 std::set<ParameterTypes> parameterTypesRight;
54 std::set<ParameterTypes> wildcardTypesRight;
55 node_right_->checkAndGetLabelsAndTypes(labelsRight, parameterTypesRight, wildcardTypesRight);
61 usedLabels.insert(labelsLeft.begin(), labelsLeft.end());
62 usedLabels.insert(labelsRight.begin(), labelsRight.end());
64 parameterTypes.insert(parameterTypesRight.begin(), parameterTypesRight.end());
65 parameterTypes.insert(parameterTypesLeft.begin(), parameterTypesLeft.end());
67 wildcardTypes.insert(wildcardTypesRight.begin(), wildcardTypesRight.end());
68 wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end());
74 std::set<std::string> & validatedLabels,
75 bool optional)
const {
80 if (!leftExists && !rightExists) {
83 else if (leftExists && rightExists) {
84 node_left_->validate(pset, validatedLabels,
false);
85 node_right_->validate(pset, validatedLabels,
false);
87 else if (leftExists && !rightExists) {
88 node_left_->validate(pset, validatedLabels,
false);
89 if (!optional)
node_right_->validate(pset, validatedLabels,
false);
91 else if (!leftExists && rightExists) {
92 node_left_->validate(pset, validatedLabels,
false);
93 node_right_->validate(pset, validatedLabels,
false);
100 bool & startWithComma,
102 bool & wroteSomething)
const {
103 node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
104 node_right_->writeCfi(os, startWithComma, indentation, wroteSomething);
114 if (dfh.
pass() == 1) {
117 os <<
"IfExists pair:";
121 if (optional) os <<
" optional";
123 if (!writeToCfi) os <<
" (do not write to cfi)";
125 os <<
" see Section " << dfh.
section() <<
"." << dfh.
counter() <<
"\n";
133 if (optional) os <<
"optional";
134 if (!writeToCfi) os <<
" (do not write to cfi)";
135 if (optional || !writeToCfi) {
140 os <<
"see Section " << dfh.
section() <<
"." << dfh.
counter() <<
"\n";
164 std::stringstream ss;
169 os <<
"Section " << newSection;
170 if (optional) os <<
" optional";
171 os <<
" IfExists pair description:\n";
174 os <<
"If the first parameter exists, then the second is allowed to exist\n";
177 os <<
"If the first parameter exists, then the second is required to exist\n";
179 if (!dfh.
brief()) os <<
"\n";
199 node_left_->printNestedContent(os,
false, new_dfh);
200 node_right_->printNestedContent(os,
false , new_dfh);
209 if (leftExists && rightExists)
return true;
210 else if (!leftExists && !rightExists)
return true;
223 return exists(pset) ? 1 : 0;
229 std::set<std::string>
const& labelsRight)
const {
231 std::set<std::string> duplicateLabels;
232 std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
233 std::set_intersection(labelsLeft.begin(), labelsLeft.end(),
234 labelsRight.begin(), labelsRight.end(),
236 if (!duplicateLabels.empty()) {
237 std::stringstream ss;
238 for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(),
239 iEnd = duplicateLabels.end();
242 ss <<
" \"" << *iter <<
"\"\n";
245 <<
"Labels used in a node of a ParameterSetDescription\n" 246 <<
"\"ifExists\" expression must be not be the same as labels used\n" 247 <<
"in other nodes of the expression. The following duplicate\n" 248 <<
"labels were detected:\n" 257 std::set<ParameterTypes>
const& types2)
const 259 if (!types1.empty()) {
260 std::set<ParameterTypes> duplicateTypes;
261 std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
262 std::set_intersection(types1.begin(), types1.end(),
263 types2.begin(), types2.end(),
265 if (!duplicateTypes.empty()) {
266 std::stringstream ss;
267 for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(),
268 iEnd = duplicateTypes.end();
274 <<
"Types used for wildcards in a node of a ParameterSetDescription\n" 275 <<
"\"ifExists\" expression must be different from types used for other parameters\n" 276 <<
"in other nodes. The following duplicate types were detected:\n"
virtual int howManyXORSubNodesExist_(ParameterSet const &pset) const
std::string parameterTypeEnumToString(ParameterTypes iType)
virtual ParameterDescriptionNode * clone() const
IfExistsDescription(ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)
virtual bool exists_(ParameterSet const &pset) const
virtual void writeCfi_(std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const
void throwIfDuplicateLabels(std::set< std::string > const &labelsLeft, std::set< std::string > const &labelsRight) const
void throwIfDuplicateTypes(std::set< ParameterTypes > const &types1, std::set< ParameterTypes > const &types2) const
std::string const & comment() const
virtual void print_(std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh) const
edm::value_ptr< ParameterDescriptionNode > node_right_
edm::value_ptr< ParameterDescriptionNode > node_left_
virtual void printNestedContent_(std::ostream &os, bool optional, DocFormatHelper &dfh) const
static void printSpaces(std::ostream &os, int n)
bool exists(ParameterSet const &pset) const
virtual void checkAndGetLabelsAndTypes_(std::set< std::string > &usedLabels, std::set< ParameterTypes > ¶meterTypes, std::set< ParameterTypes > &wildcardTypes) const
virtual bool partiallyExists_(ParameterSet const &pset) const
virtual void validate_(ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)