LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
AssnsGroupWithData.cc
Go to the documentation of this file.
2 
3 art::EDProduct const*
5 {
6  art::EDProduct const* result = AssnsGroup::anyProduct();
7  if (result == nullptr) {
8  if ((result = baseProduct_.get()) == nullptr) {
9  result = partnerBaseProduct_.get();
10  }
11  }
12  return result;
13 }
14 
15 art::EDProduct const*
16 art::AssnsGroupWithData::uniqueProduct(TypeID const& wanted_wrapper_type) const
17 {
18  EDProduct const* retval = nullptr;
19  if (wanted_wrapper_type == partnerBaseWrapperType_) {
20  retval = partnerBaseProduct_.get();
21  } else if (wanted_wrapper_type == baseWrapperType_) {
22  retval = baseProduct_.get();
23  } else {
24  retval = AssnsGroup::uniqueProduct(wanted_wrapper_type);
25  }
26  return retval;
27 }
28 
29 bool
31  TypeID const& wanted_wrapper_type) const
32 {
33  // Prerequisite: ask us for something we can do.
34  if (!(wanted_wrapper_type == producedWrapperType() ||
35  wanted_wrapper_type == partnerWrapperType() ||
36  wanted_wrapper_type == baseWrapperType_ ||
37  wanted_wrapper_type == partnerBaseWrapperType_)) {
38  throwResolveLogicError(wanted_wrapper_type);
39  }
40 
41  TypeID const& upstream_wrapper_type =
42  (wanted_wrapper_type == partnerBaseWrapperType_ ||
43  wanted_wrapper_type == partnerWrapperType()) ?
46  bool result = AssnsGroup::resolveProductIfAvailable(upstream_wrapper_type);
47  if (!(productUnavailable() ||
48  (result = uniqueProduct(wanted_wrapper_type))) &&
49  AssnsGroup::uniqueProduct(upstream_wrapper_type)) {
50  if (wanted_wrapper_type == baseWrapperType_) {
51  result = makePartner(wanted_wrapper_type, baseProduct_);
52  } else if (wanted_wrapper_type == partnerBaseWrapperType_) {
53  result = makePartner(wanted_wrapper_type, partnerBaseProduct_);
54  }
55  }
56  return result;
57 }
58 
59 void
61 {
63  baseProduct_.reset();
64  partnerBaseProduct_.reset();
65 }
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
std::unique_ptr< EDProduct > partnerBaseProduct_
EDProduct const * anyProduct() const override
bool productUnavailable() const
Definition: Group.cc:84
EDProduct const * anyProduct() const override
Definition: AssnsGroup.cc:13
TypeID const & producedWrapperType() const
Definition: Group.h:162
std::unique_ptr< EDProduct > baseProduct_
bool resolveProductIfAvailable(TypeID const &) const override
void removeCachedProduct() const override
bool makePartner(TypeID const &wanted_wrapper_type, std::unique_ptr< EDProduct > &partner) const
Definition: AssnsGroup.h:103
bool resolveProductIfAvailable(TypeID const &) const override
Definition: AssnsGroup.cc:44
TypeID const & partnerWrapperType() const
Definition: AssnsGroup.h:97
void throwResolveLogicError(TypeID const &wanted_wrapper_type) const
Definition: Group.cc:123
void removeCachedProduct() const override
Definition: AssnsGroup.cc:66