CMS 3D CMS Logo

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

edm::ParameterWildcardBase Class Reference

#include <ParameterWildcardBase.h>

Inheritance diagram for edm::ParameterWildcardBase:
edm::ParameterDescriptionNode edm::ParameterWildcard< T > edm::ParameterWildcard< ParameterSetDescription > edm::ParameterWildcard< std::vector< ParameterSet > >

List of all members.

Public Member Functions

WildcardValidationCriteria criteria () const
bool isTracked () const
ParameterTypes type () const
virtual ~ParameterWildcardBase ()

Protected Member Functions

 ParameterWildcardBase (ParameterTypes iType, bool isTracked, WildcardValidationCriteria criteria)
void throwIfInvalidPattern (char const *pattern) const
void throwIfInvalidPattern (std::string const &pattern) const
void validateMatchingNames (std::vector< std::string > const &matchingNames, std::set< std::string > &validatedLabels, bool optional) const

Private Member Functions

virtual void checkAndGetLabelsAndTypes_ (std::set< std::string > &usedLabels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes) const
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 writeCfi_ (std::ostream &os, bool &startWithComma, int indentation, bool &wroteSomething) const

Private Attributes

WildcardValidationCriteria criteria_
bool isTracked_
ParameterTypes type_

Detailed Description

Definition at line 24 of file ParameterWildcardBase.h.


Constructor & Destructor Documentation

edm::ParameterWildcardBase::~ParameterWildcardBase ( ) [virtual]

Definition at line 13 of file ParameterWildcardBase.cc.

{ }
edm::ParameterWildcardBase::ParameterWildcardBase ( ParameterTypes  iType,
bool  isTracked,
WildcardValidationCriteria  criteria 
) [protected]

Definition at line 15 of file ParameterWildcardBase.cc.


Member Function Documentation

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

Implements edm::ParameterDescriptionNode.

Definition at line 69 of file ParameterWildcardBase.cc.

References type().

                                                                          {
    wildcardTypes.insert(type());
  }
WildcardValidationCriteria edm::ParameterWildcardBase::criteria ( ) const [inline]
int edm::ParameterWildcardBase::howManyXORSubNodesExist_ ( ParameterSet const &  pset) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 183 of file ParameterWildcardBase.cc.

References edm::ParameterDescriptionNode::exists().

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

Implements edm::ParameterDescriptionNode.

Definition at line 177 of file ParameterWildcardBase.cc.

References edm::ParameterDescriptionNode::exists().

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

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 77 of file ParameterWildcardBase.cc.

References edm::DocFormatHelper::brief(), edm::DocFormatHelper::column1(), edm::DocFormatHelper::column2(), edm::DocFormatHelper::column3(), edm::ParameterDescriptionNode::comment(), edm::DocFormatHelper::commentWidth(), edm::DocFormatHelper::counter(), criteria(), relativeConstraints::empty, edm::ParameterDescriptionNode::hasNestedContent(), edm::DocFormatHelper::indent(), edm::DocFormatHelper::indent2(), isTracked(), edm::parameterTypeEnumToString(), edm::DocFormatHelper::pass(), edm::RequireAtLeastOne, edm::RequireExactlyOne, edm::RequireZeroOrMore, edm::DocFormatHelper::section(), 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(11U);
      if(isTracked()) {
        dfh.setAtLeast2(parameterTypeEnumToString(type()).size());
      } else {
        dfh.setAtLeast2(parameterTypeEnumToString(type()).size() + 10U);
      }
      dfh.setAtLeast3(8U);
    } else {

      if(dfh.brief()) {

        dfh.indent(os);
        std::ios::fmtflags oldFlags = os.flags();
        os << std::left << std::setw(dfh.column1()) << "wildcard: *" << " ";

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

        os << " ";
        os << std::setw(dfh.column3());
        if(optional) os << "optional";
        else os << "";

        if(criteria() == RequireZeroOrMore) {
          os << " (require zero or more)";
        } else if(criteria() == RequireAtLeastOne) {
          os << " (require at least one)";
        } else if(criteria() == RequireExactlyOne) {
          os << " (require exactly one)";
        }
        os << "\n";
        if(hasNestedContent()) {
          dfh.indent(os);
          os << "  (see Section " << dfh.section()
             << "." << dfh.counter() << ")\n";
        }
        os.flags(oldFlags);
      } else {
        // not brief

        dfh.indent(os);
        os << "labels must match this wildcard pattern: *\n";

        dfh.indent2(os);
        os << "type: ";
        if(isTracked()) {
          os << parameterTypeEnumToString(type());
        } else {
          os << "untracked " << parameterTypeEnumToString(type());
        }

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

        dfh.indent2(os);
        os << "criteria: ";
        if(criteria() == RequireZeroOrMore) os << "require zero or more";
        else if(criteria() == RequireAtLeastOne) os << "require at least one";
        else if(criteria() == RequireExactlyOne) os << "require exactly one";
        os << "\n";

        if(hasNestedContent()) {
          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::ParameterWildcardBase::throwIfInvalidPattern ( char const *  pattern) const [protected]
void edm::ParameterWildcardBase::throwIfInvalidPattern ( std::string const &  pattern) const [protected]

Definition at line 32 of file ParameterWildcardBase.cc.

References edm::errors::Configuration, Exception, edm::parameterTypeEnumToString(), AlCaHLTBitMon_QueryRunRegistry::string, and type().

                                                        {
    if(pattern != std::string("*")) {
      throw Exception(errors::Configuration)
        << "Currently, the only supported wildcard in ParameterSetDescriptions\n"
        << "is the single character \"*\".  The configuration contains a wildcard\n"
        << "with pattern \"" << pattern << "\" and type \"" << parameterTypeEnumToString(type()) << "\"\n"
        << "At some future date, globbing or regular expression support may be added\n"
        << "if there are any requests for it from users.\n";
    }
  }
ParameterTypes edm::ParameterWildcardBase::type ( ) const [inline]

Definition at line 29 of file ParameterWildcardBase.h.

References type_.

Referenced by checkAndGetLabelsAndTypes_(), print_(), throwIfInvalidPattern(), and validateMatchingNames().

{ return type_; }
void edm::ParameterWildcardBase::validateMatchingNames ( std::vector< std::string > const &  matchingNames,
std::set< std::string > &  validatedLabels,
bool  optional 
) const [protected]

Definition at line 45 of file ParameterWildcardBase.cc.

References edm::errors::Configuration, criteria_, Exception, edm::parameterTypeEnumToString(), edm::RequireAtLeastOne, edm::RequireExactlyOne, edm::RequireZeroOrMore, and type().

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

                                             {
    validatedLabels.insert(matchingNames.begin(), matchingNames.end());
    if(criteria_ == RequireZeroOrMore) return;
    if(criteria_ == RequireAtLeastOne && matchingNames.size() < 1U && !optional) {
      throw Exception(errors::Configuration)
        << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires "
        << "at least one match\n"
        << "and there are no parameters in the configuration matching\n"
        << "that type.\n";
    } else if(criteria_ == RequireExactlyOne) {
      if((matchingNames.size() < 1U && !optional) ||
           matchingNames.size() > 1U) {
        throw Exception(errors::Configuration)
          << "Parameter wildcard of type \"" << parameterTypeEnumToString(type()) << "\" requires\n"
          << "exactly one match and there are " << matchingNames.size() << " matching parameters\n"
          << "in the configuration.\n";
      }
    }
  }
void edm::ParameterWildcardBase::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const [private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 167 of file ParameterWildcardBase.cc.

                           {
    // Until we implement default labels and values there is nothing
    // to do here.
  }

Member Data Documentation

Definition at line 68 of file ParameterWildcardBase.h.

Referenced by criteria(), and validateMatchingNames().

Definition at line 67 of file ParameterWildcardBase.h.

Referenced by isTracked().

Definition at line 66 of file ParameterWildcardBase.h.

Referenced by type().