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