CMS 3D CMS Logo

/data/git/CMSSW_5_3_11_patch5/src/FWCore/ParameterSet/interface/AllowedLabelsDescription.h

Go to the documentation of this file.
00001 
00002 #ifndef FWCore_ParameterSet_AllowedLabelsDescription_h
00003 #define FWCore_ParameterSet_AllowedLabelsDescription_h
00004 
00005 #include "FWCore/ParameterSet/interface/AllowedLabelsDescriptionBase.h"
00006 #include "FWCore/ParameterSet/interface/ParameterDescriptionNode.h"
00007 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00008 #include "FWCore/Utilities/interface/value_ptr.h"
00009 
00010 #include <string>
00011 #include <set>
00012 #include <vector>
00013 #include <iosfwd>
00014 
00015 namespace edm {
00016 
00017   class VParameterSetEntry;
00018   class ParameterSetDescription;
00019   class DocFormatHelper;
00020 
00021   template<class T>
00022   class AllowedLabelsDescription : public AllowedLabelsDescriptionBase {
00023 
00024   public:
00025     AllowedLabelsDescription(std::string const& label,
00026                              bool isTracked) :
00027       AllowedLabelsDescriptionBase(label, ParameterTypeToEnum::toEnum<T>(), isTracked)
00028     {              
00029     }
00030 
00031     AllowedLabelsDescription(char const* label,
00032                              bool isTracked) :
00033       AllowedLabelsDescriptionBase(label, ParameterTypeToEnum::toEnum<T>(), isTracked)
00034     {
00035     }
00036 
00037     virtual ParameterDescriptionNode* clone() const {
00038       return new AllowedLabelsDescription(*this);
00039     }
00040 
00041   private:
00042 
00043     virtual void validateAllowedLabel_(std::string const& allowedLabel,
00044                                        ParameterSet & pset,
00045                                        std::set<std::string> & validatedLabels) const {
00046       if (pset.existsAs<T>(allowedLabel, isTracked())) {
00047         validatedLabels.insert(allowedLabel);
00048       }
00049     }
00050   };
00051 
00052   template<>
00053   class AllowedLabelsDescription<ParameterSetDescription> : public AllowedLabelsDescriptionBase {
00054 
00055   public:
00056     AllowedLabelsDescription(std::string const& label,
00057                              bool isTracked);
00058 
00059     AllowedLabelsDescription(char const* label,
00060                              bool isTracked);
00061 
00062     AllowedLabelsDescription(std::string const& label,
00063                              ParameterSetDescription const& value,
00064                              bool isTracked);
00065 
00066     AllowedLabelsDescription(char const* label,
00067                              ParameterSetDescription const& value,
00068                              bool isTracked);
00069 
00070     virtual ParameterDescriptionNode* clone() const;
00071 
00072   private:
00073 
00074     virtual void printNestedContent_(std::ostream & os,
00075                                      bool optional,
00076                                      DocFormatHelper & helper);
00077 
00078     virtual void validateAllowedLabel_(std::string const& allowedLabel,
00079                                        ParameterSet & pset,
00080                                        std::set<std::string> & validatedLabels) const;
00081 
00082     value_ptr<ParameterSetDescription> psetDesc_;
00083   };
00084 
00085   template<>
00086   class AllowedLabelsDescription<std::vector<ParameterSet> > : public AllowedLabelsDescriptionBase {
00087 
00088   public:
00089     AllowedLabelsDescription(std::string const& label,
00090                              bool isTracked);
00091 
00092     AllowedLabelsDescription(char const* label,
00093                              bool isTracked);
00094 
00095     AllowedLabelsDescription(std::string const& label,
00096                              ParameterSetDescription const& value,
00097                              bool isTracked);
00098 
00099     AllowedLabelsDescription(char const* label,
00100                              ParameterSetDescription const& value,
00101                              bool isTracked);
00102 
00103     virtual ParameterDescriptionNode* clone() const;
00104 
00105   private:
00106 
00107     virtual void printNestedContent_(std::ostream & os,
00108                                      bool optional,
00109                                      DocFormatHelper & helper);
00110 
00111     virtual void validateAllowedLabel_(std::string const& allowedLabel,
00112                                        ParameterSet & pset,
00113                                        std::set<std::string> & validatedLabels) const;
00114 
00115     value_ptr<ParameterSetDescription> psetDesc_;
00116   };
00117 }
00118 #endif