LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
PtrVectorBase.cc
Go to the documentation of this file.
2 
3 #include <utility>
4 
5 void
7 {
8  if (indicies_.size() == 0)
9  return; // Empty or already done.
11 
12  using std::swap;
13  indices_t tmp;
14  swap(indicies_, tmp); // Zero -- finished with these.
15 }
16 
17 void
18 art::PtrVectorBase::updateCore(RefCore const& productToBeInserted)
19 {
20  if (productToBeInserted.isNull()) {
21  throw art::Exception(errors::InvalidReference, "Inconsistency")
22  << "art::PtrVectorBase::updateCore: Ptr has invalid (zero) product ID,\n"
23  "so it cannot be added to a PtrVector. id should be ("
24  << id() << ")\n";
25  }
26  if (isNull()) {
27  core_ = productToBeInserted;
28  return;
29  }
30  if (core_.id() != productToBeInserted.id()) {
31  throw art::Exception(errors::InvalidReference, "Inconsistency")
32  << "art::PtrVectorBase::updateCore: Ptr is inconsistent with\n"
33  "PtrVector. id = ("
34  << productToBeInserted.id() << "), should be (" << core_.id() << ")\n";
35  }
36  if (core_.productGetter() == nullptr &&
37  productToBeInserted.productGetter() != nullptr) {
38  core_.setProductGetter(productToBeInserted.productGetter());
39  }
40  if (core_.productPtr() == nullptr &&
41  productToBeInserted.productPtr() != nullptr) {
42  core_.setProductPtr(productToBeInserted.productPtr());
43  }
44 }
void swap(PtrVectorBase &)
Float_t tmp
Definition: plot.C:37
bool isNull() const
Definition: PtrVectorBase.h:72
EDProductGetter const * productGetter() const
Definition: RefCore.h:105
ProductID id() const
Definition: PtrVectorBase.h:84
virtual void fill_from_offsets(indices_t const &indices) const =0
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
void const * productPtr() const
Definition: RefCore.h:99
void setProductGetter(EDProductGetter const *prodGetter) const
Definition: RefCore.h:117
ProductID id() const
Definition: RefCore.h:93
bool isNull() const
Definition: RefCore.h:82
void fillPtrs() const
Definition: PtrVectorBase.cc:6
std::vector< key_type > indices_t
Definition: PtrVectorBase.h:24
void updateCore(RefCore const &core)
void setProductPtr(void const *prodPtr) const
Definition: RefCore.h:111