LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
art::AssnsGroupWithData Class Reference

#include "AssnsGroupWithData.h"

Inheritance diagram for art::AssnsGroupWithData:
art::AssnsGroup art::Group art::EDProductGetter

Public Member Functions

 AssnsGroupWithData ()=default
 
bool isReady () const override
 
EDProduct const * getIt () const override
 
EDProduct const * uniqueProduct () const override
 
bool productUnavailable () const
 
cet::exempt_ptr< ProductProvenance const > productProvenancePtr () const
 
BranchDescription const & productDescription () const
 
std::string const & moduleLabel () const
 
std::string const & productInstanceName () const
 
std::string const & processName () const
 
ProductStatus status () const
 
void setResolvers (BranchMapper const &bm, DelayedReader const &dr)
 
bool resolveProduct (TypeID const &) const override
 
void write (std::ostream &os) const
 
ProductID const & productID () const
 
TypeID const & producedWrapperType () const
 
RangeSet const & rangeOfValidity () const
 

Protected Member Functions

 AssnsGroupWithData (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type, TypeID const &base_wrapper_type, TypeID const &partner_base_wrapper_type, std::unique_ptr< EDProduct > &&edp=nullptr, cet::exempt_ptr< Worker > productProducer=cet::exempt_ptr< Worker >())
 
 AssnsGroupWithData (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, std::unique_ptr< EDProduct > &&edp, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type, TypeID const &base_wrapper_type, TypeID const &partner_base_wrapper_type)
 
 AssnsGroupWithData (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, cet::exempt_ptr< Worker > productProducer, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type, TypeID const &base_wrapper_type, TypeID const &partner_base_wrapper_type)
 
EDProduct const * anyProduct () const override
 
EDProduct const * uniqueProduct (TypeID const &wanted_wrapper_type) const override
 
bool resolveProductIfAvailable (TypeID const &) const override
 
void removeCachedProduct () const override
 
TypeID const & partnerWrapperType () const
 
bool makePartner (TypeID const &wanted_wrapper_type, std::unique_ptr< EDProduct > &partner) const
 
std::unique_ptr< EDProductobtainDesiredProduct (TypeID const &) const
 
void setProduct (std::unique_ptr< EDProduct > &&prod) const
 
void throwResolveLogicError (TypeID const &wanted_wrapper_type) const
 

Private Attributes

TypeID baseWrapperType_
 
TypeID partnerBaseWrapperType_
 
std::unique_ptr< EDProductbaseProduct_
 
std::unique_ptr< EDProductpartnerBaseProduct_
 

Friends

template<typename... ARGS>
std::unique_ptr< Groupgfactory::detail::make_group (BranchDescription const &, ARGS &&...args)
 

Detailed Description

Definition at line 14 of file AssnsGroupWithData.h.

Constructor & Destructor Documentation

art::AssnsGroupWithData::AssnsGroupWithData ( )
default
art::AssnsGroupWithData::AssnsGroupWithData ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
TypeID const &  primary_wrapper_type,
TypeID const &  partner_wrapper_type,
TypeID const &  base_wrapper_type,
TypeID const &  partner_base_wrapper_type,
std::unique_ptr< EDProduct > &&  edp = nullptr,
cet::exempt_ptr< Worker productProducer = cet::exempt_ptr<Worker>() 
)
inlineprotected

Definition at line 26 of file AssnsGroupWithData.h.

References baseProduct_, partnerBaseProduct_, and partnerBaseWrapperType_.

36  : AssnsGroup(pd,
37  pid,
38  std::move(rs),
39  primary_wrapper_type,
40  partner_wrapper_type,
41  std::move(edp),
42  productProducer)
43  , baseWrapperType_{base_wrapper_type}
44  , partnerBaseWrapperType_{partner_base_wrapper_type}
45  , baseProduct_{}
47  {}
std::unique_ptr< EDProduct > partnerBaseProduct_
std::unique_ptr< EDProduct > baseProduct_
AssnsGroup()=default
art::AssnsGroupWithData::AssnsGroupWithData ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
std::unique_ptr< EDProduct > &&  edp,
TypeID const &  primary_wrapper_type,
TypeID const &  partner_wrapper_type,
TypeID const &  base_wrapper_type,
TypeID const &  partner_base_wrapper_type 
)
inlineprotected

Definition at line 49 of file AssnsGroupWithData.h.

57  : AssnsGroupWithData(pd,
58  pid,
59  std::move(rs),
60  primary_wrapper_type,
61  partner_wrapper_type,
62  base_wrapper_type,
63  partner_base_wrapper_type,
64  std::move(edp))
65  {}
art::AssnsGroupWithData::AssnsGroupWithData ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
cet::exempt_ptr< Worker productProducer,
TypeID const &  primary_wrapper_type,
TypeID const &  partner_wrapper_type,
TypeID const &  base_wrapper_type,
TypeID const &  partner_base_wrapper_type 
)
inlineprotected

Definition at line 67 of file AssnsGroupWithData.h.

References anyProduct(), removeCachedProduct(), resolveProductIfAvailable(), and art::AssnsGroup::uniqueProduct().

75  : AssnsGroupWithData(pd,
76  pid,
77  std::move(rs),
78  primary_wrapper_type,
79  partner_wrapper_type,
80  base_wrapper_type,
81  partner_base_wrapper_type,
82  nullptr,
83  productProducer)
84  {}

Member Function Documentation

art::EDProduct const * art::AssnsGroupWithData::anyProduct ( ) const
overrideprotectedvirtual

Reimplemented from art::AssnsGroup.

Definition at line 4 of file AssnsGroupWithData.cc.

References art::AssnsGroup::anyProduct(), baseProduct_, and partnerBaseProduct_.

Referenced by AssnsGroupWithData().

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 }
std::unique_ptr< EDProduct > partnerBaseProduct_
EDProduct const * anyProduct() const override
Definition: AssnsGroup.cc:13
std::unique_ptr< EDProduct > baseProduct_
art::EDProduct const * art::AssnsGroup::getIt ( ) const
overridevirtualinherited

Implements art::EDProductGetter.

Definition at line 7 of file AssnsGroup.cc.

References art::AssnsGroup::uniqueProduct().

Referenced by art::AssnsGroup::isReady().

8 {
9  return uniqueProduct();
10 }
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
bool art::AssnsGroup::isReady ( ) const
inlineoverridevirtualinherited
bool art::AssnsGroup::makePartner ( TypeID const &  wanted_wrapper_type,
std::unique_ptr< EDProduct > &  partner 
) const
inlineprotectedinherited

Definition at line 103 of file AssnsGroup.h.

References art::EDProduct::makePartner(), art::TypeID::typeInfo(), and art::Group::uniqueProduct().

Referenced by art::AssnsGroup::resolveProductIfAvailable(), and resolveProductIfAvailable().

105  {
106  bool result;
107  auto edp =
108  Group::uniqueProduct()->makePartner(wanted_wrapper_type.typeInfo());
109  if ((result = edp.get())) {
110  partner = std::move(edp);
111  }
112  return result;
113  }
std::unique_ptr< EDProduct > makePartner(std::type_info const &wanted_type) const
Definition: EDProduct.h:61
EDProduct const * uniqueProduct() const override
Definition: Group.h:103
std::string const& art::Group::moduleLabel ( ) const
inlineinherited

Definition at line 123 of file Group.h.

References art::Group::branchDescription_.

124  {
125  return branchDescription_->moduleLabel();
126  }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
std::unique_ptr< art::EDProduct > art::Group::obtainDesiredProduct ( TypeID const &  wanted_wrapper_type) const
protectedinherited

Definition at line 76 of file Group.cc.

References art::Group::productDescription(), art::Group::productResolver_, and art::Group::rangeOfValidity_.

Referenced by art::Group::rangeOfValidity(), and art::Group::resolveProductIfAvailable().

77 {
78  BranchKey const bk{productDescription()};
79  return productResolver_->getProduct(
80  bk, wanted_wrapper_type, rangeOfValidity_);
81 }
RangeSet rangeOfValidity_
Definition: Group.h:194
cet::exempt_ptr< DelayedReader const > productResolver_
Definition: Group.h:189
BranchDescription const & productDescription() const
Definition: Group.h:117
TypeID const& art::AssnsGroup::partnerWrapperType ( ) const
inlineprotectedinherited

Definition at line 97 of file AssnsGroup.h.

References art::AssnsGroup::partnerWrapperType_.

Referenced by resolveProductIfAvailable().

98  {
99  return partnerWrapperType_;
100  }
TypeID partnerWrapperType_
Definition: AssnsGroup.h:116
std::string const& art::Group::processName ( ) const
inlineinherited

Definition at line 135 of file Group.h.

References art::Group::branchDescription_, and art::Group::status().

136  {
137  return branchDescription_->processName();
138  }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
TypeID const& art::Group::producedWrapperType ( ) const
inlineinherited
BranchDescription const& art::Group::productDescription ( ) const
inlineinherited

Definition at line 117 of file Group.h.

References art::Group::branchDescription_.

Referenced by art::Group::obtainDesiredProduct(), and art::Group::resolveProduct().

118  {
119  return *branchDescription_;
120  }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
ProductID const& art::Group::productID ( ) const
inlineinherited

Definition at line 156 of file Group.h.

References art::Group::pid_.

157  {
158  return pid_;
159  };
ProductID pid_
Definition: Group.h:192
std::string const& art::Group::productInstanceName ( ) const
inlineinherited

Definition at line 129 of file Group.h.

References art::Group::branchDescription_.

130  {
131  return branchDescription_->productInstanceName();
132  }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
cet::exempt_ptr< art::ProductProvenance const > art::Group::productProvenancePtr ( ) const
inherited

Definition at line 96 of file Group.cc.

References art::Group::branchDescription_, and art::Group::ppResolver_.

Referenced by art::detail::PrincipalProcessor< DETAIL >::operator()(), art::Group::resolveProduct(), art::Group::status(), and art::Group::uniqueProduct().

97 {
98  if (!ppResolver_) {
99  return cet::exempt_ptr<ProductProvenance const>{};
100  }
101  return ppResolver_->branchToProductProvenance(
102  branchDescription_->productID());
103 }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
cet::exempt_ptr< BranchMapper const > ppResolver_
Definition: Group.h:188
bool art::Group::productUnavailable ( ) const
inherited

Definition at line 84 of file Group.cc.

References art::Group::dropped(), art::productstatus::present(), art::Group::status(), and art::productstatus::unknown().

Referenced by art::Group::Group(), art::Group::resolveProduct(), art::AssnsGroup::resolveProductIfAvailable(), resolveProductIfAvailable(), and art::Group::resolveProductIfAvailable().

85 {
86  if (dropped()) {
87  return true;
88  }
90  return false;
91  }
92  return !productstatus::present(status());
93 }
ProductStatus unknown()
Definition: ProductStatus.h:31
ProductStatus status() const
Definition: Group.cc:14
ProductStatus present()
Definition: ProductStatus.h:16
bool dropped() const
Definition: Group.cc:132
RangeSet const& art::Group::rangeOfValidity ( ) const
inlineinherited
void art::AssnsGroupWithData::removeCachedProduct ( ) const
overrideprotectedvirtual

Reimplemented from art::AssnsGroup.

Definition at line 60 of file AssnsGroupWithData.cc.

References baseProduct_, partnerBaseProduct_, and art::AssnsGroup::removeCachedProduct().

Referenced by AssnsGroupWithData().

61 {
63  baseProduct_.reset();
64  partnerBaseProduct_.reset();
65 }
std::unique_ptr< EDProduct > partnerBaseProduct_
std::unique_ptr< EDProduct > baseProduct_
void removeCachedProduct() const override
Definition: AssnsGroup.cc:66
bool art::Group::resolveProduct ( TypeID const &  wanted_wrapper_type) const
overridevirtualinherited

Implements art::EDProductGetter.

Definition at line 45 of file Group.cc.

References e, art::Group::productDescription(), art::errors::ProductNotFound, art::Group::productProvenancePtr(), art::Group::productUnavailable(), and art::Group::resolveProductIfAvailable().

Referenced by art::detail::PrincipalProcessor< DETAIL >::operator()(), and art::Group::setResolvers().

46 {
47  if (!productUnavailable()) {
48  return resolveProductIfAvailable(wanted_wrapper_type);
49  }
50  art::Exception e{errors::ProductNotFound, "InaccessibleProduct"};
51  e << "resolveProduct: product is not accessible\n"
52  << productDescription() << '\n';
53  if (productProvenancePtr()) {
54  e << *productProvenancePtr() << '\n';
55  }
56  throw e;
57 }
bool productUnavailable() const
Definition: Group.cc:84
cet::exempt_ptr< ProductProvenance const > productProvenancePtr() const
Definition: Group.cc:96
bool resolveProductIfAvailable(TypeID const &) const override
Definition: Group.cc:60
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
Float_t e
Definition: plot.C:34
BranchDescription const & productDescription() const
Definition: Group.h:117
bool art::AssnsGroupWithData::resolveProductIfAvailable ( TypeID const &  wanted_wrapper_type) const
overrideprotectedvirtual

Reimplemented from art::AssnsGroup.

Definition at line 30 of file AssnsGroupWithData.cc.

References baseProduct_, baseWrapperType_, art::AssnsGroup::makePartner(), partnerBaseProduct_, partnerBaseWrapperType_, art::AssnsGroup::partnerWrapperType(), art::Group::producedWrapperType(), art::Group::productUnavailable(), art::AssnsGroup::resolveProductIfAvailable(), art::Group::throwResolveLogicError(), and art::AssnsGroup::uniqueProduct().

Referenced by AssnsGroupWithData().

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 }
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
std::unique_ptr< EDProduct > partnerBaseProduct_
bool productUnavailable() const
Definition: Group.cc:84
TypeID const & producedWrapperType() const
Definition: Group.h:162
std::unique_ptr< EDProduct > baseProduct_
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 art::Group::setProduct ( std::unique_ptr< EDProduct > &&  prod) const
protectedinherited

Definition at line 116 of file Group.cc.

References art::Group::product_.

Referenced by art::Group::rangeOfValidity(), and art::Group::resolveProductIfAvailable().

117 {
118  assert(!product_.get());
119  product_ = std::move(prod);
120 }
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
void art::Group::setResolvers ( BranchMapper const &  bm,
DelayedReader const &  dr 
)
inlineinherited

Definition at line 143 of file Group.h.

References art::Group::ppResolver_, art::Group::productResolver_, art::Group::resolveProduct(), art::Group::resolveProductIfAvailable(), and art::Group::write().

144  {
145  ppResolver_.reset(&bm);
146  productResolver_.reset(&dr);
147  }
cet::exempt_ptr< BranchMapper const > ppResolver_
Definition: Group.h:188
cet::exempt_ptr< DelayedReader const > productResolver_
Definition: Group.h:189
art::ProductStatus art::Group::status ( ) const
inherited

Definition at line 14 of file Group.cc.

References art::productstatus::dropped(), art::Group::dropped(), art::productstatus::neverCreated(), art::productstatus::present(), art::Group::product_, art::Group::productProvenancePtr(), and art::productstatus::unknown().

Referenced by art::Group::processName(), and art::Group::productUnavailable().

15 {
16  if (dropped()) {
17  return productstatus::dropped();
18  }
19  cet::exempt_ptr<ProductProvenance const> pp(productProvenancePtr());
20  if (!pp) {
21  // No provenance, must be new.
22  if (product_.get()) {
23  if (product_->isPresent()) {
24  return productstatus::present();
25  }
27  }
28  return productstatus::unknown();
29  }
30  if (product_.get()) {
31  // Product has already been delay read, use the present flag
32  // from the wrapper.
33  // FIXME: Old CMS note said backward compatibility only?
34  if (product_->isPresent()) {
35  pp->setPresent();
36  } else {
37  pp->setNotPresent();
38  }
39  }
40  // Not new, and not yet read, use the status from the provenance.
41  return pp->productStatus();
42 }
ProductStatus unknown()
Definition: ProductStatus.h:31
cet::exempt_ptr< ProductProvenance const > productProvenancePtr() const
Definition: Group.cc:96
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
ProductStatus dropped()
Definition: ProductStatus.h:26
ProductStatus present()
Definition: ProductStatus.h:16
bool dropped() const
Definition: Group.cc:132
ProductStatus neverCreated()
Definition: ProductStatus.h:21
void art::Group::throwResolveLogicError ( TypeID const &  wanted_wrapper_type) const
protectedinherited

Definition at line 123 of file Group.cc.

References art::TypeID::className(), and art::errors::LogicError.

Referenced by art::Group::rangeOfValidity(), art::AssnsGroup::resolveProductIfAvailable(), resolveProductIfAvailable(), and art::Group::resolveProductIfAvailable().

124 {
125  throw Exception(errors::LogicError, "INTERNAL ERROR: ")
126  << cet::demangle_symbol(typeid(*this).name())
127  << " cannot resolve wanted product of type "
128  << wanted_wrapper_type.className() << ".\n";
129 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::EDProduct const * art::AssnsGroup::uniqueProduct ( ) const
overridevirtualinherited

Implements art::EDProductGetter.

Definition at line 23 of file AssnsGroup.cc.

References art::errors::LogicError.

Referenced by AssnsGroupWithData(), art::AssnsGroup::getIt(), art::AssnsGroup::isReady(), art::AssnsGroup::resolveProductIfAvailable(), resolveProductIfAvailable(), and uniqueProduct().

24 {
25  throw Exception(errors::LogicError, "AmbiguousProduct")
26  << cet::demangle_symbol(typeid(*this).name())
27  << " was asked for a held product (uniqueProduct()) "
28  << "without specifying which one was wanted.\n";
29 }
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
art::EDProduct const * art::AssnsGroupWithData::uniqueProduct ( TypeID const &  wanted_wrapper_type) const
overrideprotectedvirtual

Reimplemented from art::AssnsGroup.

Definition at line 16 of file AssnsGroupWithData.cc.

References baseProduct_, baseWrapperType_, partnerBaseProduct_, partnerBaseWrapperType_, and art::AssnsGroup::uniqueProduct().

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 }
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
std::unique_ptr< EDProduct > partnerBaseProduct_
std::unique_ptr< EDProduct > baseProduct_
void art::Group::write ( std::ostream &  os) const
inherited

Definition at line 139 of file Group.cc.

References art::Group::pid_.

Referenced by art::operator<<(), and art::Group::setResolvers().

140 {
141  // This is grossly inadequate. It is also not critical for the
142  // first pass.
143  os << "Group for product with ID: " << pid_;
144 }
ProductID pid_
Definition: Group.h:192

Friends And Related Function Documentation

template<typename... ARGS>
std::unique_ptr<Group> gfactory::detail::make_group ( BranchDescription const &  ,
ARGS &&...  args 
)
friend

Member Data Documentation

std::unique_ptr<EDProduct> art::AssnsGroupWithData::baseProduct_
mutableprivate
TypeID art::AssnsGroupWithData::baseWrapperType_
private

Definition at line 98 of file AssnsGroupWithData.h.

Referenced by resolveProductIfAvailable(), and uniqueProduct().

std::unique_ptr<EDProduct> art::AssnsGroupWithData::partnerBaseProduct_
mutableprivate
TypeID art::AssnsGroupWithData::partnerBaseWrapperType_
private

The documentation for this class was generated from the following files: