Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:47:39

0001 #ifndef FWCore_ParameterSet_ConfigurationDescriptions_h
0002 #define FWCore_ParameterSet_ConfigurationDescriptions_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     ParameterSet
0006 // Class  :     ConfigurationDescriptions
0007 //
0008 /**\class ConfigurationDescriptions ConfigurationDescriptions.h FWCore/ParameterSet/interface/ConfigurationDescriptions.h
0009 
0010  Used to hold ParameterSetDescriptions corresponding to labels
0011 
0012 */
0013 //
0014 // Original Author:  W. David Dagenhart
0015 //         Created:  17 December 2008
0016 //
0017 
0018 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0019 
0020 #include <vector>
0021 #include <set>
0022 #include <string>
0023 #include <utility>
0024 #include <iosfwd>
0025 
0026 namespace edm {
0027 
0028   class ConfigurationDescriptions {
0029   public:
0030     typedef std::vector<std::pair<std::string, ParameterSetDescription> >::iterator iterator;
0031 
0032     //NOTE: This does not take ownership of the PreValidatorBase instance so
0033     // this instance must remain valid for as long as the ConfigurationDescriptions
0034     // is being modified
0035     ConfigurationDescriptions(std::string const& baseType, std::string const& pluginName);
0036 
0037     ~ConfigurationDescriptions();
0038 
0039     // ---------------------------------------------------------
0040     // These functions are used by module developers to create
0041     // a description for a module.
0042     // ---------------------------------------------------------
0043 
0044     std::string const& comment() const { return comment_; }
0045     void setComment(std::string const& value);
0046     void setComment(char const* value);
0047 
0048     void add(std::string const& label, ParameterSetDescription const& psetDescription);
0049     void add(char const* label, ParameterSetDescription const& psetDescription);
0050     void addWithDefaultLabel(ParameterSetDescription const& psetDescription);
0051 
0052     void addDefault(ParameterSetDescription const& psetDescription);
0053 
0054     ///Returns 0 if no default has been assigned
0055     ParameterSetDescription* defaultDescription();
0056     iterator begin();
0057     iterator end();
0058 
0059     // ---------------------------------------------------------
0060     // These functions use the information in the descriptions
0061     // ---------------------------------------------------------
0062 
0063     void validate(ParameterSet& pset, std::string const& moduleLabel) const;
0064 
0065     void writeCfis(std::set<std::string>& usedCfiFileNames) const;
0066 
0067     void print(std::ostream& os,
0068                std::string const& moduleLabel,
0069                bool brief,
0070                bool printOnlyLabels,
0071                size_t lineWidth,
0072                int indentation,
0073                int iPlugin) const;
0074 
0075     // ---------------------------------------------------------
0076 
0077   private:
0078     class DescriptionCounter {
0079     public:
0080       int iPlugin;
0081       int iSelectedModule;
0082       int iModule;
0083     };
0084 
0085     static void writeCfiForLabel(std::pair<std::string, ParameterSetDescription> const& labelAndDesc,
0086                                  std::string const& baseType,
0087                                  std::string const& pluginName,
0088                                  std::set<std::string>& usedCfiFileNames);
0089 
0090     void printForLabel(std::pair<std::string, ParameterSetDescription> const& labelAndDesc,
0091                        std::ostream& os,
0092                        std::string const& moduleLabel,
0093                        bool brief,
0094                        bool printOnlyLabels,
0095                        size_t lineWidth,
0096                        int indentationn,
0097                        DescriptionCounter& counter) const;
0098 
0099     void printForLabel(std::ostream& os,
0100                        std::string const& label,
0101                        ParameterSetDescription const& description,
0102                        std::string const& moduleLabel,
0103                        bool brief,
0104                        bool printOnlyLabels,
0105                        size_t lineWidth,
0106                        int indentationn,
0107                        DescriptionCounter& counter) const;
0108 
0109     std::string baseType_;
0110     std::string pluginName_;
0111 
0112     std::vector<std::pair<std::string, ParameterSetDescription> > descriptions_;
0113 
0114     ParameterSetDescription defaultDesc_;
0115 
0116     std::string comment_;
0117     bool defaultDescDefined_;
0118   };
0119 }  // namespace edm
0120 
0121 #endif