LArSoft  v06_85_00
Liquid Argon Software toolkit - http://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 
15 // C/C++ standard
16 #include <tuple> // std::tuple_size(), std::get()
17 #include <utility> // std::forward(), std::move(), std::index_sequence<>...
18 #include <cstdlib> // std::size_t
19 
20 
39 namespace proxy {
40 
41  //----------------------------------------------------------------------------
42  namespace details {
43 
44  //--------------------------------------------------------------------------
64  template <
65  typename Aux,
66  typename Metadata,
67  typename ArgTuple,
68  template <typename CollProxy> class ProxyMaker,
69  typename AuxTag /* = Aux */
70  >
72 
74  template <typename CollProxy>
75  using main_t = typename CollProxy::main_element_t;
76 
78  using aux_t = Aux;
79 
81  using metadata_t = Metadata;
82 
84  using tag = AuxTag;
85 
87  template <typename CollProxy>
88  using proxy_maker_t = ProxyMaker<CollProxy>;
89 
90  public:
91 
93  template <typename CollProxy>
96 
99  WithAssociatedStructBase(ArgTuple&& args): args(std::move(args)) {}
100 
102  template
103  <typename CollProxy, typename Event, typename Handle, typename MainArgs>
105  (Event const& event, Handle&& mainHandle, MainArgs const& mainArgs)
106  {
107  return createAssnProxyMaker<CollProxy>(
108  event, std::forward<Handle>(mainHandle), mainArgs,
109  std::make_index_sequence<NArgs>()
110  );
111  } // construct()
112 
113 
114  protected:
115 
116  ArgTuple args;
117 
119  static constexpr std::size_t NArgs = std::tuple_size<ArgTuple>();
120 
121  // this method allows unpacking the arguments from the tuple
122  template<
123  typename CollProxy, typename Event, typename Handle, typename MainArgs,
124  std::size_t... I
125  >
127  Event const& event, Handle&& mainHandle, MainArgs const& mainArgs,
128  std::index_sequence<I...>
129  )
130  {
132  event, mainHandle, mainArgs,
133  std::get<I>(std::forward<ArgTuple>(args))...
134  );
135  }
136 
137  }; // struct WithAssociatedStructBase<>
138 
139 
140  //--------------------------------------------------------------------------
141 
142  } // namespace details
143 
144 } // namespace proxy
145 
146 
147 #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.
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.