DataFormats
GeometryCommonDetAlgo
interface
DeepCopyPointer.h
Go to the documentation of this file.
1
#ifndef DeepCopyPointer_H
2
#define DeepCopyPointer_H
3
4
#include <algorithm>
5
14
template
<
class
T>
15
class
DeepCopyPointer
{
16
public
:
17
~DeepCopyPointer
() {
delete
theData
; }
18
19
DeepCopyPointer
() :
theData
(0) {}
20
21
DeepCopyPointer
(
T
*
t
) :
theData
(
t
) {}
22
23
DeepCopyPointer
(
const
DeepCopyPointer
&
other
) {
24
if
(
other
.theData)
25
theData
=
new
T
(*
other
);
26
else
27
theData
= 0;
28
}
29
30
DeepCopyPointer
&
operator=
(
const
DeepCopyPointer
&
other
) {
31
if
(
theData
!=
other
.theData) {
32
delete
theData
;
33
if
(
other
.theData)
34
theData
=
new
T
(*
other
);
35
else
36
theData
= 0;
37
}
38
return
*
this
;
39
}
40
41
// straight from http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n2027.html
42
DeepCopyPointer
(
DeepCopyPointer
&&
other
) :
theData
(
other
.
theData
) {
other
.theData = 0; }
43
DeepCopyPointer
&
operator=
(
DeepCopyPointer
&&
other
) {
44
std::swap
(
theData
,
other
.theData);
45
return
*
this
;
46
}
47
50
void
replaceWith
(
T
* otherP) {
51
if
(
theData
!= otherP) {
52
delete
theData
;
53
theData
= otherP;
54
}
55
}
56
57
// assume that the replacement object is of the very same class!
58
// at the moment all the work is done by the client i.e.
59
// call the distructor
60
// new in place
61
// with c++0X a templated method can encasulate it all here...
62
T
*
replaceInplace
() {
return
theData
; }
63
64
T
&
operator*
() {
return
*
theData
; }
65
const
T
&
operator*
()
const
{
return
*
theData
; }
66
67
T
*
operator->
() {
return
theData
; }
68
const
T
*
operator->
()
const
{
return
theData
; }
69
71
operator
bool
()
const
{
return
theData
!= 0; }
72
74
bool
operator==
(
const
T
* otherP)
const
{
return
theData
== otherP; }
75
76
private
:
77
T
*
theData
;
78
};
79
80
#endif // DeepCopyPointer_H
electrons_cff.bool
bool
Definition:
electrons_cff.py:366
DeepCopyPointer::operator*
const T & operator*() const
Definition:
DeepCopyPointer.h:65
DeepCopyPointer::replaceWith
void replaceWith(T *otherP)
Definition:
DeepCopyPointer.h:50
DeepCopyPointer::DeepCopyPointer
DeepCopyPointer(T *t)
Definition:
DeepCopyPointer.h:21
DeepCopyPointer::replaceInplace
T * replaceInplace()
Definition:
DeepCopyPointer.h:62
DeepCopyPointer::operator=
DeepCopyPointer & operator=(const DeepCopyPointer &other)
Definition:
DeepCopyPointer.h:30
std::swap
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
Definition:
DataFrameContainer.h:209
DeepCopyPointer::DeepCopyPointer
DeepCopyPointer(DeepCopyPointer &&other)
Definition:
DeepCopyPointer.h:42
trackingPlots.other
other
Definition:
trackingPlots.py:1460
DeepCopyPointer
Definition:
DeepCopyPointer.h:15
DeepCopyPointer::operator->
T * operator->()
Definition:
DeepCopyPointer.h:67
DeepCopyPointer::operator->
const T * operator->() const
Definition:
DeepCopyPointer.h:68
DeepCopyPointer::operator=
DeepCopyPointer & operator=(DeepCopyPointer &&other)
Definition:
DeepCopyPointer.h:43
DeepCopyPointer::theData
T * theData
Definition:
DeepCopyPointer.h:77
DeepCopyPointer::DeepCopyPointer
DeepCopyPointer(const DeepCopyPointer &other)
Definition:
DeepCopyPointer.h:23
T
long double T
Definition:
Basic3DVectorLD.h:48
DeepCopyPointer::operator==
bool operator==(const T *otherP) const
to allow test like " if (p == &someT) {...}"
Definition:
DeepCopyPointer.h:74
DeepCopyPointer::~DeepCopyPointer
~DeepCopyPointer()
Definition:
DeepCopyPointer.h:17
DeepCopyPointer::DeepCopyPointer
DeepCopyPointer()
Definition:
DeepCopyPointer.h:19
submitPVValidationJobs.t
string t
Definition:
submitPVValidationJobs.py:644
DeepCopyPointer::operator*
T & operator*()
Definition:
DeepCopyPointer.h:64
Generated for CMSSW Reference Manual by
1.8.16