LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ProductProvenance.cc
Go to the documentation of this file.
1 // vim: set sw=2 expandtab :
2 
7 
8 #include <ostream>
9 
10 using namespace std;
11 
12 namespace art {
13 
14  ProductProvenance::ProductProvenance() = default;
15  ProductProvenance::~ProductProvenance() = default;
16 
17  ProductProvenance::ProductProvenance(ProductID const& bid,
18  ProductStatus const status)
19  : productID_{bid}, productStatus_{status}
20  {}
21 
23  ProductStatus const status,
24  vector<ProductID> const& parents)
25  : productID_{bid}
26  , productStatus_{status}
27  , transients_{{false, Parentage{parents}}}
28  {
29  parentageID_ = transients_.get().parentage_.id();
31  }
32 
36  default;
38  default;
39 
40  ProductID
42  {
43  return productID_;
44  }
45 
48  {
49  return productStatus_;
50  }
51 
52  ParentageID const&
54  {
55  return parentageID_;
56  }
57 
58  // Note: This is true for Run, SubRun, and Results products.
59  bool
61  {
62  return transients_.get().noParentage_;
63  }
64 
65  Parentage const&
67  {
69  return transients_.get().parentage_;
70  }
71 
72  void
73  ProductProvenance::write(ostream& os) const
74  {
75  os << "product ID = " << productID() << '\n';
76  os << "product status = " << static_cast<int>(productStatus_) << '\n';
77  if (!noParentage()) {
78  os << "entry description ID = " << parentageID() << '\n';
79  }
80  }
81 
82  ostream&
83  operator<<(ostream& os, ProductProvenance const& p)
84  {
85  p.write(os);
86  return os;
87  }
88 
89  bool
90  operator==(ProductProvenance const& a, ProductProvenance const& b) noexcept
91  {
92  if (a.noParentage() != b.noParentage()) {
93  return false;
94  }
95  if (a.noParentage()) {
96  return (a.productID() == b.productID()) &&
97  (a.productStatus() == b.productStatus());
98  }
99  return (a.productID() == b.productID()) &&
100  (a.productStatus() == b.productStatus()) &&
101  (a.parentageID() == b.parentageID());
102  }
103 
104  bool
105  operator!=(ProductProvenance const& a, ProductProvenance const& b) noexcept
106  {
107  return !(a == b);
108  }
109 
110  // FIXME: This is not compatible with operator==. That is if !(a<b) && !(a>b)
111  // does not imply (a==b)!!!
112  bool
113  operator<(ProductProvenance const& a, ProductProvenance const& b) noexcept
114  {
115  return a.productID() < b.productID();
116  }
117 
118 } // namespace art
bool operator==(Provenance const &a, Provenance const &b) noexcept
Definition: Provenance.cc:141
STL namespace.
bool operator!=(ScheduleID const left, ScheduleID const right) noexcept
Definition: ScheduleID.cc:41
ParentageID const & parentageID() const noexcept
ProductID productID() const noexcept
std::ostream & operator<<(std::ostream &os, const GroupSelector &gs)
bool operator<(ProductInfo const &a, ProductInfo const &b)
Definition: ProductInfo.cc:51
static collection_type const & get()
Parentage const & parentage() const
ProductStatus productStatus_
bool noParentage() const noexcept
Transient< Transients > transients_
unsigned char ProductStatus
Definition: ProductStatus.h:6
ProductStatus productStatus() const noexcept
ProductProvenance & operator=(ProductProvenance const &)
void write(std::ostream &) const
Definition: MVAAlg.h:12
static auto emplace(value_type const &value)