LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
AssnsGroup.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_AssnsGroup_h
2 #define art_Framework_Principal_AssnsGroup_h
3 
6 #include "art/Utilities/fwd.h"
8 #include "cetlib/exempt_ptr.h"
9 
10 namespace art {
11 
12  class BranchDescription;
13  class EDProduct;
14  class ProductID;
15 
16  class AssnsGroup : public Group {
17 
18  // The operative part of the GroupFactory system.
19  template <typename... ARGS>
20  friend std::unique_ptr<Group> gfactory::detail::make_group(
21  BranchDescription const&,
22  ARGS&&... args);
23 
24  public:
25  AssnsGroup() = default;
26 
27  protected:
29  BranchDescription const& pd,
30  ProductID const& pid,
31  RangeSet&& rs,
32  TypeID const& primary_wrapper_type,
33  TypeID const& partner_wrapper_type,
34  std::unique_ptr<EDProduct>&& edp = nullptr,
35  cet::exempt_ptr<Worker> productProducer = cet::exempt_ptr<Worker>())
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  {}
45 
47  ProductID const& pid,
48  RangeSet&& rs,
49  std::unique_ptr<EDProduct>&& edp,
50  TypeID const& primary_wrapper_type,
51  TypeID const& partner_wrapper_type)
52  : AssnsGroup{pd,
53  pid,
54  std::move(rs),
55  primary_wrapper_type,
56  partner_wrapper_type,
57  std::move(edp)}
58  {}
59 
61  ProductID const& pid,
62  RangeSet&& rs,
63  cet::exempt_ptr<Worker> productProducer,
64  TypeID const& primary_wrapper_type,
65  TypeID const& partner_wrapper_type)
66  : AssnsGroup{pd,
67  pid,
68  std::move(rs),
69  primary_wrapper_type,
70  partner_wrapper_type,
71  nullptr,
72  productProducer}
73  {}
74 
75  public:
76  bool
77  isReady() const override
78  {
79  return true;
80  }
81 
82  EDProduct const* getIt() const override;
83 
84  EDProduct const* anyProduct() const override;
85 
86  EDProduct const* uniqueProduct() const override;
87 
88  EDProduct const* uniqueProduct(
89  TypeID const& wanted_wrapper_type) const override;
90 
91  bool resolveProductIfAvailable(TypeID const&) const override;
92 
93  void removeCachedProduct() const override;
94 
95  protected:
96  TypeID const&
98  {
99  return partnerWrapperType_;
100  }
101 
102  bool
103  makePartner(TypeID const& wanted_wrapper_type,
104  std::unique_ptr<EDProduct>& partner) const
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  }
114 
115  private:
117  mutable std::unique_ptr<EDProduct> partnerProduct_;
118  };
119 
120 } // namespace art
121 
122 // Local Variables:
123 // mode: c++
124 // End:
125 #endif /* art_Framework_Principal_AssnsGroup_h */
EDProduct const * uniqueProduct() const override
Definition: AssnsGroup.cc:23
TypeID partnerWrapperType_
Definition: AssnsGroup.h:116
EDProduct const * anyProduct() const override
Definition: AssnsGroup.cc:13
std::unique_ptr< Group > make_group(BranchDescription const &pd, ARGS &&...args)
AssnsGroup(BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, std::unique_ptr< EDProduct > &&edp, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type)
Definition: AssnsGroup.h:46
bool isReady() const override
Definition: AssnsGroup.h:77
std::unique_ptr< EDProduct > makePartner(std::type_info const &wanted_type) const
Definition: EDProduct.h:61
std::unique_ptr< EDProduct > partnerProduct_
Definition: AssnsGroup.h:117
std::type_info const & typeInfo() const
Definition: TypeID.h:114
AssnsGroup()=default
AssnsGroup(BranchDescription const &pd, ProductID const &pid, RangeSet &&rs, cet::exempt_ptr< Worker > productProducer, TypeID const &primary_wrapper_type, TypeID const &partner_wrapper_type)
Definition: AssnsGroup.h:60
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 >())
Definition: AssnsGroup.h:28
EDProduct const * getIt() const override
Definition: AssnsGroup.cc:7
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
bool resolveProductIfAvailable(TypeID const &) const override
Definition: AssnsGroup.cc:44
HLT enums.
TypeID const & partnerWrapperType() const
Definition: AssnsGroup.h:97
void removeCachedProduct() const override
Definition: AssnsGroup.cc:66