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
|
#ifndef DataFormats_Common_interface_OrphanHandle_h
#define DataFormats_Common_interface_OrphanHandle_h
/*----------------------------------------------------------------------
OrphanHandle: 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 OrphanHandle
becomes undefined. There is no way to query the OrphanHandle to
discover if this has happened.
OrphanHandles 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 OrphanHandle : public OrphanHandleBase {
public:
using element_type = T;
// Default constructed handles are invalid.
OrphanHandle();
OrphanHandle(T const* prod, ProductID const& id);
T const* product() const;
T const* operator->() const; // alias for product()
T const& operator*() const;
};
template <class T>
OrphanHandle<T>::OrphanHandle() : OrphanHandleBase() {}
template <class T>
OrphanHandle<T>::OrphanHandle(T const* prod, ProductID const& theId) : OrphanHandleBase(prod, theId) {}
template <class T>
T const* OrphanHandle<T>::product() const {
return static_cast<T const*>(productStorage());
}
template <class T>
T const* OrphanHandle<T>::operator->() const {
return product();
}
template <class T>
T const& OrphanHandle<T>::operator*() const {
return *product();
}
} // namespace edm
#endif // DataFormats_Common_interface_OrphanHandle_h
|