LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
WithProxyAsAuxStructBase.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_WITHPROXYASAUXSTRUCTBASE_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_WITHPROXYASAUXSTRUCTBASE_H
13 
14 // LArSoft libraries
16 
17 // framework libraries
19 
20 // C/C++ standard
21 #include <cstdlib> // std::size_t
22 #include <tuple> // std::tuple_element_t<>, std::get(), ...
23 #include <type_traits> // std::is_convertible<>, std::decay_t<>, ...
24 #include <utility> // std::forward(), std::move(), std::make_index_sequence()...
25 
26 namespace proxy {
27 
28  namespace details {
29 
33 
34  //--------------------------------------------------------------------------
52  template <typename AuxProxy, typename ArgTuple, typename AuxTag = AuxProxy>
54 
55  static_assert(
56  std::is_convertible<std::decay_t<std::tuple_element_t<0U, ArgTuple>>, art::InputTag>(),
57  "The first argument of WithProxyAsAuxStructBase must be art::InputTag.");
58 
60  template <typename CollProxy>
61  using main_t = typename CollProxy::main_element_t;
62 
64  using aux_proxy_t = AuxProxy;
65 
67  using tag = AuxTag;
68 
70  template <typename CollProxy>
72 
73  public:
76  WithProxyAsAuxStructBase(ArgTuple&& args) : args(std::move(args)) {}
77 
79  template <typename CollProxy, typename Event, typename Handle, typename MainArgs>
80  auto createAuxProxyMaker(Event const& event, Handle&& mainHandle, MainArgs const& mainArgs)
81  {
82  return createAuxProxyImpl<CollProxy>(
83  event, std::forward<Handle>(mainHandle), mainArgs, std::make_index_sequence<NArgs>());
84  } // construct()
85 
86  protected:
87  ArgTuple args;
88 
90  static constexpr std::size_t NArgs = std::tuple_size<ArgTuple>();
91 
92  // this method allows unpacking the arguments from the tuple
93  template <typename CollProxy,
94  typename Event,
95  typename Handle,
96  typename MainArgs,
97  std::size_t... I>
98  auto createAuxProxyImpl(Event const& event,
99  Handle&& mainHandle,
100  MainArgs const& mainArgs,
101  std::index_sequence<I...>)
102  {
104  event, mainHandle, mainArgs, std::get<I>(std::forward<ArgTuple>(args))...);
105  }
106 
107  }; // struct WithProxyAsAuxStructBase
108 
111 
112  } // namespace details
113 
114 } // namespace proxy
115 
116 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_WITHPROXYASAUXSTRUCTBASE_H
AuxProxy aux_proxy_t
Type of auxiliary proxy.
static constexpr std::size_t NArgs
Number of arguments stored.
auto createAuxProxyMaker(Event const &event, Handle &&mainHandle, MainArgs const &mainArgs)
Creates the associated data proxy by means of ProxyAsAuxProxyMaker.
ArgTuple args
Argument construction storage as tuple.
STL namespace.
auto createAuxProxyImpl(Event const &event, Handle &&mainHandle, MainArgs const &mainArgs, std::index_sequence< I... >)
typename CollProxy::main_element_t main_t
Type of main data product element from a proxy of type CollProxy.
Creates an auxiliary proxy wrapper for the specified proxy.
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
Infrastructure for a collection proxy as auxiliary data for a proxy.
static auto make(Event const &event, Handle &&, MainArgs const &, art::InputTag const &auxProxyTag, AuxArgs &&...args)
Create a parallel data proxy collection using the specified tag.
Helper to create a proxy as auxiliary data for another proxy.
AuxTag tag
Tag for the associated data (same as the data type itself).
Event finding and building.