CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

edm::IfExistsDescription Class Reference

#include <IfExistsDescription.h>

Inheritance diagram for edm::IfExistsDescription:
edm::ParameterDescriptionNode

List of all members.

Public Member Functions

virtual ParameterDescriptionNodeclone () const
 IfExistsDescription (std::auto_ptr< ParameterDescriptionNode > node_left, ParameterDescriptionNode const &node_right)
 IfExistsDescription (std::auto_ptr< ParameterDescriptionNode > node_left, std::auto_ptr< ParameterDescriptionNode > node_right)
 IfExistsDescription (ParameterDescriptionNode const &node_left, std::auto_ptr< ParameterDescriptionNode > node_right)
 IfExistsDescription (ParameterDescriptionNode const &node_left, ParameterDescriptionNode const &node_right)

Private Member Functions

virtual void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
virtual bool exists_ (ParameterSet const &pset) const
virtual bool hasNestedContent_ ()
virtual int howManyXORSubNodesExist_ (ParameterSet const &pset) const
virtual bool partiallyExists_ (ParameterSet const &pset) const
virtual void print_ (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
virtual void printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh)
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
virtual void validate_ (ParameterSet &pset, std::set< std::string > &validatedLabels, bool optional) const
virtual void writeCfi_ (std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const

Private Attributes

edm::value_ptr
< ParameterDescriptionNode
node_left_
edm::value_ptr
< ParameterDescriptionNode
node_right_

Detailed Description

Definition at line 18 of file IfExistsDescription.h.


Constructor & Destructor Documentation

edm::IfExistsDescription::IfExistsDescription ( ParameterDescriptionNode const &  node_left,
ParameterDescriptionNode const &  node_right 
)

Definition at line 14 of file IfExistsDescription.cc.

Referenced by clone().

                                                                  :
    node_left_(node_left.clone()),
    node_right_(node_right.clone()) {
  }
edm::IfExistsDescription::IfExistsDescription ( std::auto_ptr< ParameterDescriptionNode node_left,
ParameterDescriptionNode const &  node_right 
)

Definition at line 21 of file IfExistsDescription.cc.

                                                                  :
    node_left_(node_left),
    node_right_(node_right.clone()) {
  }
edm::IfExistsDescription::IfExistsDescription ( ParameterDescriptionNode const &  node_left,
std::auto_ptr< ParameterDescriptionNode node_right 
)

Definition at line 28 of file IfExistsDescription.cc.

                                                                        :
    node_left_(node_left.clone()),
    node_right_(node_right) {
  }
edm::IfExistsDescription::IfExistsDescription ( std::auto_ptr< ParameterDescriptionNode node_left,
std::auto_ptr< ParameterDescriptionNode node_right 
)

Definition at line 35 of file IfExistsDescription.cc.

                                                                        :
    node_left_(node_left),
    node_right_(node_right) {
  }

Member Function Documentation

void edm::IfExistsDescription::checkAndGetLabelsAndTypes_ ( std::set< std::string > &  usedLabels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 43 of file IfExistsDescription.cc.

References node_left_, node_right_, throwIfDuplicateLabels(), and throwIfDuplicateTypes().

                                                                           {

    std::set<std::string> labelsLeft;
    std::set<ParameterTypes> parameterTypesLeft;
    std::set<ParameterTypes> wildcardTypesLeft;
    node_left_->checkAndGetLabelsAndTypes(labelsLeft, parameterTypesLeft, wildcardTypesLeft);

    std::set<std::string> labelsRight;
    std::set<ParameterTypes> parameterTypesRight;
    std::set<ParameterTypes> wildcardTypesRight;
    node_right_->checkAndGetLabelsAndTypes(labelsRight, parameterTypesRight, wildcardTypesRight);

    throwIfDuplicateLabels(labelsLeft, labelsRight);
    throwIfDuplicateTypes(wildcardTypesLeft, parameterTypesRight);
    throwIfDuplicateTypes(wildcardTypesRight, parameterTypesLeft);

    usedLabels.insert(labelsLeft.begin(), labelsLeft.end());
    usedLabels.insert(labelsRight.begin(), labelsRight.end());

    parameterTypes.insert(parameterTypesRight.begin(), parameterTypesRight.end());
    parameterTypes.insert(parameterTypesLeft.begin(), parameterTypesLeft.end());

    wildcardTypes.insert(wildcardTypesRight.begin(), wildcardTypesRight.end());
    wildcardTypes.insert(wildcardTypesLeft.begin(), wildcardTypesLeft.end());
  }
virtual ParameterDescriptionNode* edm::IfExistsDescription::clone ( void  ) const [inline, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 32 of file IfExistsDescription.h.

References IfExistsDescription().

                                                    {
      return new IfExistsDescription(*this);
    }
bool edm::IfExistsDescription::exists_ ( ParameterSet const &  pset) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 205 of file IfExistsDescription.cc.

References node_left_, and node_right_.

                                          {
    bool leftExists = node_left_->exists(pset);
    bool rightExists = node_right_->exists(pset);

    if (leftExists && rightExists) return true;
    else if (!leftExists && !rightExists) return true;
    return false;
  }
virtual bool edm::IfExistsDescription::hasNestedContent_ ( ) [inline, private, virtual]

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 56 of file IfExistsDescription.h.

                                     {
      return true;
    }
int edm::IfExistsDescription::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 222 of file IfExistsDescription.cc.

References edm::ParameterDescriptionNode::exists().

                                                           {
    return exists(pset) ? 1 : 0;
  }
bool edm::IfExistsDescription::partiallyExists_ ( ParameterSet const &  pset) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 216 of file IfExistsDescription.cc.

References edm::ParameterDescriptionNode::exists().

                                                   {
    return exists(pset);
  }
void edm::IfExistsDescription::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) [private, virtual]

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 109 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), edm::DocFormatHelper::pass(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and edm::DocFormatHelper::wrapAndPrintText().

                                {

    if (dfh.pass() == 1) {

      dfh.indent(os);
      os << "IfExists pair:";

      if (dfh.brief()) {

        if (optional)  os << " optional";

        if (!writeToCfi) os << " (do not write to cfi)";

        os << " see Section " << dfh.section() << "." << dfh.counter() << "\n";
      }
      // not brief
      else {

        os << "\n";
        dfh.indent2(os);

        if (optional)  os << "optional";
        if (!writeToCfi) os << " (do not write to cfi)";
        if (optional || !writeToCfi) {
          os << "\n";
          dfh.indent2(os);
        }

        os << "see Section " << dfh.section() << "." << dfh.counter() << "\n";

        if (!comment().empty()) {
          DocFormatHelper::wrapAndPrintText(os,
                                            comment(),
                                            dfh.startColumn2(),
                                            dfh.commentWidth());
        }
        os << "\n";
      }
    }
  }
void edm::IfExistsDescription::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) [private, virtual]

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 155 of file IfExistsDescription.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::indentation(), edm::DocFormatHelper::init(), node_left_, node_right_, edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::OTHER, edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), edm::DocFormatHelper::setCounter(), edm::DocFormatHelper::setIndentation(), edm::DocFormatHelper::setParent(), edm::DocFormatHelper::setPass(), edm::DocFormatHelper::setSection(), AlCaHLTBitMon_QueryRunRegistry::string, and pat::TOP.

                                             {

    int indentation = dfh.indentation();
    if (dfh.parent() != DocFormatHelper::TOP) {
      indentation -= DocFormatHelper::offsetSectionContent();
    }

    std::stringstream ss;
    ss << dfh.section() << "." << dfh.counter();
    std::string newSection = ss.str();

    printSpaces(os, indentation);
    os << "Section " << newSection;
    if (optional) os << " optional";
    os << " IfExists pair description:\n";
    printSpaces(os, indentation);
    if (optional) {
      os << "If the first parameter exists, then the second is allowed to exist\n";
    }
    else {
      os << "If the first parameter exists, then the second is required to exist\n";
    }
    if (!dfh.brief()) os << "\n";

    DocFormatHelper new_dfh(dfh);
    new_dfh.init();
    new_dfh.setSection(newSection);
    new_dfh.setIndentation(indentation + DocFormatHelper::offsetSectionContent());
    new_dfh.setParent(DocFormatHelper::OTHER);

    node_left_->print(os, false, true, new_dfh);
    node_right_->print(os, false, true, new_dfh);

    new_dfh.setPass(1);
    new_dfh.setCounter(0);

    node_left_->print(os, false, true, new_dfh);
    node_right_->print(os, false, true, new_dfh);

    new_dfh.setPass(2);
    new_dfh.setCounter(0);

    node_left_->printNestedContent(os, false, new_dfh);
    node_right_->printNestedContent(os, false , new_dfh);
  }
void edm::IfExistsDescription::throwIfDuplicateLabels ( std::set< std::string > const &  labelsLeft,
std::set< std::string > const &  labelsRight 
) const [private]

Definition at line 228 of file IfExistsDescription.cc.

References Exception, and edm::errors::LogicError.

Referenced by checkAndGetLabelsAndTypes_().

                                                                     {

    std::set<std::string> duplicateLabels;
    std::insert_iterator<std::set<std::string> > insertIter(duplicateLabels, duplicateLabels.begin());
    std::set_intersection(labelsLeft.begin(), labelsLeft.end(),
                          labelsRight.begin(), labelsRight.end(),
                          insertIter);
    if (!duplicateLabels.empty()) {
      std::stringstream ss;
      for (std::set<std::string>::const_iterator iter = duplicateLabels.begin(),
                                                 iEnd = duplicateLabels.end();
           iter != iEnd;
           ++iter) {
        ss << " \"" << *iter <<  "\"\n";
      }
      throw edm::Exception(errors::LogicError)
        << "Labels used in a node of a ParameterSetDescription\n"
        << "\"ifExists\" expression must be not be the same as labels used\n"
        << "in other nodes of the expression.  The following duplicate\n"
        << "labels were detected:\n"
        << ss.str()
        << "\n";
    }
  }
void edm::IfExistsDescription::throwIfDuplicateTypes ( std::set< ParameterTypes > const &  types1,
std::set< ParameterTypes > const &  types2 
) const [private]

Definition at line 256 of file IfExistsDescription.cc.

References Exception, edm::errors::LogicError, and edm::parameterTypeEnumToString().

Referenced by checkAndGetLabelsAndTypes_().

  {
    if (!types1.empty()) {
      std::set<ParameterTypes> duplicateTypes;
      std::insert_iterator<std::set<ParameterTypes> > insertIter(duplicateTypes, duplicateTypes.begin());
      std::set_intersection(types1.begin(), types1.end(),
                            types2.begin(), types2.end(),
                            insertIter);
      if (!duplicateTypes.empty()) {
        std::stringstream ss;
        for (std::set<ParameterTypes>::const_iterator iter = duplicateTypes.begin(),
                                                      iEnd = duplicateTypes.end();
             iter != iEnd;
             ++iter) {
          ss << " \"" << parameterTypeEnumToString(*iter) <<  "\"\n";
        }
        throw edm::Exception(errors::LogicError)
          << "Types used for wildcards in a node of a ParameterSetDescription\n"
          << "\"ifExists\" expression must be different from types used for other parameters\n"
          << "in other nodes.  The following duplicate types were detected:\n"
          << ss.str()
          << "\n";
      }
    }
  }
void edm::IfExistsDescription::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 73 of file IfExistsDescription.cc.

References node_left_, and node_right_.

                                 {

    bool leftExists = node_left_->exists(pset);
    bool rightExists = node_right_->exists(pset);

    if (!leftExists && !rightExists) {
      return;
    }
    else if (leftExists && rightExists) {
      node_left_->validate(pset, validatedLabels, false);
      node_right_->validate(pset, validatedLabels, false);
    }
    else if (leftExists && !rightExists) {
      node_left_->validate(pset, validatedLabels, false);
      if (!optional) node_right_->validate(pset, validatedLabels, false);
    }
    else if (!leftExists && rightExists) {
      node_left_->validate(pset, validatedLabels, false);
      node_right_->validate(pset, validatedLabels, false);
    }
  }
void edm::IfExistsDescription::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 99 of file IfExistsDescription.cc.

References node_left_, and node_right_.

                                         {
    node_left_->writeCfi(os, startWithComma, indentation, wroteSomething);
    node_right_->writeCfi(os, startWithComma, indentation, wroteSomething);
  }

Member Data Documentation