Go to the documentation of this file.00001 #include "DataFormats/Provenance/interface/ProductProvenance.h"
00002 #include "DataFormats/Provenance/interface/ParentageRegistry.h"
00003 #include <ostream>
00004 #include <cassert>
00005
00006
00007
00008
00009
00010 namespace edm {
00011 ProductProvenance::Transients::Transients() :
00012 parentagePtr_(),
00013 noParentage_(false)
00014 {}
00015
00016 ProductProvenance::ProductProvenance() :
00017 branchID_(),
00018 productStatus_(productstatus::uninitialized()),
00019 parentageID_(),
00020 transients_()
00021 {}
00022
00023 ProductProvenance::ProductProvenance(BranchID const& bid) :
00024 branchID_(bid),
00025 productStatus_(productstatus::uninitialized()),
00026 parentageID_(),
00027 transients_()
00028 {}
00029
00030 ProductProvenance::ProductProvenance(BranchID const& bid,
00031 ProductStatus status) :
00032 branchID_(bid),
00033 productStatus_(status),
00034 parentageID_(),
00035 transients_()
00036 {}
00037
00038 ProductProvenance::ProductProvenance(BranchID const& bid,
00039 ProductStatus status,
00040 ParentageID const& edid) :
00041 branchID_(bid),
00042 productStatus_(status),
00043 parentageID_(edid),
00044 transients_()
00045 {}
00046
00047 ProductProvenance::ProductProvenance(BranchID const& bid,
00048 ProductStatus status,
00049 boost::shared_ptr<Parentage> pPtr) :
00050 branchID_(bid),
00051 productStatus_(status),
00052 parentageID_(pPtr->id()),
00053 transients_() {
00054 parentagePtr() = pPtr;
00055 ParentageRegistry::instance()->insertMapped(*pPtr);
00056 }
00057
00058 ProductProvenance::ProductProvenance(BranchID const& bid,
00059 ProductStatus status,
00060 std::vector<BranchID> const& parents) :
00061 branchID_(bid),
00062 productStatus_(status),
00063 parentageID_(),
00064 transients_() {
00065 parentagePtr() = boost::shared_ptr<Parentage>(new Parentage);
00066 parentagePtr()->parents() = parents;
00067 parentageID_ = parentagePtr()->id();
00068 ParentageRegistry::instance()->insertMapped(*parentagePtr());
00069 }
00070
00071 ProductProvenance
00072 ProductProvenance::makeProductProvenance() const {
00073 return *this;
00074 }
00075
00076 Parentage const &
00077 ProductProvenance::parentage() const {
00078 if (!parentagePtr()) {
00079 parentagePtr().reset(new Parentage);
00080 ParentageRegistry::instance()->getMapped(parentageID_, *parentagePtr());
00081 }
00082 return *parentagePtr();
00083 }
00084
00085 void
00086 ProductProvenance::setStatus(ProductStatus const& status) {
00087 if (productstatus::presenceUnknown(productStatus())) {
00088 productStatus_ = status;
00089 } else if (productstatus::present(productStatus())) {
00090 assert(productstatus::present(status));
00091 } else {
00092 assert(productstatus::notPresent(productStatus()));
00093 assert(productstatus::notPresent(status));
00094 if (!productstatus::neverCreated(status)) {
00095 productStatus_ = status;
00096 }
00097 }
00098 }
00099
00100 void
00101 ProductProvenance::write(std::ostream& os) const {
00102 os << "branch ID = " << branchID() << '\n';
00103 os << "product status = " << static_cast<int>(productStatus()) << '\n';
00104 if (!noParentage()) {
00105 os << "entry description ID = " << parentageID() << '\n';
00106 }
00107 }
00108
00109 bool
00110 operator==(ProductProvenance const& a, ProductProvenance const& b) {
00111 if (a.noParentage() != b.noParentage()) return false;
00112 if (a.noParentage()) {
00113 return
00114 a.branchID() == b.branchID()
00115 && a.productStatus() == b.productStatus();
00116 }
00117 return
00118 a.branchID() == b.branchID()
00119 && a.productStatus() == b.productStatus()
00120 && a.parentageID() == b.parentageID();
00121 }
00122 }