ParameterDescriptionBase

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109

#ifndef FWCore_ParameterSet_ParameterDescriptionBase_h
#define FWCore_ParameterSet_ParameterDescriptionBase_h
// -*- C++ -*-
//
// Package:     ParameterSet
// Class  :     ParameterDescriptionBase
//
/**\class ParameterDescriptionBase ParameterDescriptionBase.h FWCore/ParameterSet/interface/ParameterDescriptionBase.h

 Description: Base class for a description of one parameter in a ParameterSet

 Usage:
    <usage>

*/
//
// Original Author:  Chris Jones
//         Created:  Thu Aug  2 15:33:46 EDT 2007
//

#include "FWCore/ParameterSet/interface/ParameterDescriptionNode.h"

#include <string>
#include <set>
#include <iosfwd>

namespace edm {

  class ParameterSetDescription;
  class DocFormatHelper;

  class ParameterDescriptionBase : public ParameterDescriptionNode {
  public:
    ~ParameterDescriptionBase() override;

    std::string const& label() const { return label_; }
    ParameterTypes type() const { return type_; }
    bool isTracked() const { return isTracked_; }
    bool hasDefault() const { return hasDefault_; }

    virtual ParameterSetDescription const* parameterSetDescription() const { return nullptr; }
    virtual ParameterSetDescription* parameterSetDescription() { return nullptr; }

  protected:
    void throwParameterWrongTrackiness() const;
    void throwParameterWrongType() const;
    void throwMissingRequiredNoDefault() const;

    ParameterDescriptionBase(
        std::string const& iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const& iComment);

    ParameterDescriptionBase(
        char const* iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const& iComment);

  private:
    void checkAndGetLabelsAndTypes_(std::set<std::string>& usedLabels,
                                    std::set<ParameterTypes>& parameterTypes,
                                    std::set<ParameterTypes>& wildcardTypes) const override;

    void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, Modifier modifier) const override;

    void writeCfi_(std::ostream& os,
                   Modifier modifier,
                   bool& startWithComma,
                   int indentation,
                   CfiOptions&,
                   bool& wroteSomething) const override;

    void writeLabelValueCfi(std::ostream& os,
                            bool optional,
                            bool& startWithComma,
                            int indentation,
                            CfiOptions&,
                            bool& wroteSomething) const;

    void writeFullCfi(std::ostream& os,
                      Modifier modifier,
                      bool& startWithComma,
                      int indentation,
                      CfiOptions&,
                      bool& wroteSomething) const;

    bool partiallyExists_(ParameterSet const& pset) const override;

    int howManyXORSubNodesExist_(ParameterSet const& pset) const override;

    virtual void writeCfi_(std::ostream& os, int indentation, CfiOptions&) const = 0;

    virtual void writeDoc_(std::ostream& os, int indentation) const = 0;

    void print_(std::ostream& os, Modifier modifier, bool writeToCfi, DocFormatHelper& dfh) const override;

    virtual void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const;

    void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const override;

    using ParameterDescriptionNode::exists_;
    virtual bool exists_(ParameterSet const& pset, bool isTracked) const = 0;

    virtual void insertDefault_(ParameterSet& pset) const = 0;

    std::string label_;
    ParameterTypes type_;
    bool isTracked_;
    bool hasDefault_;
  };
}  // namespace edm
#endif