CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

edm::ParameterDescriptionBase Class Reference

#include <ParameterDescriptionBase.h>

Inheritance diagram for edm::ParameterDescriptionBase:
edm::ParameterDescriptionNode edm::ParameterDescription< T > edm::ParameterDescription< ParameterSetDescription > edm::ParameterDescription< std::vector< ParameterSet > >

List of all members.

Public Member Functions

bool hasDefault () const
bool isTracked () const
std::string const & label () const
virtual ParameterSetDescriptionparameterSetDescription ()
virtual
ParameterSetDescription const * 
parameterSetDescription () const
ParameterTypes type () const
virtual ~ParameterDescriptionBase ()

Protected Member Functions

 ParameterDescriptionBase (std::string const &iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)
 ParameterDescriptionBase (char const *iLabel, ParameterTypes iType, bool isTracked, bool hasDefault)
void throwMissingRequiredNoDefault () const
void throwParameterWrongTrackiness () const
void throwParameterWrongType () const

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, bool isTracked) const =0
virtual int howManyXORSubNodesExist_ (ParameterSet const &pset) const
virtual void insertDefault_ (ParameterSet &pset) const =0
virtual bool partiallyExists_ (ParameterSet const &pset) const
virtual void print_ (std::ostream &os, bool optional, bool writeToCfi, DocFormatHelper &dfh)
virtual void printDefault_ (std::ostream &os, bool writeToCfi, DocFormatHelper &dfh)
virtual void printNestedContent_ (std::ostream &os, bool optional, DocFormatHelper &dfh)
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
virtual void writeCfi_ (std::ostream &os, int indentation) const =0
virtual void writeDoc_ (std::ostream &os, int indentation) const =0

Private Attributes

bool hasDefault_
bool isTracked_
std::string label_
ParameterTypes type_

Detailed Description

Definition at line 33 of file ParameterDescriptionBase.h.


Constructor & Destructor Documentation

ParameterDescriptionBase::~ParameterDescriptionBase ( ) [virtual]

Definition at line 55 of file ParameterDescriptionBase.cc.

{ }
ParameterDescriptionBase::ParameterDescriptionBase ( std::string const &  iLabel,
ParameterTypes  iType,
bool  isTracked,
bool  hasDefault 
) [protected]

Definition at line 23 of file ParameterDescriptionBase.cc.

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

    :label_(iLabel),
     type_(iType),
     isTracked_(isTracked),
     hasDefault_(hasDefault)
  {
    if(label_.empty()) {
      throw edm::Exception(errors::LogicError)
        << "Empty string used as a label for a parameter.  This is\n"
           "not allowed.\n";
    }
  }
ParameterDescriptionBase::ParameterDescriptionBase ( char const *  iLabel,
ParameterTypes  iType,
bool  isTracked,
bool  hasDefault 
) [protected]

Definition at line 39 of file ParameterDescriptionBase.cc.

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

    :label_(iLabel),
     type_(iType),
     isTracked_(isTracked),
     hasDefault_(hasDefault)
  {
    if (label_.empty()) {
      throw edm::Exception(errors::LogicError)
        << "Empty string used as a label for a parameter.  This is\n"
           "not allowed.\n";
    }
  }

Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 99 of file ParameterDescriptionBase.cc.

References label(), and type().

                                                                           {
    usedLabels.insert(label());
    parameterTypes.insert(type());
  }
virtual bool edm::ParameterDescriptionBase::exists_ ( ParameterSet const &  pset,
bool  isTracked 
) const [private, pure virtual]
bool edm::ParameterDescriptionBase::hasDefault ( ) const [inline]
int ParameterDescriptionBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 290 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

                                                           {
    return exists(pset) ? 1 : 0; 
  }
virtual void edm::ParameterDescriptionBase::insertDefault_ ( ParameterSet pset) const [private, pure virtual]
bool edm::ParameterDescriptionBase::isTracked ( ) const [inline]
std::string const& edm::ParameterDescriptionBase::label ( ) const [inline]
virtual ParameterSetDescription const* edm::ParameterDescriptionBase::parameterSetDescription ( ) const [inline, virtual]
virtual ParameterSetDescription* edm::ParameterDescriptionBase::parameterSetDescription ( ) [inline, virtual]
bool ParameterDescriptionBase::partiallyExists_ ( ParameterSet const &  pset) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 284 of file ParameterDescriptionBase.cc.

References edm::ParameterDescriptionNode::exists().

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 162 of file ParameterDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::column1(), edm::DocFormatHelper::column2(), edm::DocFormatHelper::column3(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), relativeConstraints::empty, edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), isTracked(), label(), edm::parameterTypeEnumToString(), edm::DocFormatHelper::pass(), printDefault_(), edm::DocFormatHelper::setAtLeast1(), edm::DocFormatHelper::setAtLeast2(), edm::DocFormatHelper::setAtLeast3(), findQualityFiles::size, edm::DocFormatHelper::startColumn2(), type(), and edm::DocFormatHelper::wrapAndPrintText().

  {
    if (dfh.pass() == 0) {
      dfh.setAtLeast1(label().size());
      if (isTracked()) {
        dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
      }
      else {
        dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
      }
      if (optional) {
        dfh.setAtLeast3(8U);
      }
    }
    else {

      if (dfh.brief()) {
        std::ios::fmtflags oldFlags = os.flags();

        dfh.indent(os);
        os << std::left << std::setw(dfh.column1()) << label() << " ";

        if (isTracked()) {
          os << std::setw(dfh.column2()) << parameterTypeEnumToString(type());
        }
        else {
          std::stringstream ss;
          ss << "untracked ";
          ss << parameterTypeEnumToString(type());
          os << std::setw(dfh.column2()) << ss.str();
        }
        os << " ";

        os << std::setw(dfh.column3());
        if (optional) {
          os << "optional";
        }
        else {
          os << "";
        }
        os << " ";
        os.flags(oldFlags);
        printDefault_(os, writeToCfi, dfh);
      }
      // not brief
      else {

        dfh.indent(os);
        os << label() << "\n";

        dfh.indent2(os);
        os << "type: ";
        if (!isTracked()) os << "untracked ";
        
        os << parameterTypeEnumToString(type()) << " ";

        if (optional)  os << "optional";
        os << "\n";

        dfh.indent2(os);
        printDefault_(os, writeToCfi, dfh);

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

Reimplemented in edm::ParameterDescription< ParameterSetDescription >, and edm::ParameterDescription< std::vector< ParameterSet > >.

Definition at line 240 of file ParameterDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), hasDefault(), edm::ParameterDescriptionNode::hasNestedContent(), edm::DocFormatHelper::indentation(), edm::DocFormatHelper::section(), edm::DocFormatHelper::startColumn2(), and writeDoc_().

Referenced by print_().

                                         {
    if (!dfh.brief()) os << "default: ";
    if (writeToCfi && hasDefault()) {
      if (hasNestedContent()) {
        os << "see Section " << dfh.section()
           << "." << dfh.counter();
      }
      else {
        if (dfh.brief()) {
          writeDoc_(os, dfh.indentation());
        }
        else {
          writeDoc_(os, dfh.startColumn2());
        }
      }
    }
    else {
      os << "none (do not write to cfi)";
    }
    os << "\n";
  }
void ParameterDescriptionBase::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) [private, virtual]

Reimplemented from edm::ParameterDescriptionNode.

Reimplemented in edm::ParameterDescription< ParameterSetDescription >, and edm::ParameterDescription< std::vector< ParameterSet > >.

Definition at line 266 of file ParameterDescriptionBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::counter(), edm::DocFormatHelper::indentation(), label(), edm::DocFormatHelper::offsetSectionContent(), edm::DocFormatHelper::parent(), edm::ParameterDescriptionNode::printSpaces(), edm::DocFormatHelper::section(), pat::TOP, and writeDoc_().

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

    printSpaces(os, indentation);
    os << "Section " << dfh.section() << "." << dfh.counter()
       << " " << label() << " default contents: ";
    writeDoc_(os, indentation + 2);
    os << "\n";
    if (!dfh.brief()) os << "\n";
  }
void ParameterDescriptionBase::throwMissingRequiredNoDefault ( ) const [protected]

Definition at line 84 of file ParameterDescriptionBase.cc.

References edm::errors::Configuration, Exception, isTracked(), label(), edm::parameterTypeEnumToString(), and type().

Referenced by validate_().

                                                                {

    std::string tr("untracked");
    if (isTracked()) tr = "tracked";

    throw edm::Exception(errors::Configuration)
      << "Missing required parameter.  It should have label \""
      << label() << "\" and have type \""
      << tr << " " << parameterTypeEnumToString(type()) << "\".\n"
      << "The description has no default.  The parameter must be defined "
         "in the configuration\n";
  }
void ParameterDescriptionBase::throwParameterWrongTrackiness ( ) const [protected]

Definition at line 58 of file ParameterDescriptionBase.cc.

References edm::errors::Configuration, Exception, isTracked(), label(), edm::parameterTypeEnumToString(), and type().

Referenced by validate_(), and edm::ParameterDescription< ParameterSetDescription >::validate_().

                                                                {
    std::string tr("a tracked");
    std::string shouldBe("untracked");
    if (isTracked()) {
      tr = "an untracked";
      shouldBe = "tracked";
    }

    throw edm::Exception(errors::Configuration)
      << "In the configuration, parameter \"" << label() << "\" is defined "
      "as " << tr << " " << parameterTypeEnumToString(type()) << ".\n"
      << "It should be " << shouldBe << ".\n";
  }
void ParameterDescriptionBase::throwParameterWrongType ( ) const [protected]

Definition at line 73 of file ParameterDescriptionBase.cc.

References edm::errors::Configuration, Exception, isTracked(), label(), edm::parameterTypeEnumToString(), and type().

Referenced by validate_(), and edm::ParameterDescription< ParameterSetDescription >::validate_().

                                                          {
    std::string tr("an untracked");
    if (isTracked()) tr = "a tracked";

    throw edm::Exception(errors::Configuration)
      << "Parameter \"" << label() << "\" should be defined "
      "as " << tr << " " << parameterTypeEnumToString(type()) << ".\n"
      << "The type in the configuration is incorrect.\n";
  }
ParameterTypes edm::ParameterDescriptionBase::type ( ) const [inline]
void ParameterDescriptionBase::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const [private, virtual]
virtual void edm::ParameterDescriptionBase::writeCfi_ ( std::ostream &  os,
int  indentation 
) const [private, pure virtual]
void ParameterDescriptionBase::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 137 of file ParameterDescriptionBase.cc.

References hasDefault(), isTracked(), label(), edm::parameterTypeEnumToString(), edm::ParameterDescriptionNode::printSpaces(), and type().

                                        {

    if (!hasDefault()) return;

    wroteSomething = true;
    if (startWithComma) os << ",";
    startWithComma = true;

    os << "\n";
    printSpaces(os, indentation);

    os << label()
       << " = cms.";
    if (!isTracked()) os << "untracked.";
    os << parameterTypeEnumToString(type())
       << "(";
    writeCfi_(os, indentation);
    os << ")";
  }
virtual void edm::ParameterDescriptionBase::writeDoc_ ( std::ostream &  os,
int  indentation 
) const [private, pure virtual]

Member Data Documentation

Definition at line 106 of file ParameterDescriptionBase.h.

Referenced by hasDefault().

Definition at line 105 of file ParameterDescriptionBase.h.

Referenced by isTracked().

Definition at line 103 of file ParameterDescriptionBase.h.

Referenced by label(), and ParameterDescriptionBase().

Definition at line 104 of file ParameterDescriptionBase.h.

Referenced by type().