Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:28:50

0001 
0002 #ifndef FWCore_ParameterSet_AllowedLabelsDescription_h
0003 #define FWCore_ParameterSet_AllowedLabelsDescription_h
0004 
0005 #include "FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h"
0006 #include "FWCore/ParameterSet/interface/ParameterDescriptionNode.h"
0007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0008 #include "FWCore/ParameterSet/interface/ParameterSetDescriptionTraits.h"
0009 #include "FWCore/Utilities/interface/value_ptr.h"
0010 
0011 #include <string>
0012 #include <set>
0013 #include <vector>
0014 #include <iosfwd>
0015 
0016 namespace edm {
0017 
0018   class VParameterSetEntry;
0019   class ParameterSetDescription;
0020   class DocFormatHelper;
0021 
0022   template <class T>
0023   class AllowedLabelsDescription : public AllowedLabelsDescriptionBase {
0024   public:
0025     AllowedLabelsDescription(std::string const& label, bool isTracked)
0026         : AllowedLabelsDescriptionBase(label, ParameterTypeToEnum::toEnum<T>(), isTracked) {}
0027 
0028     AllowedLabelsDescription(char const* label, bool isTracked)
0029         : AllowedLabelsDescriptionBase(label, ParameterTypeToEnum::toEnum<T>(), isTracked) {}
0030 
0031     ~AllowedLabelsDescription() override {}
0032 
0033     ParameterDescriptionNode* clone() const override { return new AllowedLabelsDescription(*this); }
0034 
0035   private:
0036     void validateAllowedLabel_(std::string const& allowedLabel,
0037                                ParameterSet& pset,
0038                                std::set<std::string>& validatedLabels) const override {
0039       if (pset.existsAs<T>(allowedLabel, isTracked())) {
0040         validatedLabels.insert(allowedLabel);
0041       }
0042     }
0043   };
0044 
0045   template <>
0046   class AllowedLabelsDescription<ParameterSetDescription> : public AllowedLabelsDescriptionBase {
0047   public:
0048     AllowedLabelsDescription(std::string const& label, bool isTracked);
0049 
0050     AllowedLabelsDescription(char const* label, bool isTracked);
0051 
0052     AllowedLabelsDescription(std::string const& label, ParameterSetDescription const& value, bool isTracked);
0053 
0054     AllowedLabelsDescription(char const* label, ParameterSetDescription const& value, bool isTracked);
0055 
0056     ~AllowedLabelsDescription() override;
0057 
0058     ParameterDescriptionNode* clone() const override;
0059 
0060   private:
0061     void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& helper) const override;
0062 
0063     void validateAllowedLabel_(std::string const& allowedLabel,
0064                                ParameterSet& pset,
0065                                std::set<std::string>& validatedLabels) const override;
0066 
0067     value_ptr<ParameterSetDescription> psetDesc_;
0068   };
0069 
0070   template <>
0071   class AllowedLabelsDescription<std::vector<ParameterSet> > : public AllowedLabelsDescriptionBase {
0072   public:
0073     AllowedLabelsDescription(std::string const& label, bool isTracked);
0074 
0075     AllowedLabelsDescription(char const* label, bool isTracked);
0076 
0077     AllowedLabelsDescription(std::string const& label, ParameterSetDescription const& value, bool isTracked);
0078 
0079     AllowedLabelsDescription(char const* label, ParameterSetDescription const& value, bool isTracked);
0080 
0081     ~AllowedLabelsDescription() override;
0082 
0083     ParameterDescriptionNode* clone() const override;
0084 
0085   private:
0086     void printNestedContent_(std::ostream& os, bool optional, DocFormatHelper& helper) const override;
0087 
0088     void validateAllowedLabel_(std::string const& allowedLabel,
0089                                ParameterSet& pset,
0090                                std::set<std::string>& validatedLabels) const override;
0091 
0092     value_ptr<ParameterSetDescription> psetDesc_;
0093   };
0094 }  // namespace edm
0095 #endif