LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
art::AssnsGroup Class Reference

#include "AssnsGroup.h"

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

Public Member Functions

 AssnsGroup ()=default
 
bool isReady () const override
 
EDProduct const * getIt () const override
 
EDProduct const * anyProduct () const override
 
EDProduct const * uniqueProduct () const override
 
EDProduct const * uniqueProduct (TypeID const &wanted_wrapper_type) const override
 
bool resolveProductIfAvailable (TypeID const &) const override
 
void removeCachedProduct () 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

 AssnsGroup (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type, std::unique_ptr< EDProduct > &&edp=nullptr, cet::exempt_ptr< Worker > productProducer=cet::exempt_ptr< Worker >())
 
 AssnsGroup (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, std::unique_ptr< EDProduct > &&edp, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type)
 
 AssnsGroup (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 & 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 partnerWrapperType_
 
std::unique_ptr< EDProductpartnerProduct_
 

Friends

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

Detailed Description

Definition at line 16 of file AssnsGroup.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file AssnsGroup.h.

References partnerProduct_, and partnerWrapperType_.

36  : Group{pd,
37  pid,
38  std::move(rs),
39  primary_wrapper_type,
40  std::move(edp),
41  productProducer}
42  , partnerWrapperType_{partner_wrapper_type}
43  , partnerProduct_{}
44  {}
TypeID partnerWrapperType_
Definition: AssnsGroup.h:116
std::unique_ptr< EDProduct > partnerProduct_
Definition: AssnsGroup.h:117
Group()=default
art::AssnsGroup::AssnsGroup ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
std::unique_ptr< EDProduct > &&  edp,
TypeID const &  primary_wrapper_type,
TypeID const &  partner_wrapper_type 
)
inlineprotected

Definition at line 46 of file AssnsGroup.h.

52  : AssnsGroup{pd,
53  pid,
54  std::move(rs),
55  primary_wrapper_type,
56  partner_wrapper_type,
57  std::move(edp)}
58  {}
AssnsGroup()=default
art::AssnsGroup::AssnsGroup ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
cet::exempt_ptr< Worker productProducer,
TypeID const &  primary_wrapper_type,
TypeID const &  partner_wrapper_type 
)
inlineprotected

Definition at line 60 of file AssnsGroup.h.

66  : AssnsGroup{pd,
67  pid,
68  std::move(rs),
69  primary_wrapper_type,
70  partner_wrapper_type,
71  nullptr,
72  productProducer}
73  {}
AssnsGroup()=default

Member Function Documentation

art::EDProduct const * art::AssnsGroup::anyProduct ( ) const
overridevirtual

Implements art::EDProductGetter.

Reimplemented in art::AssnsGroupWithData.

Definition at line 13 of file AssnsGroup.cc.

References art::Group::anyProduct(), and partnerProduct_.

Referenced by art::AssnsGroupWithData::anyProduct(), and isReady().

14 {
15  art::EDProduct const* result = Group::anyProduct();
16  if (result == nullptr) {
17  result = partnerProduct_.get();
18  }
19  return result;
20 }
std::unique_ptr< EDProduct > partnerProduct_
Definition: AssnsGroup.h:117
EDProduct const * anyProduct() const override
Definition: Group.h:97
art::EDProduct const * art::AssnsGroup::getIt ( ) const
overridevirtual

Implements art::EDProductGetter.

Definition at line 7 of file AssnsGroup.cc.

References uniqueProduct().

Referenced by isReady().

8 {
9  return uniqueProduct();
10 }
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
bool art::AssnsGroup::isReady ( ) const
inlineoverridevirtual

Implements art::EDProductGetter.

Definition at line 77 of file AssnsGroup.h.

References anyProduct(), getIt(), removeCachedProduct(), resolveProductIfAvailable(), and uniqueProduct().

78  {
79  return true;
80  }
bool art::AssnsGroup::makePartner ( TypeID const &  wanted_wrapper_type,
std::unique_ptr< EDProduct > &  partner 
) const
inlineprotected

Definition at line 103 of file AssnsGroup.h.

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

Referenced by resolveProductIfAvailable(), and art::AssnsGroupWithData::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
inlineprotected

Definition at line 97 of file AssnsGroup.h.

References partnerWrapperType_.

Referenced by art::AssnsGroupWithData::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(), resolveProductIfAvailable(), art::AssnsGroupWithData::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::AssnsGroup::removeCachedProduct ( ) const
overridevirtual

Reimplemented from art::Group.

Reimplemented in art::AssnsGroupWithData.

Definition at line 66 of file AssnsGroup.cc.

References partnerProduct_, and art::Group::removeCachedProduct().

Referenced by isReady(), and art::AssnsGroupWithData::removeCachedProduct().

67 {
69  partnerProduct_.reset();
70 }
std::unique_ptr< EDProduct > partnerProduct_
Definition: AssnsGroup.h:117
virtual void removeCachedProduct() const
Definition: Group.cc:106
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::AssnsGroup::resolveProductIfAvailable ( TypeID const &  wanted_wrapper_type) const
overridevirtual

Implements art::EDProductGetter.

Reimplemented in art::AssnsGroupWithData.

Definition at line 44 of file AssnsGroup.cc.

References makePartner(), partnerProduct_, partnerWrapperType_, art::Group::producedWrapperType(), art::Group::productUnavailable(), art::Group::resolveProductIfAvailable(), art::Group::throwResolveLogicError(), uniqueProduct(), and art::Group::uniqueProduct().

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

46 {
47  // Ask us for something we can do.
48  if (!(wanted_wrapper_type == producedWrapperType() ||
49  wanted_wrapper_type == partnerWrapperType_)) {
50  throwResolveLogicError(wanted_wrapper_type);
51  }
53  if (!(productUnavailable() ||
54  (result = uniqueProduct(wanted_wrapper_type))) &&
55  Group::uniqueProduct() != nullptr) {
56  if (wanted_wrapper_type == partnerWrapperType_) {
57  // We know at this point that our wanted object has not been read
58  // or created yet.
59  result = makePartner(wanted_wrapper_type, partnerProduct_);
60  }
61  }
62  return result;
63 }
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
TypeID partnerWrapperType_
Definition: AssnsGroup.h:116
bool productUnavailable() const
Definition: Group.cc:84
std::unique_ptr< EDProduct > partnerProduct_
Definition: AssnsGroup.h:117
TypeID const & producedWrapperType() const
Definition: Group.h:162
bool resolveProductIfAvailable(TypeID const &) const override
Definition: Group.cc:60
EDProduct const * uniqueProduct() const override
Definition: Group.h:103
bool makePartner(TypeID const &wanted_wrapper_type, std::unique_ptr< EDProduct > &partner) const
Definition: AssnsGroup.h:103
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(), resolveProductIfAvailable(), art::AssnsGroupWithData::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
overridevirtual

Implements art::EDProductGetter.

Definition at line 23 of file AssnsGroup.cc.

References art::errors::LogicError.

Referenced by art::AssnsGroupWithData::AssnsGroupWithData(), getIt(), isReady(), resolveProductIfAvailable(), art::AssnsGroupWithData::resolveProductIfAvailable(), and art::AssnsGroupWithData::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::AssnsGroup::uniqueProduct ( TypeID const &  wanted_wrapper_type) const
overridevirtual

Implements art::EDProductGetter.

Reimplemented in art::AssnsGroupWithData.

Definition at line 32 of file AssnsGroup.cc.

References partnerProduct_, partnerWrapperType_, and art::Group::uniqueProduct().

33 {
34  EDProduct const* retval = nullptr;
35  if (wanted_wrapper_type == partnerWrapperType_) {
36  retval = partnerProduct_.get();
37  } else {
38  retval = Group::uniqueProduct();
39  }
40  return retval;
41 }
TypeID partnerWrapperType_
Definition: AssnsGroup.h:116
std::unique_ptr< EDProduct > partnerProduct_
Definition: AssnsGroup.h:117
EDProduct const * uniqueProduct() const override
Definition: Group.h:103
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::AssnsGroup::partnerProduct_
mutableprivate
TypeID art::AssnsGroup::partnerWrapperType_
private

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