Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-12-21 03:54:34

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) : branchID_(bid), parentageID_(edid) {}
0020 
0021   ProductProvenance::ProductProvenance(BranchID bid, std::vector<BranchID> const& parents)
0022       : branchID_(bid), parentageID_() {
0023     Parentage p;
0024     p.setParents(parents);
0025     parentageID_ = p.id();
0026     ParentageRegistry::instance()->insertMapped(p);
0027   }
0028 
0029   ProductProvenance::ProductProvenance(BranchID bid, std::vector<BranchID>&& parents) : branchID_(bid), parentageID_() {
0030     Parentage p;
0031     p.setParents(std::move(parents));
0032     parentageID_ = p.id();
0033     ParentageRegistry::instance()->insertMapped(std::move(p));
0034   }
0035 
0036   ProductProvenance ProductProvenance::makeProductProvenance() const { return *this; }
0037 
0038   Parentage const& ProductProvenance::parentage() const {
0039     auto p = ParentageRegistry::instance()->getMapped(parentageID_);
0040     if (p) {
0041       return *p;
0042     }
0043     return s_emptyParentage;
0044   }
0045 
0046   void ProductProvenance::write(std::ostream& os) const {
0047     os << "branch ID = " << branchID() << '\n';
0048     os << "entry description ID = " << parentageID() << '\n';
0049   }
0050 
0051   bool operator==(ProductProvenance const& a, ProductProvenance const& b) {
0052     return a.branchID() == b.branchID() && a.parentageID() == b.parentageID();
0053   }
0054 }  // namespace edm