LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
WithAssociatedStructBase.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_WITHASSOCIATEDSTRUCTBASE_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_WITHASSOCIATEDSTRUCTBASE_H
13 
14 // C/C++ standard
15 #include <cstdlib> // std::size_t
16 #include <tuple> // std::tuple_size(), std::get()
17 #include <utility> // std::forward(), std::move(), std::index_sequence<>...
18 
36 namespace proxy {
37 
38  //----------------------------------------------------------------------------
39  namespace details {
40 
41  //--------------------------------------------------------------------------
61  template <typename Aux,
62  typename Metadata,
63  typename ArgTuple,
64  template <typename CollProxy>
65  class ProxyMaker,
66  typename AuxTag /* = Aux */
67  >
69 
71  template <typename CollProxy>
72  using main_t = typename CollProxy::main_element_t;
73 
75  using aux_t = Aux;
76 
78  using metadata_t = Metadata;
79 
81  using tag = AuxTag;
82 
84  template <typename CollProxy>
85  using proxy_maker_t = ProxyMaker<CollProxy>;
86 
87  public:
89  template <typename CollProxy>
91 
94  WithAssociatedStructBase(ArgTuple&& args) : args(std::move(args)) {}
95 
97  template <typename CollProxy, typename Event, typename Handle, typename MainArgs>
98  auto createAuxProxyMaker(Event const& event, Handle&& mainHandle, MainArgs const& mainArgs)
99  {
100  return createAssnProxyMaker<CollProxy>(
101  event, std::forward<Handle>(mainHandle), mainArgs, std::make_index_sequence<NArgs>());
102  } // construct()
103 
104  protected:
105  ArgTuple args;
106 
108  static constexpr std::size_t NArgs = std::tuple_size<ArgTuple>();
109 
110  // this method allows unpacking the arguments from the tuple
111  template <typename CollProxy,
112  typename Event,
113  typename Handle,
114  typename MainArgs,
115  std::size_t... I>
116  auto createAssnProxyMaker(Event const& event,
117  Handle&& mainHandle,
118  MainArgs const& mainArgs,
119  std::index_sequence<I...>)
120  {
122  event, mainHandle, mainArgs, std::get<I>(std::forward<ArgTuple>(args))...);
123  }
124 
125  }; // struct WithAssociatedStructBase<>
126 
127  //--------------------------------------------------------------------------
128 
129  } // namespace details
130 
131 } // namespace proxy
132 
133 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_WITHASSOCIATEDSTRUCTBASE_H
ProxyMaker< CollProxy > proxy_maker_t
Class to create the data proxy associated to a CollProxy.
typename proxy_maker_t< CollProxy >::aux_collection_proxy_t aux_collection_proxy_t
Type of association proxy created for the specified CollProxy.
Helper to create associated data proxy.
std::unique_ptr< InputSource > make(fhicl::ParameterSet const &conf, InputSourceDescription &desc)
STL namespace.
AuxTag tag
Tag for the associated data (same as the data type itself).
ArgTuple args
Argument construction storage as tuple.
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
static constexpr std::size_t NArgs
Number of arguments stored.
Metadata metadata_t
Type of associated metadata.
typename CollProxy::main_element_t main_t
Type of main data product element from a proxy of type CollProxy.
auto createAuxProxyMaker(Event const &event, Handle &&mainHandle, MainArgs const &mainArgs)
Creates the associated data proxy by means of ProxyMaker.
auto createAssnProxyMaker(Event const &event, Handle &&mainHandle, MainArgs const &mainArgs, std::index_sequence< I... >)
Event finding and building.