00001 #ifndef DataFormats_Provenance_BranchID_h 00002 #define DataFormats_Provenance_BranchID_h 00003 00004 /*---------------------------------------------------------------------- 00005 00006 BranchID: A unique identifier for each branch. 00007 00008 ----------------------------------------------------------------------*/ 00009 00010 #include <iosfwd> 00011 #include <string> 00012 00013 namespace edm { 00014 class BranchID { 00015 public: 00016 typedef unsigned int value_type; 00017 BranchID() : id_(0) { } 00018 explicit BranchID(std::string const& branchName) : id_(toID(branchName)) { 00019 } 00020 explicit BranchID(value_type id) : id_(id) { 00021 } 00022 void setID(std::string const& branchName) {id_ = toID(branchName);} 00023 unsigned int id() const { return id_; } 00024 bool isValid() const {return id_ != 0;} 00025 00026 bool operator<(BranchID const& rh) const {return id_ < rh.id_;} 00027 bool operator>(BranchID const& rh) const {return id_ > rh.id_;} 00028 bool operator==(BranchID const& rh) const {return id_ == rh.id_;} 00029 bool operator!=(BranchID const& rh) const {return id_ != rh.id_;} 00030 00031 private: 00032 static value_type toID(std::string const& branchName); 00033 value_type id_; 00034 }; 00035 00036 00037 std::ostream& 00038 operator<<(std::ostream& os, BranchID const& id); 00039 } 00040 #endif