LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
OneTo01DataProxyMaker.h
Go to the documentation of this file.
1 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_ONETO01DATAPROXYMAKER_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_ONETO01DATAPROXYMAKER_H
13 
14 // LArSoft libraries
17 
18 // framework libraries
20 
21 // C/C++ standard libraries
22 #include <utility> // std::forward()
23 #include <type_traits> // std::is_convertible<>
24 
25 
26 namespace proxy {
27 
28  // --- BEGIN LArSoftProxiesAssociatedData ------------------------------------
31 
32  //----------------------------------------------------------------------------
33  //--- one-to-(zero/one) associations
34  //----------------------------------------------------------------------------
49  template <
50  typename Main, typename Aux, typename Metadata = void,
51  typename AuxTag = Aux
52  >
54 
56  using data_tag = AuxTag;
57 
59  using main_element_t = Main;
60 
62  using aux_element_t = Aux;
63 
65  using metadata_t = Metadata;
66 
70 
73 
92  template<typename Event, typename Handle, typename MainArgs>
93  static auto make
94  (Event const& event, Handle&& mainHandle, MainArgs const& mainArgs)
95  {
96  return createFromTag
97  (event, std::forward<Handle>(mainHandle), art::InputTag(mainArgs));
98  }
99 
114  template<typename Event, typename Handle, typename MainArgs>
115  static auto make(
116  Event const& event, Handle&& mainHandle,
117  MainArgs const&, art::InputTag const& auxInputTag
118  )
119  {
120  return
121  createFromTag(event, std::forward<Handle>(mainHandle), auxInputTag);
122  }
123 
137  template<typename Event, typename Handle, typename MainArgs, typename Assns>
138  static auto make
139  (Event const&, Handle&& handle, MainArgs const&, Assns const& assns)
140  {
141  static_assert(
142  std::is_convertible<typename Assns::right_t, aux_element_t>(),
143  "Improper right type for one-to-(zero-or-one) association."
144  );
145  return makeOneTo01dataFrom<data_tag>(assns, handle->size());
146  }
147 
148 
149  private:
150  template<typename Event, typename Handle>
151  static auto createFromTag(
152  Event const& event, Handle&& mainHandle, art::InputTag const& auxInputTag
153  )
154  {
155  return makeOneTo01dataFrom
157  (event, auxInputTag, mainHandle->size());
158  }
159 
160  }; // struct OneTo01DataProxyMakerBase<>
161 
162 
163  //--------------------------------------------------------------------------
197  template <
198  typename Main, typename Aux, typename Metadata,
199  typename CollProxy, typename Tag = Aux
200  >
202  : public OneTo01DataProxyMakerBase<Main, Aux, Metadata, Tag>
203  {
204  //
205  // Note that this implementation is here only to document how to derive
206  // a OneTo01DataProxyMaker (specialization) from
207  // OneTo01DataProxyMakerBase. It's just mirroring the base class.
208  //
210 
211  public:
212 
214  using typename base_t::main_element_t;
215 
217  using typename base_t::aux_element_t;
218 
220  using typename base_t::metadata_t;
221 
223  using typename base_t::aux_collection_proxy_t;
224 
226  using typename base_t::assns_t;
227 
248  template
249  <typename Event, typename Handle, typename MainArgs, typename... Args>
250  static auto make(
251  Event const& event, Handle&& mainHandle, MainArgs const& margs,
252  Args&&... args
253  )
254  {
255  return base_t::make(
256  event,
257  std::forward<Handle>(mainHandle),
258  margs,
259  std::forward<Args>(args)...
260  );
261  }
262 
263  }; // struct OneTo01DataProxyMaker<>
264 
265 
267  // --- END LArSoftProxiesAssociatedData --------------------------------------
268 
269 
270  namespace details {
271 
272  //--------------------------------------------------------------------------
273  //--- Stuff for one-to-(zero or one) associated data
274  //--------------------------------------------------------------------------
275  template <
276  typename Aux, typename Metadata /* = void */,
277  typename AuxTag /* = Aux */
278  >
280  template <typename CollProxy>
282  <typename CollProxy::main_element_t, Aux, Metadata, CollProxy, AuxTag>;
283  };
284 
285  } // namespace details
286 
287 
288 } // namespace proxy
289 
290 
291 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_ONETO01DATAPROXYMAKER_H
static auto make(Event const &event, Handle &&mainHandle, MainArgs const &mainArgs)
Create a association proxy collection using main collection tag.
auto makeOneTo01dataFrom(Assns const &assns, std::size_t minSize=0)
Processes and returns an one-to-(zero/one) associated data object.
art::Assns< main_t, aux_t > assns_t
Type of the source association.
Definition: OneTo01Data.h:97
static auto createFromTag(Event const &event, Handle &&mainHandle, art::InputTag const &auxInputTag)
Auxiliary data from one-to-(zero-or-one) sequential association.
Aux aux_element_t
Type of the auxiliary associated datum ("right").
static auto make(Event const &event, Handle &&mainHandle, MainArgs const &, art::InputTag const &auxInputTag)
Create a association proxy collection using the specified tag.
Creates an one-to-(zero-or-one) wrapper for the specified types.
Object for one-to-zero/or/one associated data interface.
Definition: OneTo01Data.h:71
static auto make(Event const &event, Handle &&mainHandle, MainArgs const &margs, Args &&...args)
Create a association proxy collection using main collection tag.
Encloses LArSoft data product proxy objects and utilities.See this doxygen module for an introduction...
typename aux_collection_proxy_t::assns_t assns_t
Type of art association being used as input.
Helper functions to create data structures associated to a proxy.
Tag data_tag
Tag labelling the associated data we are going to produce.
Creates an one-to-(zero-or-one) wrapper for the specified types.
Event finding and building.