CMS 3D CMS Logo

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