CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/DataFormats/Provenance/interface/ProductID.h

Go to the documentation of this file.
00001 #ifndef DataFormats_Provenance_ProductID_h
00002 #define DataFormats_Provenance_ProductID_h
00003 
00004 /*----------------------------------------------------------------------
00005   
00006 ProductID: A unique identifier for each EDProduct within a process.
00007 Used only in Ref, Ptr, and similar classes.
00008 
00009 The high order 16 bits is the process index, identifying the process
00010 in which the product was created.  Exception: An index of 0 means that
00011 the product was created prior to the new format (i.e. prior to CMSSW_3_0_0.
00012 
00013 The low order 16 bits is the product index, identifying the product that
00014 in which the product was created.  An index of zero means no product.
00015 
00016 
00017 The 
00018 
00019 ----------------------------------------------------------------------*/
00020 
00021 #include <iosfwd>
00022 
00023 namespace edm {
00024 
00025   typedef unsigned short ProcessIndex;
00026   typedef unsigned short ProductIndex;
00027   class ProductID {
00028   public:
00029     ProductID() : processIndex_(0),
00030                   productIndex_(0),
00031                   oldID_(0) {}
00032     explicit
00033     ProductID(ProductIndex productIndex) : processIndex_(0), productIndex_(productIndex), oldID_(0) {}
00034     ProductID(ProcessIndex processIndex, ProductIndex productIndex) :
00035       processIndex_(processIndex), productIndex_(productIndex), oldID_(0) {}
00036     bool isValid() const {return productIndex_ != 0;}
00037     ProcessIndex processIndex() const {return processIndex_;}
00038     ProcessIndex productIndex() const {return productIndex_;}
00039     ProductIndex id() const {return productIndex_;} // backward compatibility
00040     void reset() {processIndex_ = productIndex_ = 0;}
00041 
00042     unsigned int oldID() const {return oldID_;}
00043     unsigned int & oldID() {return oldID_;}
00044     void swap(ProductID& other);
00045 
00046   private:
00047     ProcessIndex processIndex_;
00048     ProductIndex productIndex_;
00049     unsigned int oldID_;
00050   };
00051 
00052   inline
00053   void swap(ProductID& a, ProductID& b) {
00054     a.swap(b);
00055   }
00056 
00057   inline
00058   bool operator==(ProductID const& lh, ProductID const& rh) {
00059     return lh.processIndex() == rh.processIndex() && lh.productIndex() == rh.productIndex();
00060   }
00061   inline
00062   bool operator!=(ProductID const& lh, ProductID const& rh) {
00063     return !(lh == rh);
00064   }
00065 
00066   bool operator<(ProductID const& lh, ProductID const& rh);
00067 
00068   std::ostream&
00069   operator<<(std::ostream& os, ProductID const& id);
00070 }
00071 #endif