LArSoft  v07_13_02
Liquid Argon Software toolkit - http://larsoft.org/
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 Consumer;
32 
33  namespace detail {
34  template <typename T>
36  template <typename T>
38  }
39 
40  template <typename T>
41  class ProductToken {
42  public:
43  using product_type = T;
44 
45  private:
46  static ProductToken<T>
48  {
49  return ProductToken<T>{};
50  }
51  explicit ProductToken() = default;
52  explicit ProductToken(InputTag const& t) : inputTag_{t} {}
53 
54  friend class DataViewImpl;
55  friend class Consumer;
56  friend InputTag detail::input_tag<>(ProductToken const&);
57 
58  // For now, the representation is just an InputTag. For an
59  // input-tag that includes a specified process name, the
60  // representation could be a ProductID allowing efficient access
61  // to the appropriate data. However, until a mechanism can be
62  // determined for combining the needs of specifying a process name
63  // vs. not, we will use the InputTag.
64 
65  InputTag inputTag_{};
66  };
67 
68  template <typename Element>
69  class ViewToken {
70  public:
71  using element_type = Element;
72 
73  private:
74  static ViewToken<Element>
76  {
77  return ViewToken<Element>{};
78  }
79  explicit ViewToken() = default;
80  explicit ViewToken(InputTag const& t) : inputTag_{t} {}
81 
82  friend class DataViewImpl;
83  friend class Consumer;
84  friend InputTag detail::input_tag<>(ViewToken const&);
85 
86  // See notes in ProductToken re. the representation.
87  InputTag inputTag_{};
88  };
89 }
90 
91 #endif /* canvas_Persistency_Provenance_ProductToken_h */
92 
93 // Local Variables:
94 // mode: c++
95 // End:
InputTag input_tag(InputTag const &tag)
Definition: IPRHelper.h:21
ProductToken(InputTag const &t)
Definition: ProductToken.h:52
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ViewToken(InputTag const &t)
Definition: ProductToken.h:80
Element element_type
Definition: ProductToken.h:71
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
HLT enums.