CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/DataFormats/Provenance/src/ProductProvenance.cc

Go to the documentation of this file.
00001 #include "DataFormats/Provenance/interface/ProductProvenance.h"
00002 #include "DataFormats/Provenance/interface/ParentageRegistry.h"
00003 
00004 #include <cassert>
00005 #include <ostream>
00006 
00007 /*----------------------------------------------------------------------
00008 
00009 ----------------------------------------------------------------------*/
00010 
00011 namespace edm {
00012   ProductProvenance::Transients::Transients() :
00013     parentagePtr_(),
00014     noParentage_(false)
00015   {}
00016 
00017   void
00018   ProductProvenance::Transients::reset() {
00019     parentagePtr_.reset();
00020     noParentage_ = false;
00021   }
00022 
00023   ProductProvenance::ProductProvenance() :
00024     branchID_(),
00025     parentageID_(),
00026     transient_()
00027   {}
00028 
00029   ProductProvenance::ProductProvenance(BranchID const& bid) :
00030     branchID_(bid),
00031     parentageID_(),
00032     transient_()
00033   {}
00034 
00035    ProductProvenance::ProductProvenance(BranchID const& bid,
00036                                     ParentageID const& edid) :
00037     branchID_(bid),
00038     parentageID_(edid),
00039     transient_()
00040   {}
00041 
00042    ProductProvenance::ProductProvenance(BranchID const& bid,
00043                                     boost::shared_ptr<Parentage> pPtr) :
00044     branchID_(bid),
00045     parentageID_(pPtr->id()),
00046     transient_() {
00047        parentagePtr() = pPtr;
00048        ParentageRegistry::instance()->insertMapped(*pPtr);
00049   }
00050 
00051   ProductProvenance::ProductProvenance(BranchID const& bid,
00052                    std::vector<BranchID> const& parents) :
00053     branchID_(bid),
00054     parentageID_(),
00055     transient_() {
00056       parentagePtr() = boost::shared_ptr<Parentage>(new Parentage);
00057       parentagePtr()->parents() = parents;
00058       parentageID_ = parentagePtr()->id();
00059       ParentageRegistry::instance()->insertMapped(*parentagePtr());
00060   }
00061 
00062   ProductProvenance
00063   ProductProvenance::makeProductProvenance() const {
00064     return *this;
00065   }
00066 
00067   Parentage const &
00068   ProductProvenance::parentage() const {
00069     if (!parentagePtr()) {
00070       parentagePtr().reset(new Parentage);
00071       ParentageRegistry::instance()->getMapped(parentageID_, *parentagePtr());
00072     }
00073     return *parentagePtr();
00074   }
00075 
00076   void
00077   ProductProvenance::write(std::ostream& os) const {
00078     os << "branch ID = " << branchID() << '\n';
00079     if (!noParentage()) {
00080       os << "entry description ID = " << parentageID() << '\n';
00081     }
00082   }
00083     
00084   bool
00085   operator==(ProductProvenance const& a, ProductProvenance const& b) {
00086     if (a.noParentage() != b.noParentage()) return false;
00087     if (a.noParentage()) {
00088       return
00089         a.branchID() == b.branchID();
00090     }
00091     return
00092       a.branchID() == b.branchID() && a.parentageID() == b.parentageID();
00093   }
00094 }