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

#include "Group.h"

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

Public Member Functions

 Group ()=default
 
bool productUnavailable () const
 
bool isReady () const override
 
EDProduct const * getIt () const override
 
EDProduct const * anyProduct () const override
 
EDProduct const * uniqueProduct () const override
 
EDProduct const * uniqueProduct (TypeID const &) const override
 
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
 
bool resolveProductIfAvailable (TypeID const &) const override
 
void write (std::ostream &os) const
 
ProductID const & productID () const
 
TypeID const & producedWrapperType () const
 
virtual void removeCachedProduct () const
 
RangeSet const & rangeOfValidity () const
 

Protected Member Functions

 Group (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, art::TypeID const &wrapper_type, std::unique_ptr< EDProduct > &&edp=nullptr, cet::exempt_ptr< Worker > productProducer=cet::exempt_ptr< Worker >{})
 
 Group (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, cet::exempt_ptr< Worker > productProducer, art::TypeID const &wrapper_type)
 
 Group (BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, std::unique_ptr< EDProduct > &&edp, art::TypeID const &wrapper_type)
 
std::unique_ptr< EDProductobtainDesiredProduct (TypeID const &) const
 
void setProduct (std::unique_ptr< EDProduct > &&prod) const
 
void throwResolveLogicError (TypeID const &wanted_wrapper_type) const
 

Private Member Functions

bool dropped () const
 

Private Attributes

TypeID wrapperType_ {}
 
cet::exempt_ptr< BranchMapper const > ppResolver_ {nullptr}
 
cet::exempt_ptr< DelayedReader const > productResolver_ {nullptr}
 
std::unique_ptr< EDProductproduct_ {nullptr}
 
cet::exempt_ptr< BranchDescription const > branchDescription_ {nullptr}
 
ProductID pid_ {}
 
cet::exempt_ptr< WorkerproductProducer_ {nullptr}
 
RangeSet rangeOfValidity_ {RangeSet::invalid()}
 

Friends

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

Detailed Description

Definition at line 34 of file Group.h.

Constructor & Destructor Documentation

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

Definition at line 49 of file Group.h.

References branchDescription_, pid_, product_, productProducer_, rangeOfValidity_, and wrapperType_.

54  {})
55  : wrapperType_{wrapper_type}
56  , product_{std::move(edp)}
57  , branchDescription_{&pd}
58  , pid_{pid}
59  , productProducer_{productProducer}
60  , rangeOfValidity_{std::move(rs)}
61  {}
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
ProductID pid_
Definition: Group.h:192
RangeSet rangeOfValidity_
Definition: Group.h:194
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
TypeID wrapperType_
Definition: Group.h:187
cet::exempt_ptr< Worker > productProducer_
Definition: Group.h:193
art::Group::Group ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
cet::exempt_ptr< Worker productProducer,
art::TypeID const &  wrapper_type 
)
inlineprotected

Definition at line 63 of file Group.h.

68  : Group{pd, pid, std::move(rs), wrapper_type, nullptr, productProducer}
69  {}
Group()=default
art::Group::Group ( BranchDescription const &  pd,
ProductID const &  pid,
RangeSet &&  rs,
std::unique_ptr< EDProduct > &&  edp,
art::TypeID const &  wrapper_type 
)
inlineprotected

Definition at line 71 of file Group.h.

References productUnavailable().

76  : Group{pd, pid, std::move(rs), wrapper_type, std::move(edp)}
77  {}
Group()=default

Member Function Documentation

EDProduct const* art::Group::anyProduct ( ) const
inlineoverridevirtual

Implements art::EDProductGetter.

Definition at line 97 of file Group.h.

References product_.

Referenced by art::AssnsGroup::anyProduct(), and art::detail::PrincipalProcessor< DETAIL >::operator()().

98  {
99  return product_.get();
100  }
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
bool art::Group::dropped ( ) const
private

Definition at line 132 of file Group.cc.

References branchDescription_.

Referenced by productUnavailable(), rangeOfValidity(), and status().

133 {
134  assert(branchDescription_);
135  return branchDescription_->dropped();
136 }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
EDProduct const* art::Group::getIt ( ) const
inlineoverridevirtual

Implements art::EDProductGetter.

Definition at line 90 of file Group.h.

References producedWrapperType(), product_, and resolveProductIfAvailable().

91  {
93  return product_.get();
94  }
TypeID const & producedWrapperType() const
Definition: Group.h:162
bool resolveProductIfAvailable(TypeID const &) const override
Definition: Group.cc:60
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
bool art::Group::isReady ( ) const
inlineoverridevirtual

Implements art::EDProductGetter.

Definition at line 84 of file Group.h.

85  {
86  return true;
87  }
std::string const& art::Group::moduleLabel ( ) const
inline

Definition at line 123 of file Group.h.

References 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
protected

Definition at line 76 of file Group.cc.

References productDescription(), productResolver_, and rangeOfValidity_.

Referenced by rangeOfValidity(), and 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
std::string const& art::Group::processName ( ) const
inline

Definition at line 135 of file Group.h.

References branchDescription_, and status().

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

Definition at line 117 of file Group.h.

References branchDescription_.

Referenced by obtainDesiredProduct(), and resolveProduct().

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

Definition at line 156 of file Group.h.

References pid_.

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

Definition at line 129 of file Group.h.

References 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

Definition at line 96 of file Group.cc.

References branchDescription_, and ppResolver_.

Referenced by art::detail::PrincipalProcessor< DETAIL >::operator()(), resolveProduct(), status(), and 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

Definition at line 84 of file Group.cc.

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

Referenced by Group(), resolveProduct(), art::AssnsGroup::resolveProductIfAvailable(), art::AssnsGroupWithData::resolveProductIfAvailable(), and 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
inline

Definition at line 170 of file Group.h.

References dropped(), obtainDesiredProduct(), rangeOfValidity_, setProduct(), and throwResolveLogicError().

171  {
172  return rangeOfValidity_;
173  }
RangeSet rangeOfValidity_
Definition: Group.h:194
void art::Group::removeCachedProduct ( ) const
virtual

Reimplemented in art::AssnsGroupWithData, and art::AssnsGroup.

Definition at line 106 of file Group.cc.

References branchDescription_, and product_.

Referenced by producedWrapperType(), and art::AssnsGroup::removeCachedProduct().

107 {
108  // This check should already have been done by the surrounding art
109  // code, therefore this is a precondition and valid for an assertion
110  // rather than a runtime check and throw.
111  assert(!(branchDescription_ && branchDescription_->produced()));
112  product_.reset();
113 }
cet::exempt_ptr< BranchDescription const > branchDescription_
Definition: Group.h:191
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
bool art::Group::resolveProduct ( TypeID const &  wanted_wrapper_type) const
overridevirtual

Implements art::EDProductGetter.

Definition at line 45 of file Group.cc.

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

Referenced by art::detail::PrincipalProcessor< DETAIL >::operator()(), and 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::Group::resolveProductIfAvailable ( TypeID const &  wanted_wrapper_type) const
overridevirtual

Implements art::EDProductGetter.

Definition at line 60 of file Group.cc.

References obtainDesiredProduct(), product_, productUnavailable(), setProduct(), throwResolveLogicError(), and wrapperType_.

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

61 {
62  if (wanted_wrapper_type != wrapperType_) {
63  throwResolveLogicError(wanted_wrapper_type);
64  }
65  bool result = product_.get();
66  if (!(result || productUnavailable())) {
67  std::unique_ptr<EDProduct> edp{obtainDesiredProduct(wanted_wrapper_type)};
68  if ((result = edp.get())) {
69  setProduct(std::move(edp));
70  }
71  }
72  return result;
73 }
bool productUnavailable() const
Definition: Group.cc:84
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
TypeID wrapperType_
Definition: Group.h:187
std::unique_ptr< EDProduct > obtainDesiredProduct(TypeID const &) const
Definition: Group.cc:76
void setProduct(std::unique_ptr< EDProduct > &&prod) const
Definition: Group.cc:116
void throwResolveLogicError(TypeID const &wanted_wrapper_type) const
Definition: Group.cc:123
void art::Group::setProduct ( std::unique_ptr< EDProduct > &&  prod) const
protected

Definition at line 116 of file Group.cc.

References product_.

Referenced by rangeOfValidity(), and 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 
)
inline

Definition at line 143 of file Group.h.

References ppResolver_, productResolver_, resolveProduct(), resolveProductIfAvailable(), and 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

Definition at line 14 of file Group.cc.

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

Referenced by processName(), and 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
protected

Definition at line 123 of file Group.cc.

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

Referenced by rangeOfValidity(), art::AssnsGroup::resolveProductIfAvailable(), art::AssnsGroupWithData::resolveProductIfAvailable(), and 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
EDProduct const* art::Group::uniqueProduct ( ) const
inlineoverridevirtual

Implements art::EDProductGetter.

Definition at line 103 of file Group.h.

References product_.

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

104  {
105  return product_.get();
106  }
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
EDProduct const* art::Group::uniqueProduct ( TypeID const &  ) const
inlineoverridevirtual

Implements art::EDProductGetter.

Definition at line 109 of file Group.h.

References product_, and productProvenancePtr().

110  {
111  return product_.get();
112  }
std::unique_ptr< EDProduct > product_
Definition: Group.h:190
void art::Group::write ( std::ostream &  os) const

Definition at line 139 of file Group.cc.

References pid_.

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

cet::exempt_ptr<BranchDescription const> art::Group::branchDescription_ {nullptr}
private
ProductID art::Group::pid_ {}
mutableprivate

Definition at line 192 of file Group.h.

Referenced by Group(), productID(), and write().

cet::exempt_ptr<BranchMapper const> art::Group::ppResolver_ {nullptr}
private

Definition at line 188 of file Group.h.

Referenced by productProvenancePtr(), and setResolvers().

std::unique_ptr<EDProduct> art::Group::product_ {nullptr}
mutableprivate
cet::exempt_ptr<Worker> art::Group::productProducer_ {nullptr}
private

Definition at line 193 of file Group.h.

Referenced by Group().

cet::exempt_ptr<DelayedReader const> art::Group::productResolver_ {nullptr}
private

Definition at line 189 of file Group.h.

Referenced by obtainDesiredProduct(), and setResolvers().

RangeSet art::Group::rangeOfValidity_ {RangeSet::invalid()}
mutableprivate

Definition at line 194 of file Group.h.

Referenced by Group(), obtainDesiredProduct(), and rangeOfValidity().

TypeID art::Group::wrapperType_ {}
private

Definition at line 187 of file Group.h.

Referenced by Group(), producedWrapperType(), and resolveProductIfAvailable().


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