CMS 3D CMS Logo

TestHandle.h
Go to the documentation of this file.
1 #ifndef DataFormats_Common_TestHandle_h
2 #define DataFormats_Common_TestHandle_h
3 
4 /*----------------------------------------------------------------------
5 
6 TestHandle: Non-owning "smart pointer" for reference to EDProducts.
7 
8 
9 This is a very preliminary version, and lacks safety features and
10 elegance.
11 
12 If the pointed-to EDProduct is destroyed, use of the TestHandle
13 becomes undefined. There is no way to query the TestHandle to
14 discover if this has happened.
15 
16 TestHandles can have:
17  -- Product pointer null and id == 0;
18  -- Product pointer valid and id != 0;
19 
20 To check validity, one can use the isValid() function.
21 
22 ----------------------------------------------------------------------*/
23 
25 
26 namespace edm {
27 
28  template <typename T>
29  class TestHandle : public OrphanHandleBase {
30  public:
31  typedef T element_type;
32 
33  // Default constructed handles are invalid.
34  TestHandle();
35 
36  TestHandle(T const* prod, ProductID const& id);
37 
38  ~TestHandle();
39 
40  T const* product() const;
41  T const* operator->() const; // alias for product()
42  T const& operator*() const;
43 
44  private:
45  };
46 
47  template <class T>
49  { }
50 
51  template <class T>
52  TestHandle<T>::TestHandle(T const* prod, ProductID const& theId) : OrphanHandleBase(prod, theId) {
53  }
54 
55  template <class T>
57 
58  template <class T>
59  T const*
61  return static_cast<T const*>(productStorage());
62  }
63 
64  template <class T>
65  T const*
67  return product();
68  }
69 
70  template <class T>
71  T const&
73  return *product();
74  }
75 
76 }
77 #endif
T const * product() const
Definition: TestHandle.h:60
T const & operator*() const
Definition: TestHandle.h:72
T const * operator->() const
Definition: TestHandle.h:66
HLT enums.
long double T
void const * productStorage() const