ProductToken.h
Go to the documentation of this file.
1 #ifndef canvas_Persistency_Provenance_ProductToken_h
2 #define canvas_Persistency_Provenance_ProductToken_h
3 
4 //==============================================================
5 // ProductToken and ViewToken are used to enable efficient product
6 // lookup via a consumes statement given in a module's constructor
7 // (e.g.):
8 //
9 // ProductToken<int> nPotsToken_{consumes<int>(inputTag_)};
10 // ...
11 // auto const& nPotsH = e.getValidHandle(nPotsToken_); => ValidHandle<int>
12 //
13 // The ProductToken and ViewToken classes have only private members:
14 // access is granted via friendship. The intention is that these
15 // classes should be entirely opaque to the user.
16 // ==============================================================
17 
19 
20 #include <string>
21 
22 namespace art {
23 
24  template <typename T>
25  class ProductToken;
26  template <typename T>
27  class ViewToken;
28 
29  // Forward declarations needed for granting friendship
30  class DataViewImpl;
31  class ConsumesCollector;
32 
33  namespace detail {
34  template <typename ProdA, typename ProdB, typename Data>
35  struct safe_input_tag;
36  }
37 
38  template <typename T>
39  class ProductToken {
40  public:
41  using product_type = T;
42 
43  private:
44  static ProductToken<T>
46  {
47  return ProductToken<T>{};
48  }
49  explicit ProductToken() = default;
50  explicit ProductToken(InputTag const& t) : inputTag_{t} {}
51 
52  friend class DataViewImpl;
53  friend class ConsumesCollector;
54  template <typename ProdA, typename ProdB, typename Data>
55  friend struct detail::safe_input_tag;
56 
57  // For now, the representation is just an InputTag. For an
58  // input-tag that includes a specified process name, the
59  // representation could be a ProductID allowing efficient access
60  // to the appropriate data. However, until a mechanism can be
61  // determined for combining the needs of specifying a process name
62  // vs. not, we will use the InputTag.
63 
64  InputTag inputTag_{};
65  };
66 
67  template <typename Element>
68  class ViewToken {
69  public:
70  using element_type = Element;
71 
72  private:
73  static ViewToken<Element>
75  {
76  return ViewToken<Element>{};
77  }
78  explicit ViewToken() = default;
79  explicit ViewToken(InputTag const& t) : inputTag_{t} {}
80 
81  friend class DataViewImpl;
82  friend class ConsumesCollector;
83 
84  // See notes in ProductToken re. the representation.
85  InputTag inputTag_{};
86  };
87 }
88 
89 #endif /* canvas_Persistency_Provenance_ProductToken_h */
90 
91 // Local Variables:
92 // mode: c++
93 // End:
ProductToken(InputTag const &t)
Definition: ProductToken.h:50
static ProductToken< T > invalid()
Definition: ProductToken.h:45
ViewToken(InputTag const &t)
Definition: ProductToken.h:79
Element element_type
Definition: ProductToken.h:70
static ViewToken< Element > invalid()
Definition: ProductToken.h:74
Service to store calibration data products (CDP) in the SQLite3 metadatabase of a file...
Definition: FillParentInfo.h:8
double T
Definition: Xdiff_gwt.C:5