Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:02

0001 #ifndef DataFormats_Provenance_Parentage_h
0002 #define DataFormats_Provenance_Parentage_h
0003 
0004 /*----------------------------------------------------------------------
0005   
0006 Parentage: The products that were read in producing this product.
0007 
0008 ----------------------------------------------------------------------*/
0009 #include "DataFormats/Provenance/interface/BranchID.h"
0010 #include "DataFormats/Provenance/interface/ParentageID.h"
0011 
0012 #include <iosfwd>
0013 #include <vector>
0014 
0015 /*
0016   Parentage
0017 
0018   definitions:
0019   Product: The WrapperBase to which a provenance object is associated
0020 
0021   Parents: The EDProducts used as input by the creator.
0022 */
0023 
0024 namespace edm {
0025   class Parentage {
0026   public:
0027     Parentage();
0028 
0029     explicit Parentage(std::vector<BranchID> const& parents);
0030     explicit Parentage(std::vector<BranchID>&& parents);
0031 
0032     Parentage(Parentage const&) = default;
0033     Parentage(Parentage&&) = default;
0034 
0035     Parentage& operator=(Parentage const&) = default;
0036     Parentage& operator=(Parentage&&) = default;
0037 
0038     ~Parentage() {}
0039 
0040     ParentageID id() const;
0041 
0042     void write(std::ostream& os) const;
0043 
0044     std::vector<BranchID> const& parents() const { return parents_; }
0045     std::vector<BranchID>& parentsForUpdate() { return parents_; }
0046     void setParents(std::vector<BranchID> parents) { parents_ = std::move(parents); }
0047     void swap(Parentage& other) { parents_.swap(other.parents_); }
0048     void initializeTransients() { transient_.reset(); }
0049     struct Transients {
0050       Transients() {}
0051       void reset() {}
0052     };
0053 
0054   private:
0055     // The Branch IDs of the parents
0056     std::vector<BranchID> parents_;
0057     Transients transient_;
0058   };
0059 
0060   // Free swap function
0061   inline void swap(Parentage& a, Parentage& b) { a.swap(b); }
0062 
0063   inline std::ostream& operator<<(std::ostream& os, Parentage const& p) {
0064     p.write(os);
0065     return os;
0066   }
0067 
0068   // Only the 'salient attributes' are testing in equality comparison.
0069   bool operator==(Parentage const& a, Parentage const& b);
0070   inline bool operator!=(Parentage const& a, Parentage const& b) { return !(a == b); }
0071 }  // namespace edm
0072 #endif