CMS 3D CMS Logo

Public Types | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes

edm::ParameterSwitch< T > Class Template Reference

#include <ParameterSwitch.h>

Inheritance diagram for edm::ParameterSwitch< T >:
edm::ParameterSwitchBase edm::ParameterDescriptionNode

List of all members.

Public Types

typedef std::map< T,
edm::value_ptr
< ParameterDescriptionNode > > 
CaseMap
typedef std::map< T,
edm::value_ptr
< ParameterDescriptionNode >
>::const_iterator 
CaseMapConstIter

Public Member Functions

virtual ParameterDescriptionNodeclone () const
 ParameterSwitch (ParameterDescription< T > const &switchParameter, std::auto_ptr< ParameterDescriptionCases< T > > cases)

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 void print_ (std::ostream &os, bool optional, 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

Static Private Member Functions

static void checkCaseLabels (std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &thePair, std::set< std::string > &labels, std::set< ParameterTypes > &parameterTypes, std::set< ParameterTypes > &wildcardTypes)

Private Attributes

CaseMap cases_
ParameterDescription< Tswitch_

Detailed Description

template<class T>
class edm::ParameterSwitch< T >

Definition at line 27 of file ParameterSwitch.h.


Member Typedef Documentation

template<class T >
typedef std::map<T, edm::value_ptr<ParameterDescriptionNode> > edm::ParameterSwitch< T >::CaseMap

Definition at line 30 of file ParameterSwitch.h.

template<class T >
typedef std::map<T, edm::value_ptr<ParameterDescriptionNode> >::const_iterator edm::ParameterSwitch< T >::CaseMapConstIter

Definition at line 31 of file ParameterSwitch.h.


Constructor & Destructor Documentation

template<class T >
edm::ParameterSwitch< T >::ParameterSwitch ( ParameterDescription< T > const &  switchParameter,
std::auto_ptr< ParameterDescriptionCases< T > >  cases 
) [inline]

Definition at line 33 of file ParameterSwitch.h.

References edm::ParameterDescriptionBase::label(), and edm::ParameterSwitchBase::throwDuplicateCaseValues().

Referenced by edm::ParameterSwitch< T >::clone().

                                                                      :
      switch_(switchParameter),
      cases_(*cases->caseMap())
    {
      if (cases->duplicateCaseValues()) {
        throwDuplicateCaseValues(switchParameter.label());
      }
    }

Member Function Documentation

template<class T >
virtual void edm::ParameterSwitch< T >::checkAndGetLabelsAndTypes_ ( std::set< std::string > &  usedLabels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) const [inline, private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 49 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::cases_, edm::ParameterSwitch< T >::checkCaseLabels(), edm::for_all(), edm::ParameterSwitchBase::insertAndCheckLabels(), edm::ParameterSwitchBase::insertAndCheckTypes(), edm::ParameterSwitch< T >::switch_, and edm::ParameterSwitchBase::throwNoCaseForDefault().

                                                                                          {

      std::set<std::string> caseLabels;
      std::set<ParameterTypes> caseParameterTypes;
      std::set<ParameterTypes> caseWildcardTypes;
      for_all(cases_, boost::bind(&ParameterSwitch::checkCaseLabels,
                                  _1,
                                  boost::ref(caseLabels),
                                  boost::ref(caseParameterTypes),
                                  boost::ref(caseWildcardTypes)));

      insertAndCheckLabels(switch_.label(),
                           usedLabels,
                           caseLabels);

      insertAndCheckTypes(switch_.type(),
                          caseParameterTypes,
                          caseWildcardTypes,
                          parameterTypes,
                          wildcardTypes);

      if (cases_.find(switch_.getDefaultValue()) == cases_.end()) {
        throwNoCaseForDefault(switch_.label());
      }
    }
template<class T >
static void edm::ParameterSwitch< T >::checkCaseLabels ( std::pair< T, edm::value_ptr< ParameterDescriptionNode > > const &  thePair,
std::set< std::string > &  labels,
std::set< ParameterTypes > &  parameterTypes,
std::set< ParameterTypes > &  wildcardTypes 
) [inline, static, private]

Definition at line 175 of file ParameterSwitch.h.

Referenced by edm::ParameterSwitch< T >::checkAndGetLabelsAndTypes_().

                                                                        {
      thePair.second->checkAndGetLabelsAndTypes(labels, parameterTypes, wildcardTypes);
    }
template<class T >
virtual ParameterDescriptionNode* edm::ParameterSwitch< T >::clone ( void  ) const [inline, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 43 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::ParameterSwitch().

                                                    {
      return new ParameterSwitch(*this);
    }
template<class T >
virtual bool edm::ParameterSwitch< T >::exists_ ( ParameterSet const &  pset) const [inline, private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 173 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::switch_.

{ return switch_.exists(pset); }
template<class T >
virtual void edm::ParameterSwitch< T >::print_ ( std::ostream &  os,
bool  optional,
bool  writeToCfi,
DocFormatHelper dfh 
) [inline, private, virtual]

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 126 of file ParameterSwitch.h.

References edm::parameterTypeEnumToString(), edm::ParameterSwitchBase::printBase(), and edm::ParameterSwitch< T >::switch_.

                                               {
      printBase(os, optional, writeToCfi, dfh, switch_.label(), switch_.isTracked(), parameterTypeEnumToString(switch_.type()));
    }
template<class T >
virtual void edm::ParameterSwitch< T >::printNestedContent_ ( std::ostream &  os,
bool  optional,
DocFormatHelper dfh 
) [inline, private, virtual]

Reimplemented from edm::ParameterDescriptionNode.

Definition at line 133 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::cases_, edm::for_all(), edm::DocFormatHelper::indent(), edm::ParameterSwitchBase::printNestedContentBase(), edm::DocFormatHelper::setCounter(), edm::DocFormatHelper::setPass(), and edm::ParameterSwitch< T >::switch_.

                                                            {

      DocFormatHelper new_dfh(dfh);
      printNestedContentBase(os, dfh, new_dfh, switch_.label());

      switch_.print(os, optional, true, new_dfh);
      for_all(cases_, boost::bind(&ParameterSwitchBase::printCaseT<T>,
                                  _1,
                                  boost::ref(os),
                                  optional,
                                  boost::ref(new_dfh),
                                  boost::cref(switch_.label())));

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

      new_dfh.indent(os);
      os << "switch:\n";
      switch_.print(os, optional, true, new_dfh);
      for_all(cases_, boost::bind(&ParameterSwitchBase::printCaseT<T>,
                                  _1,
                                  boost::ref(os),
                                  optional,
                                  boost::ref(new_dfh),
                                  boost::cref(switch_.label())));

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

      switch_.printNestedContent(os, optional, new_dfh);
      for_all(cases_, boost::bind(&ParameterSwitchBase::printCaseT<T>,
                                  _1,
                                  boost::ref(os),
                                  optional,
                                  boost::ref(new_dfh),
                                  boost::cref(switch_.label())));
    }
template<class T >
virtual void edm::ParameterSwitch< T >::validate_ ( ParameterSet pset,
std::set< std::string > &  validatedLabels,
bool  optional 
) const [inline, private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 77 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::cases_, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), edm::ParameterSwitch< T >::switch_, and edm::ParameterSwitchBase::throwNoCaseForSwitchValue().

                                                {

      switch_.validate(pset, validatedLabels, optional);
      if (switch_.exists(pset)) {
        T switchValue;   
        if (switch_.isTracked()) {
          switchValue = pset.getParameter<T>(switch_.label());
        }
        else {
          switchValue = pset.getUntrackedParameter<T>(switch_.label());
        }
        typename CaseMap::const_iterator selectedCase = cases_.find(switchValue);
        if (selectedCase != cases_.end()) {
          selectedCase->second->validate(pset, validatedLabels, false);
        }
        else {
          std::stringstream ss;
          ss << "The switch parameter with label \""
             << switch_.label()
             << "\" has been assigned an illegal value.\n"
             << "The value from the configuration is \""
             << switchValue
             << "\".\n"
             << "The allowed values are:\n";

          for (CaseMapConstIter iter = cases_.begin(), iEnd = cases_.end();
               iter != iEnd;
               ++iter) {
            ss << "  " << iter->first << "\n";
          }
          throwNoCaseForSwitchValue(ss.str());
        }
      }
    }
template<class T >
virtual void edm::ParameterSwitch< T >::writeCfi_ ( std::ostream &  os,
bool &  startWithComma,
int  indentation,
bool &  wroteSomething 
) const [inline, private, virtual]

Implements edm::ParameterDescriptionNode.

Definition at line 114 of file ParameterSwitch.h.

References edm::ParameterSwitch< T >::cases_, and edm::ParameterSwitch< T >::switch_.

                                                       {
      switch_.writeCfi(os, startWithComma, indentation, wroteSomething);

      typename CaseMap::const_iterator selectedCase = cases_.find(switch_.getDefaultValue());
      if (selectedCase != cases_.end()) {
        selectedCase->second->writeCfi(os, startWithComma, indentation, wroteSomething);
      }
    }

Member Data Documentation

template<class T >
CaseMap edm::ParameterSwitch< T >::cases_ [private]
template<class T >
ParameterDescription<T> edm::ParameterSwitch< T >::switch_ [private]