All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
withCollectionProxy.h
Go to the documentation of this file.
1 /**
2  * @file lardata/RecoBaseProxy/ProxyBase/withCollectionProxy.h
3  * @brief Creation of a collection proxy as auxiliary data for another proxy.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  * @date July 27, 2017
6  * @see lardata/RecoBaseProxy/ProxyBase.h
7  *
8  * This library is header-only.
9  */
10 
11 #ifndef LARDATA_RECOBASEPROXY_PROXYBASE_WITHCOLLECTIONPROXY_H
12 #define LARDATA_RECOBASEPROXY_PROXYBASE_WITHCOLLECTIONPROXY_H
13 
14 // LArSoft libraries
16 
17 // framework libraries
18 #include "canvas/Utilities/InputTag.h"
19 
20 // C/C++ standard
21 #include <tuple> // also std::tuple_element_t<>
22 #include <utility> // std::forward(), std::move()
23 #include <type_traits> // std::is_convertible<>, std::decay_t<>, ...
24 
25 
26 namespace proxy {
27 
28  // --- BEGIN Collection proxy infrastructure ---------------------------------
29  /// @addtogroup LArSoftProxyCollections
30  /// @{
31 
32  //----------------------------------------------------------------------------
33  /// The same as `withCollectionProxy()`, but it also specified a tag.
34  /// @bug Broken in many ways. Do not use.
35  template <typename AuxProxy, typename AuxTag, typename... Args>
36  auto withCollectionProxyAs(Args&&... args)
37  {
38  using ArgTuple_t = std::tuple<Args&&...>;
39  static_assert(
40  std::is_convertible
41  <std::decay_t<std::tuple_element_t<0U, ArgTuple_t>>, art::InputTag>(),
42  "The first argument of withCollectionProxyAs() must be art::InputTag."
43  );
44  ArgTuple_t argsTuple(std::forward<Args>(args)...);
46  (std::move(argsTuple));
47  } // withCollectionProxyAs()
48 
49  //----------------------------------------------------------------------------
50  /**
51  * @brief Helper function to merge an auxiliary proxy into the proxy.
52  * @tparam AuxProxy type (proxy tag) of auxiliary collection proxy requested
53  * @tparam Args types of constructor arguments for parallel data proxy
54  * @param args constructor arguments for the parallel data collection proxy
55  * @return a temporary object that `getCollection()` knows to handle
56  * @bug Broken in many ways. Do not use.
57  *
58  * This function is meant to convey to `getCollection()` function the request
59  * for merging a collection proxy to carry auxiliary data structured as
60  * another collection proxy, parallel to the main collection.
61  * The function also bridges the information required to create a proxy to
62  * that auxiliary data.
63  *
64  * This data will be tagged with the type `AuxProxy`. To use a different type
65  * as tag, use `withCollectionProxyAs()` instead, specifying the tag as second
66  * template argument.
67  *
68  *
69  * Customization of the auxiliary collection proxy
70  * ================================================
71  *
72  * The customization of auxiliary collection proxy happens in a fashion
73  * similar to the customization presented in `withParallelData()`.
74  * The customization point here is `ProxyAsAuxProxyMaker`.
75  */
76  template <typename AuxProxy, typename... Args>
77  auto withCollectionProxy(Args&&... args)
78  {
79  return
80  withCollectionProxyAs<AuxProxy, AuxProxy>(std::forward<Args>(args)...);
81  }
82 
83 
84  /// @}
85  // --- END Collection proxy infrastructure -----------------------------------
86 
87 } // namespace proxy
88 
89 
90 #endif // LARDATA_RECOBASEPROXY_PROXYBASE_WITHCOLLECTIONPROXY_H
Infrastructure for a collection proxy as auxiliary data for a proxy.
auto withCollectionProxyAs(Args &&...args)
auto withCollectionProxy(Args &&...args)
Helper function to merge an auxiliary proxy into the proxy.
Helper to create a proxy as auxiliary data for another proxy.