LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
GroupFactory.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_GroupFactory_h
2 #define art_Framework_Principal_GroupFactory_h
3 // vim: set sw=2:
4 
10 #include "canvas_root_io/Utilities/getWrapperTIDs.h"
11 #include "cetlib/exempt_ptr.h"
12 
13 #include <memory>
14 #include <vector>
15 
16 namespace art {
17 
18  class BranchDescription;
19  class EDProduct;
20  class ProductID;
21  class RangeSet;
22 
23  namespace gfactory {
24 
25  std::unique_ptr<Group> make_group(BranchDescription const&,
26  ProductID const&,
27  RangeSet&&);
28 
29  std::unique_ptr<Group> make_group(BranchDescription const&,
30  ProductID const&,
31  RangeSet&&,
32  cet::exempt_ptr<Worker> productProducer);
33 
34  std::unique_ptr<Group> make_group(BranchDescription const&,
35  ProductID const&,
36  RangeSet&&,
37  std::unique_ptr<EDProduct>&&);
38 
39  } // namespace gfactory
40 
41 } // namespace art
42 
43 inline std::unique_ptr<art::Group>
45  ProductID const& pid,
46  RangeSet&& rs)
47 {
48  return detail::make_group(pd, pid, std::move(rs));
49 }
50 
51 inline std::unique_ptr<art::Group>
53  ProductID const& pid,
54  RangeSet&& rs,
55  cet::exempt_ptr<Worker> productProducer)
56 {
57  return detail::make_group(pd, pid, std::move(rs), productProducer);
58 }
59 
60 inline std::unique_ptr<art::Group>
62  ProductID const& pid,
63  RangeSet&& rs,
64  std::unique_ptr<EDProduct>&& edp)
65 {
66  return detail::make_group(pd, pid, std::move(rs), std::move(edp));
67 }
68 
69 // Where all the real work is done.
70 template <typename... ARGS>
71 std::unique_ptr<art::Group>
73 {
74  std::unique_ptr<Group> result;
75  auto tids = art::root::getWrapperTIDs(pd);
76  switch (tids.size()) {
77  case 1ull: // Standard Group.
78  // Can't use std::make_unique<> because Group's constructor is
79  // protected.
80  result = std::unique_ptr<Group>(
81  new Group(pd, std::forward<ARGS>(args)..., tids[0]));
82  break;
83  case 2ull: // Assns<A, B, void>.
84  // Can't use std::make_unique<> because AssnGroup's constructor is
85  // protected.
86  result = std::unique_ptr<AssnsGroup>(
87  new AssnsGroup(pd, std::forward<ARGS>(args)..., tids[0], tids[1]));
88  break;
89  case 4ull: // Assns<A, B, D>.
90  // Can't use std::make_unique<> because AssnGroupWithData's
91  // constructor is protected.
92  result = std::unique_ptr<AssnsGroupWithData>(new AssnsGroupWithData(
93  pd, std::forward<ARGS>(args)..., tids[0], tids[1], tids[2], tids[3]));
94  break;
95  default:
96  // throw internal error exception
97  throw Exception(errors::LogicError, "INTERNAL ART ERROR")
98  << "While making groups, internal function getWrapperTIDs() returned "
99  "an unexpected answer of size "
100  << tids.size() << ".\n";
101  }
102  return result;
103 }
104 #endif /* art_Framework_Principal_GroupFactory_h */
105 
106 // Local Variables:
107 // mode: c++
108 // End:
std::unique_ptr< Group > make_group(BranchDescription const &pd, ARGS &&...args)
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
Definition: Exception.h:66
HLT enums.
std::unique_ptr< Group > make_group(BranchDescription const &, ProductID const &, RangeSet &&)
Definition: GroupFactory.h:44