LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
ProductProvenance.cc
Go to the documentation of this file.
4 
5 #include <cassert>
6 #include <ostream>
7 
8 namespace art {
9 
11 
13  ProductStatus const status)
14  : productID_{pid}, productStatus_{status}
15  {}
16 
18  ProductStatus const status,
19  ParentageID const& edid)
20  : productID_{pid}, productStatus_{status}, parentageID_{edid}
21  {}
22 
24  ProductStatus const status,
25  std::shared_ptr<Parentage> pPtr)
26  : productID_{pid}, productStatus_{status}, parentageID_{pPtr->id()}
27  {
28  parentagePtr() = pPtr;
30  }
31 
33  ProductStatus const status,
34  std::vector<ProductID> const& parents)
35  : productID_{pid}, productStatus_{status}
36  {
37  parentagePtr() = std::make_shared<Parentage>();
38  parentagePtr()->parents() = parents;
39  parentageID_ = parentagePtr()->id();
41  }
42 
43  Parentage const&
45  {
46  if (!parentagePtr()) {
47  parentagePtr() = std::make_shared<Parentage>();
49  parentageID_, *parentagePtr()); // Filled only if successful retrieval
50  }
51  return *parentagePtr();
52  }
53 
54  void
56  {
58  return;
61  }
62 
63  void
65  {
67  return;
69  return;
72  }
73 
74  void
75  ProductProvenance::write(std::ostream& os) const
76  {
77  os << "product ID = " << productID() << '\n';
78  os << "product status = " << static_cast<int>(productStatus()) << '\n';
79  if (!noParentage()) {
80  os << "entry description ID = " << parentageID() << '\n';
81  }
82  }
83 
84  // Only the 'salient attributes' are tested in equality comparison.
85  bool
87  {
88  if (a.noParentage() != b.noParentage())
89  return false;
90  if (a.noParentage()) {
91  return a.productID() == b.productID() &&
92  a.productStatus() == b.productStatus();
93  }
94  return a.productID() == b.productID() &&
95  a.productStatus() == b.productStatus() &&
96  a.parentageID() == b.parentageID();
97  }
98 }
ProductID productID() const
std::shared_ptr< Parentage > & parentagePtr() const
ProductStatus unknown()
Definition: ProductStatus.h:31
ProductStatus const & productStatus() const
void setStatus(ProductStatus status) const
void write(std::ostream &os) const
unsigned char ProductStatus
Definition: ProductStatus.h:12
static collection_type const & get()
Parentage const & parentage() const
ProductStatus productStatus_
ProductStatus dropped()
Definition: ProductStatus.h:26
HLT enums.
bool operator==(Provenance const &a, Provenance const &b)
Definition: Provenance.h:168
static auto emplace(value_type const &value)
ProductStatus present()
Definition: ProductStatus.h:16
ProductStatus neverCreated()
Definition: ProductStatus.h:21
ParentageID const & parentageID() const