Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-02-27 07:19:50

0001 #ifndef DataFormats_Provenance_ModuleDescription_h
0002 #define DataFormats_Provenance_ModuleDescription_h
0003 
0004 /*----------------------------------------------------------------------
0005 
0006 ModuleDescription: The description of a producer module.
0007 
0008 ----------------------------------------------------------------------*/
0009 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0010 #include "DataFormats/Provenance/interface/ProcessConfiguration.h"
0011 
0012 #include <iosfwd>
0013 #include <limits>
0014 #include <string>
0015 
0016 namespace edm {
0017 
0018   // once a module is born, these parts of the module's product provenance
0019   // are constant   (change to ModuleDescription)
0020 
0021   class ModuleDescription {
0022   public:
0023     ModuleDescription();
0024 
0025     ModuleDescription(std::string const& modName, std::string const& modLabel);
0026 
0027     ModuleDescription(std::string const& modName, std::string const& modLabel, ProcessConfiguration const* procConfig);
0028 
0029     ModuleDescription(ParameterSetID const& pid, std::string const& modName, std::string const& modLabel);
0030 
0031     ModuleDescription(ParameterSetID const& pid,
0032                       std::string const& modName,
0033                       std::string const& modLabel,
0034                       ProcessConfiguration const* procConfig,
0035                       unsigned int modID);
0036 
0037     ~ModuleDescription();
0038 
0039     void write(std::ostream& os) const;
0040 
0041     ParameterSetID const& parameterSetID() const { return parameterSetID_; }
0042     std::string const& moduleName() const { return moduleName_; }
0043     std::string const& moduleLabel() const { return moduleLabel_; }
0044     ///A unique ID for a module declared in the Process. The id is only unique for the Process and not across different Processes.
0045     ///If the id is invalid, will return the max unsigned int value.
0046     unsigned int id() const { return id_; }
0047     ProcessConfiguration const& processConfiguration() const;
0048 
0049     std::string const& processName() const;
0050     std::string const& releaseVersion() const;
0051     ParameterSetID const& mainParameterSetID() const;
0052 
0053     // compiler-written copy c'tor, assignment, and d'tor are correct.
0054 
0055     bool operator<(ModuleDescription const& rh) const;
0056 
0057     bool operator==(ModuleDescription const& rh) const;
0058 
0059     bool operator!=(ModuleDescription const& rh) const;
0060 
0061     ///Returns a unique id each time called. Intended to be passed to ModuleDescription's constructor's modID argument. Thread safe.
0062     static unsigned int getUniqueID();
0063 
0064     ///Returns a value identifying an invalid id (the max unsigned int value)
0065     static constexpr unsigned int invalidID() { return std::numeric_limits<unsigned int>::max(); }
0066 
0067   private:
0068     // ID of parameter set of the creator
0069     ParameterSetID parameterSetID_;
0070 
0071     // The class name of the creator
0072     std::string moduleName_;
0073 
0074     // A human friendly string that uniquely identifies the EDProducer
0075     // and becomes part of the identity of a product that it produces
0076     std::string moduleLabel_;
0077 
0078     // The process configuration.
0079     ProcessConfiguration const* processConfigurationPtr_;
0080 
0081     unsigned int id_;
0082   };
0083 
0084   inline std::ostream& operator<<(std::ostream& os, ModuleDescription const& p) {
0085     p.write(os);
0086     return os;
0087   }
0088 
0089 }  // namespace edm
0090 #endif