CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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  class EDProduct;
28 
29  template <typename T>
30  class TestHandle : public OrphanHandleBase {
31  public:
32  typedef T element_type;
33 
34  // Default constructed handles are invalid.
35  TestHandle();
36 
37  TestHandle(T const* prod, ProductID const& id);
38 
39  ~TestHandle();
40 
41  T const* product() const;
42  T const* operator->() const; // alias for product()
43  T const& operator*() const;
44 
45  private:
46  };
47 
48  template <class T>
50  { }
51 
52  template <class T>
53  TestHandle<T>::TestHandle(T const* prod, ProductID const& theId) : OrphanHandleBase(prod, theId) {
54  }
55 
56  template <class T>
58 
59  template <class T>
60  T const*
62  return static_cast<T const*>(productStorage());
63  }
64 
65  template <class T>
66  T const*
68  return product();
69  }
70 
71  template <class T>
72  T const&
74  return *product();
75  }
76 
77 }
78 #endif
T const * product() const
Definition: TestHandle.h:61
T const & operator*() const
Definition: TestHandle.h:73
T const * operator->() const
Definition: TestHandle.h:67
tuple prod
Definition: CrabTask.py:87
string const
Definition: compareJSON.py:14