File indexing completed on 2024-04-06 12:05:01
0001 #ifndef DataFormats_Provenance_ElementID_h
0002 #define DataFormats_Provenance_ElementID_h
0003
0004 #include "DataFormats/Provenance/interface/ProductID.h"
0005
0006 #include <iosfwd>
0007
0008 namespace edm {
0009
0010
0011
0012
0013
0014
0015
0016
0017 class ElementID {
0018 public:
0019 using key_type = unsigned int;
0020
0021 ElementID() = default;
0022 explicit ElementID(edm::ProductID id, key_type ind) : index_(ind), id_(id) {}
0023
0024 bool isValid() const { return id_.isValid(); }
0025 ProductID id() const { return id_; }
0026 key_type index() const { return index_; }
0027 key_type key() const { return index_; }
0028 void reset() {
0029 index_ = 0;
0030 id_.reset();
0031 }
0032
0033 void swap(ElementID& other);
0034
0035 private:
0036 key_type index_ = 0;
0037 ProductID id_;
0038 };
0039
0040 inline void swap(ElementID& a, ElementID& b) { a.swap(b); }
0041
0042 inline bool operator==(ElementID const& lh, ElementID const& rh) {
0043 return lh.index() == rh.index() && lh.id() == rh.id();
0044 }
0045
0046 inline bool operator!=(ElementID const& lh, ElementID const& rh) { return !(lh == rh); }
0047
0048 bool operator<(ElementID const& lh, ElementID const& rh);
0049
0050 std::ostream& operator<<(std::ostream& os, ElementID const& id);
0051 }
0052
0053 #endif