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}, parentageID_{}, transients_{}
20  {}
21 
23  ProductStatus const status,
24  vector<ProductID> const& parents)
26  {
27  transients_.get().parentagePtr_ = make_shared<Parentage>(parents);
28  parentageID_ = transients_.get().parentagePtr_->id();
29  ParentageRegistry::emplace(parentageID_, *transients_.get().parentagePtr_);
30  }
31 
35  ProductProvenance const& rhs) = default;
37  default;
38 
39  ProductID
41  {
42  return productID_;
43  }
44 
47  {
48  return productStatus_;
49  }
50 
51  ParentageID const&
53  {
54  return parentageID_;
55  }
56 
57  // Note: This is true for Run, SubRun, and Results products.
58  bool
60  {
61  return transients_.get().noParentage_;
62  }
63 
64  Parentage const&
66  {
67  if (!transients_.get().parentagePtr_) {
68  transients_.get().parentagePtr_ = make_shared<Parentage>();
69  ParentageRegistry::get(parentageID_, *transients_.get().parentagePtr_);
70  }
71  return *transients_.get().parentagePtr_;
72  }
73 
74  void
75  ProductProvenance::write(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  ostream&
85  operator<<(ostream& os, ProductProvenance const& p)
86  {
87  p.write(os);
88  return os;
89  }
90 
91  bool
93  {
94  if (a.noParentage() != b.noParentage()) {
95  return false;
96  }
97  if (a.noParentage()) {
98  return (a.productID() == b.productID()) &&
99  (a.productStatus() == b.productStatus());
100  }
101  return (a.productID() == b.productID()) &&
102  (a.productStatus() == b.productStatus()) &&
103  (a.parentageID() == b.parentageID());
104  }
105 
106  bool
108  {
109  return !(a == b);
110  }
111 
112  // FIXME: This is not compatible with operator==. That is if !(a<b) && !(a>b)
113  // does not imply (a==b)!!!
114  bool
116  {
117  return a.productID() < b.productID();
118  }
119 
120 } // namespace art
bool operator==(Provenance const &a, Provenance const &b) noexcept
Definition: Provenance.cc:141
STL namespace.
bool operator!=(debugging_allocator< X > const &, debugging_allocator< Y > const &)
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_
const double a
p
Definition: test.py:223
unsigned char ProductStatus
Definition: ProductStatus.h:6
ProductStatus productStatus() const noexcept
ProductProvenance & operator=(ProductProvenance const &)
void write(std::ostream &) const
static bool * b
Definition: config.cpp:1043
static auto emplace(value_type const &value)