00001 #ifndef DataFormats_Provenance_ProductProvenance_h 00002 #define DataFormats_Provenance_ProductProvenance_h 00003 00004 /*---------------------------------------------------------------------- 00005 00006 ProductProvenance: The event dependent portion of the description of a product 00007 and how it came into existence. 00008 00009 ----------------------------------------------------------------------*/ 00010 #include "DataFormats/Provenance/interface/BranchID.h" 00011 #include "DataFormats/Provenance/interface/ParentageID.h" 00012 #include "DataFormats/Provenance/interface/ProvenanceFwd.h" 00013 00014 #include "boost/shared_ptr.hpp" 00015 00016 #include <iosfwd> 00017 #include <vector> 00018 00019 /* 00020 ProductProvenance 00021 */ 00022 00023 namespace edm { 00024 class ProductProvenance { 00025 public: 00026 ProductProvenance(); 00027 explicit ProductProvenance(BranchID const& bid); 00028 ProductProvenance(BranchID const& bid, 00029 boost::shared_ptr<Parentage> parentagePtr); 00030 ProductProvenance(BranchID const& bid, 00031 ParentageID const& id); 00032 00033 ProductProvenance(BranchID const& bid, 00034 std::vector<BranchID> const& parents); 00035 00036 ~ProductProvenance() {} 00037 00038 ProductProvenance makeProductProvenance() const; 00039 00040 void write(std::ostream& os) const; 00041 00042 BranchID const& branchID() const {return branchID_;} 00043 ParentageID const& parentageID() const {return parentageID_;} 00044 Parentage const& parentage() const; 00045 00046 bool& noParentage() const {return transient_.noParentage_;} 00047 00048 void initializeTransients() const {transient_.reset();} 00049 00050 struct Transients { 00051 Transients(); 00052 void reset(); 00053 boost::shared_ptr<Parentage> parentagePtr_; 00054 bool noParentage_; 00055 }; 00056 00057 private: 00058 00059 boost::shared_ptr<Parentage>& parentagePtr() const {return transient_.parentagePtr_;} 00060 00061 BranchID branchID_; 00062 ParentageID parentageID_; 00063 mutable Transients transient_; 00064 }; 00065 00066 inline 00067 bool 00068 operator<(ProductProvenance const& a, ProductProvenance const& b) { 00069 return a.branchID() < b.branchID(); 00070 } 00071 00072 inline 00073 std::ostream& 00074 operator<<(std::ostream& os, ProductProvenance const& p) { 00075 p.write(os); 00076 return os; 00077 } 00078 00079 // Only the 'salient attributes' are testing in equality comparison. 00080 bool operator==(ProductProvenance const& a, ProductProvenance const& b); 00081 inline bool operator!=(ProductProvenance const& a, ProductProvenance const& b) { return !(a == b); } 00082 typedef std::vector<ProductProvenance> ProductProvenanceVector; 00083 } 00084 #endif