File indexing completed on 2024-04-06 12:05:02
0001 #ifndef DataFormats_Provenance_ProductID_h
0002 #define DataFormats_Provenance_ProductID_h
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
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_; }
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 }
0056 #endif