File indexing completed on 2024-04-06 12:05:04
0001 #include "DataFormats/Provenance/interface/ProductProvenance.h"
0002 #include "DataFormats/Provenance/interface/ParentageRegistry.h"
0003
0004 #include <cassert>
0005 #include <ostream>
0006
0007
0008
0009
0010
0011 namespace {
0012 edm::Parentage const s_emptyParentage;
0013 }
0014 namespace edm {
0015 ProductProvenance::ProductProvenance() : branchID_(), parentageID_() {}
0016
0017 ProductProvenance::ProductProvenance(BranchID bid) : branchID_(bid), parentageID_() {}
0018
0019 ProductProvenance::ProductProvenance(BranchID bid, ParentageID edid)
0020 : branchID_(bid), parentageID_(std::move(edid)) {}
0021
0022 ProductProvenance::ProductProvenance(BranchID bid, std::vector<BranchID> const& parents)
0023 : branchID_(bid), parentageID_() {
0024 Parentage p;
0025 p.setParents(parents);
0026 parentageID_ = p.id();
0027 ParentageRegistry::instance()->insertMapped(p);
0028 }
0029
0030 ProductProvenance::ProductProvenance(BranchID bid, std::vector<BranchID>&& parents) : branchID_(bid), parentageID_() {
0031 Parentage p;
0032 p.setParents(std::move(parents));
0033 parentageID_ = p.id();
0034 ParentageRegistry::instance()->insertMapped(std::move(p));
0035 }
0036
0037 ProductProvenance ProductProvenance::makeProductProvenance() const { return *this; }
0038
0039 Parentage const& ProductProvenance::parentage() const {
0040 auto p = ParentageRegistry::instance()->getMapped(parentageID_);
0041 if (p) {
0042 return *p;
0043 }
0044 return s_emptyParentage;
0045 }
0046
0047 void ProductProvenance::write(std::ostream& os) const {
0048 os << "branch ID = " << branchID() << '\n';
0049 os << "entry description ID = " << parentageID() << '\n';
0050 }
0051
0052 bool operator==(ProductProvenance const& a, ProductProvenance const& b) {
0053 return a.branchID() == b.branchID() && a.parentageID() == b.parentageID();
0054 }
0055 }