ValidHandle.h
Go to the documentation of this file.
1 #ifndef gallery_ValidHandle_h
2 #define gallery_ValidHandle_h
3 
4 // Should be identical to art::ValidHandle except it is missing
5 // functions, data members, typedefs, and dependences not needed in
6 // gallery.
7 
9 
10 namespace gallery {
11 
13 
14  template <typename T>
15  class ValidHandle {
16  public:
17  using element_type = T;
18  class HandleTag {};
19 
20  ValidHandle() = delete;
21  explicit ValidHandle(T const* prod, art::ProductID) noexcept(false);
22  ValidHandle(ValidHandle const&) = default;
23  ValidHandle& operator=(ValidHandle const&) = default;
24 
25  // pointer behaviors
26  T const& operator*() const noexcept;
27  T const* operator->() const noexcept; // alias for product()
28  T const* product() const noexcept;
29 
30  art::ProductID id() const noexcept;
31 
32  private:
33  T const* prod_;
35  };
36 
37  template <class T>
39  art::ProductID const productID) noexcept(false)
40  : prod_{prod}, productID_{productID}
41  {
42  if (prod == nullptr) {
44  }
45  }
46 
47  template <class T>
48  inline T const& ValidHandle<T>::operator*() const noexcept
49  {
50  return *prod_;
51  }
52 
53  template <class T>
54  inline T const* ValidHandle<T>::operator->() const noexcept
55  {
56  return prod_;
57  }
58 
59  template <class T>
60  inline T const*
62  {
63  return prod_;
64  }
65 
66  template <class T>
67  inline art::ProductID
69  {
70  return productID_;
71  }
72 } // namespace gallery
73 
74 #endif /* gallery_ValidHandle_h */
75 
76 // Local Variables:
77 // mode: c++
78 // End:
art::ProductID id() const noexcept
Definition: ValidHandle.h:68
void throwValidHandleNullPointer()
Definition: ValidHandle.cc:8
T const * operator->() const noexcept
Definition: ValidHandle.h:54
T const & operator*() const noexcept
Definition: ValidHandle.h:48
art::ProductID productID_
Definition: ValidHandle.h:34
ValidHandle & operator=(ValidHandle const &)=default
T const * product() const noexcept
Definition: ValidHandle.h:61