Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-25 02:29:29

0001 #include "DataFormats/Provenance/interface/Parentage.h"
0002 #include "FWCore/Utilities/interface/Digest.h"
0003 #include <charconv>
0004 #include <sstream>
0005 //#include <cassert>
0006 
0007 /*----------------------------------------------------------------------
0008 
0009 ----------------------------------------------------------------------*/
0010 
0011 namespace edm {
0012   Parentage::Parentage() : parents_() {}
0013 
0014   Parentage::Parentage(std::vector<BranchID> const& parents) : parents_(parents) {}
0015 
0016   Parentage::Parentage(std::vector<BranchID>&& parents) : parents_(std::move(parents)) {}
0017 
0018   ParentageID Parentage::id() const {
0019     //10 is the maximum number of digits for a 2^32 number
0020     std::array<char, 10 + 1> buf;
0021     cms::Digest md5alg;
0022     for (auto const& parent : parents_) {
0023       //assert(start < end);
0024       auto res = std::to_chars(buf.data(), buf.data() + buf.size(), parent.id());
0025       //assert(res.ec == std::errc());
0026       *res.ptr = ' ';
0027       md5alg.append(buf.data(), res.ptr - buf.data() + 1);
0028     }
0029     ParentageID id(md5alg.digest().bytes);
0030     return id;
0031   }
0032 
0033   void Parentage::write(std::ostream&) const {
0034     // This is grossly inadequate, but it is not critical for the
0035     // first pass.
0036   }
0037 
0038   bool operator==(Parentage const& a, Parentage const& b) { return a.parents() == b.parents(); }
0039 }  // namespace edm