DataFormats
Common
interface
Handle.h
Go to the documentation of this file.
1
#ifndef DataFormats_Common_Handle_h
2
#define DataFormats_Common_Handle_h
3
4
/*----------------------------------------------------------------------
5
6
Handle: Non-owning "smart pointer" for reference to Products and
7
their Provenances.
8
9
This is a very preliminary version, and lacks safety features and
10
elegance.
11
12
If the pointed-to Product or Provenance is destroyed, use of the
13
Handle becomes undefined. There is no way to query the Handle to
14
discover if this has happened.
15
16
Handles can have:
17
-- Product and Provenance pointers both null;
18
-- Both pointers valid
19
20
To check validity, one can use the isValid() function.
21
22
If failedToGet() returns true then the requested data is not available
23
If failedToGet() returns false but isValid() is also false then no attempt
24
to get data has occurred
25
26
----------------------------------------------------------------------*/
27
28
#include "
DataFormats/Common/interface/HandleBase.h
"
29
30
namespace
edm
{
31
32
template
<
typename
T>
33
class
Handle
:
public
HandleBase {
34
public
:
35
using
element_type
=
T
;
36
37
// Default constructed handles are invalid.
38
Handle
();
39
40
Handle
(
T
const
*
prod
,
Provenance
const
* prov);
41
42
Handle
(std::shared_ptr<HandleExceptionFactory const>&&);
43
Handle
(
Handle
const
&) =
default
;
44
Handle
&
operator=
(
Handle
&&) =
default
;
45
Handle
&
operator=
(
Handle
const
&) =
default
;
46
47
~Handle
();
48
49
T
const
*
product
()
const
;
50
T
const
*
operator->
()
const
;
// alias for product()
51
T
const
&
operator*
()
const
;
52
53
private
:
54
};
55
56
template
<
class
T>
57
Handle<T>::Handle
() :
HandleBase
() {}
58
59
template
<
class
T>
60
Handle<T>::Handle
(
T
const
*
prod
,
Provenance
const
* prov) :
HandleBase
(
prod
, prov) {}
61
62
template
<
class
T>
63
Handle<T>::Handle
(std::shared_ptr<edm::HandleExceptionFactory const>&& iWhyFailed)
64
:
HandleBase
(
std
::
move
(iWhyFailed)) {}
65
66
template
<
class
T>
67
Handle<T>::~Handle
() {}
68
69
template
<
class
T>
70
T
const
*
Handle<T>::product
()
const
{
71
return
static_cast<T const*>(productStorage());
72
}
73
74
template
<
class
T>
75
T
const
*
Handle<T>::operator->
()
const
{
76
return
product();
77
}
78
79
template
<
class
T>
80
T
const
&
Handle<T>::operator*
()
const
{
81
return
*product();
82
}
83
}
// namespace edm
84
#endif
edm::DetSetVector
Definition:
DetSetVector.h:61
operator*
MatrixMeschach operator*(const MatrixMeschach &mat1, const MatrixMeschach &mat2)
Definition:
MatrixMeschach.cc:117
edm::Handle::product
T const * product() const
Definition:
Handle.h:70
Handle
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::Handle::Handle
Handle()
Definition:
Handle.h:57
edm::HandleBase
Definition:
HandleBase.h:40
edm::Handle::operator=
Handle & operator=(Handle &&)=default
edm::Handle
Definition:
AssociativeIterator.h:50
HandleBase.h
dumpMFGeometry_cfg.prod
prod
Definition:
dumpMFGeometry_cfg.py:24
edm::Handle::~Handle
~Handle()
Definition:
Handle.h:67
edm::Handle::operator->
T const * operator->() const
Definition:
Handle.h:75
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
T
long double T
Definition:
Basic3DVectorLD.h:48
edm::Provenance
Definition:
Provenance.h:34
edm::Handle::operator*
T const & operator*() const
Definition:
Handle.h:80
Generated for CMSSW Reference Manual by
1.8.16