Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:03:19

0001 
0002 #ifndef FWCore_ParameterSet_ParameterDescriptionBase_h
0003 #define FWCore_ParameterSet_ParameterDescriptionBase_h
0004 // -*- C++ -*-
0005 //
0006 // Package:     ParameterSet
0007 // Class  :     ParameterDescriptionBase
0008 //
0009 /**\class ParameterDescriptionBase ParameterDescriptionBase.h FWCore/ParameterSet/interface/ParameterDescriptionBase.h
0010 
0011  Description: Base class for a description of one parameter in a ParameterSet
0012 
0013  Usage:
0014     <usage>
0015 
0016 */
0017 //
0018 // Original Author:  Chris Jones
0019 //         Created:  Thu Aug  2 15:33:46 EDT 2007
0020 //
0021 
0022 #include "FWCore/ParameterSet/interface/ParameterDescriptionNode.h"
0023 
0024 #include <string>
0025 #include <set>
0026 #include <iosfwd>
0027 
0028 namespace edm {
0029 
0030   class ParameterSetDescription;
0031   class DocFormatHelper;
0032 
0033   class ParameterDescriptionBase : public ParameterDescriptionNode {
0034   public:
0035     ~ParameterDescriptionBase() override;
0036 
0037     std::string const& label() const { return label_; }
0038     ParameterTypes type() const { return type_; }
0039     bool isTracked() const { return isTracked_; }
0040     bool hasDefault() const { return hasDefault_; }
0041 
0042     virtual ParameterSetDescription const* parameterSetDescription() const { return nullptr; }
0043     virtual ParameterSetDescription* parameterSetDescription() { return nullptr; }
0044 
0045   protected:
0046     void throwParameterWrongTrackiness() const;
0047     void throwParameterWrongType() const;
0048     void throwMissingRequiredNoDefault() const;
0049 
0050     ParameterDescriptionBase(
0051         std::string const& iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const& iComment);
0052 
0053     ParameterDescriptionBase(
0054         char const* iLabel, ParameterTypes iType, bool isTracked, bool hasDefault, Comment const& iComment);
0055 
0056   private:
0057     void checkAndGetLabelsAndTypes_(std::set<std::string>& usedLabels,
0058                                     std::set<ParameterTypes>& parameterTypes,
0059                                     std::set<ParameterTypes>& wildcardTypes) const override;
0060 
0061     void validate_(ParameterSet& pset, std::set<std::string>& validatedLabels, bool optional) const override;
0062 
0063     void writeCfi_(
0064         std::ostream& os, bool optional, bool& startWithComma, int indentation, bool& wroteSomething) const override;
0065 
0066     bool partiallyExists_(ParameterSet const& pset) const override;
0067 
0068     int howManyXORSubNodesExist_(ParameterSet const& pset) const override;
0069 
0070     virtual void writeCfi_(std::ostream& os, int indentation) const = 0;
0071 
0072     virtual void writeDoc_(std::ostream& os, int indentation) const = 0;
0073 
0074     void print_(std::ostream& os, bool optional, bool writeToCfi, DocFormatHelper& dfh) const override;
0075 
0076     virtual void printDefault_(std::ostream& os, bool writeToCfi, DocFormatHelper& dfh) const;
0077 
0078     void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& dfh) const override;
0079 
0080     using ParameterDescriptionNode::exists_;
0081     virtual bool exists_(ParameterSet const& pset, bool isTracked) const = 0;
0082 
0083     virtual void insertDefault_(ParameterSet& pset) const = 0;
0084 
0085     std::string label_;
0086     ParameterTypes type_;
0087     bool isTracked_;
0088     bool hasDefault_;
0089   };
0090 }  // namespace edm
0091 #endif