Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:30

0001 #ifndef DataFormats_Provenance_ProductID_h
0002 #define DataFormats_Provenance_ProductID_h
0003 
0004 /*----------------------------------------------------------------------
0005   
0006 ProductID: A unique identifier for each WrapperBase within a process.
0007 Used only in Ref, Ptr, and similar classes.
0008 
0009 The high order 16 bits is the process index, identifying the process
0010 in which the product was created.  Exception: An index of 0 means that
0011 the product was created prior to the new format (i.e. prior to CMSSW_3_0_0.
0012 
0013 The low order 16 bits is the product index, identifying the product that
0014 in which the product was created.  An index of zero means no product.
0015 
0016 
0017 The 
0018 
0019 ----------------------------------------------------------------------*/
0020 
0021 #include <iosfwd>
0022 
0023 namespace edm {
0024 
0025   typedef unsigned short ProcessIndex;
0026   typedef unsigned short ProductIndex;
0027   class ProductID {
0028   public:
0029     ProductID() : processIndex_(0), productIndex_(0) {}
0030     explicit ProductID(ProductIndex prodIndex) : processIndex_(0), productIndex_(prodIndex) {}
0031     ProductID(ProcessIndex procIndex, ProductIndex prodIndex) : processIndex_(procIndex), productIndex_(prodIndex) {}
0032     bool isValid() const { return productIndex_ != 0; }
0033     ProcessIndex processIndex() const { return processIndex_; }
0034     ProcessIndex productIndex() const { return productIndex_; }
0035     ProductIndex id() const { return productIndex_; }  // backward compatibility
0036     void reset() { processIndex_ = productIndex_ = 0; }
0037 
0038     void swap(ProductID& other);
0039 
0040   private:
0041     ProcessIndex processIndex_;
0042     ProductIndex productIndex_;
0043   };
0044 
0045   inline void swap(ProductID& a, ProductID& b) { a.swap(b); }
0046 
0047   inline bool operator==(ProductID const& lh, ProductID const& rh) {
0048     return lh.processIndex() == rh.processIndex() && lh.productIndex() == rh.productIndex();
0049   }
0050   inline bool operator!=(ProductID const& lh, ProductID const& rh) { return !(lh == rh); }
0051 
0052   bool operator<(ProductID const& lh, ProductID const& rh);
0053 
0054   std::ostream& operator<<(std::ostream& os, ProductID const& id);
0055 }  // namespace edm
0056 #endif