Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:02

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     std::string const& passID() const;
0052     ParameterSetID const& mainParameterSetID() const;
0053 
0054     // compiler-written copy c'tor, assignment, and d'tor are correct.
0055 
0056     bool operator<(ModuleDescription const& rh) const;
0057 
0058     bool operator==(ModuleDescription const& rh) const;
0059 
0060     bool operator!=(ModuleDescription const& rh) const;
0061 
0062     ///Returns a unique id each time called. Intended to be passed to ModuleDescription's constructor's modID argument. Thread safe.
0063     static unsigned int getUniqueID();
0064 
0065     ///Returns a value identifying an invalid id (the max unsigned int value)
0066     static constexpr unsigned int invalidID() { return std::numeric_limits<unsigned int>::max(); }
0067 
0068   private:
0069     // ID of parameter set of the creator
0070     ParameterSetID parameterSetID_;
0071 
0072     // The class name of the creator
0073     std::string moduleName_;
0074 
0075     // A human friendly string that uniquely identifies the EDProducer
0076     // and becomes part of the identity of a product that it produces
0077     std::string moduleLabel_;
0078 
0079     // The process configuration.
0080     ProcessConfiguration const* processConfigurationPtr_;
0081 
0082     unsigned int id_;
0083   };
0084 
0085   inline std::ostream& operator<<(std::ostream& os, ModuleDescription const& p) {
0086     p.write(os);
0087     return os;
0088   }
0089 
0090 }  // namespace edm
0091 #endif