ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DetectorDescription
GeoModel
GeoModelUtilities
GeoModelUtilities
TransientConstSharedPtr.h
Go to the documentation of this file.
1
2
/*
3
* Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration.
4
*/
5
#ifndef GEOMODELUTILITIES_TRANSIENTCONSTSHAREDPTR_H
6
#define GEOMODELUTILITIES_TRANSIENTCONSTSHAREDPTR_H
7
8
#include <memory>
9
namespace
GeoModel
{
13
template
<
typename
Obj>
class
TransientConstSharedPtr
{
14
public
:
15
template
<
typename
DerivType>
friend
class
GeoModel::TransientConstSharedPtr
;
17
using
element_type
= Obj;
19
Obj*
get
() {
return
m_ptr
.get(); }
20
Obj*
operator->
() {
return
get
(); }
22
const
Obj*
get
()
const
{
return
m_ptr
.get(); }
23
const
Obj*
operator->
()
const
{
return
get
(); }
25
const
Obj&
operator*
()
const
{
return
*
m_ptr
; }
26
Obj&
operator*
() {
return
*
m_ptr
; }
27
29
template
<
typename
DerivType>
30
TransientConstSharedPtr
(std::unique_ptr<DerivType> ptr)
31
requires
(std::is_base_of_v<Obj, DerivType>):
m_ptr
{
std
::move(ptr)} {}
32
33
template
<
typename
DerivType>
34
TransientConstSharedPtr
(std::shared_ptr<DerivType> ptr)
35
requires
(std::is_base_of_v<Obj, DerivType>) :
m_ptr
{
std
::move(ptr)} {}
36
37
TransientConstSharedPtr
(Obj* ptr) :
m_ptr
{ptr} {}
38
40
TransientConstSharedPtr
() =
default
;
42
template
<
typename
DerivType>
43
TransientConstSharedPtr
(
const
TransientConstSharedPtr<DerivType>
& other)
44
requires
(std::is_base_of_v<Obj, DerivType>) :
45
m_ptr
{other.
m_ptr
}{}
46
47
template
<
typename
DerivType>
48
TransientConstSharedPtr
(
TransientConstSharedPtr<DerivType>
&& other)
49
requires
(std::is_base_of_v<Obj, DerivType>) :
50
m_ptr
{
std
::move(other.
m_ptr
)}{}
51
53
template
<
typename
DerivType>
54
TransientConstSharedPtr
&
operator=
(
const
TransientConstSharedPtr<DerivType>
& other)
55
requires
(std::is_base_of_v<Obj, DerivType>) {
56
if
(&other !=
this
) {
57
m_ptr
= other.m_ptr;
58
}
59
return
*
this
;
60
}
61
template
<
typename
DerivType>
62
TransientConstSharedPtr
&
operator=
(
const
std::shared_ptr<DerivType>& other)
63
requires
(std::is_base_of_v<Obj, DerivType>) {
64
m_ptr
= other.m_ptr;
65
return
*
this
;
66
}
67
68
template
<
typename
DerivType>
69
TransientConstSharedPtr
&
operator=
(
TransientConstSharedPtr<DerivType>
&& other)
70
requires
(std::is_base_of_v<Obj, DerivType>) {
71
m_ptr
= std::move(other.m_ptr);
72
return
*
this
;
73
}
74
template
<
typename
DerivType>
75
TransientConstSharedPtr
&
operator=
(std::unique_ptr<DerivType>&& other)
76
requires
(std::is_base_of_v<Obj, DerivType>) {
77
m_ptr
= std::move(other);
78
return
*
this
;
79
}
80
template
<
typename
DerivType>
81
TransientConstSharedPtr
&
operator=
(std::shared_ptr<DerivType>&& other)
82
requires
(std::is_base_of_v<Obj, DerivType>) {
83
m_ptr
= std::move(other);
84
return
*
this
;
85
}
86
87
template
<
typename
DerivType>
88
void
reset
(std::unique_ptr<DerivType> newObj)
89
requires
(std::is_base_of_v<Obj, DerivType>) {
90
m_ptr
= std::move(newObj);
91
}
92
template
<
typename
DerivType>
93
void
reset
(std::shared_ptr<DerivType>&& newObj)
94
requires
(std::is_base_of_v<Obj, DerivType>) {
95
m_ptr
= std::move(newObj);
96
}
97
template
<
typename
DerivType>
98
void
reset
(
const
std::shared_ptr<DerivType>& newObj)
99
requires
(std::is_base_of_v<Obj, DerivType>) {
100
m_ptr
= std::move(newObj);
101
}
102
void
reset
() {
m_ptr
.reset(); }
104
std::shared_ptr<const Obj>
release
() {
return
std::move(
m_ptr
); }
106
operator
bool()
const
{
return
m_ptr
.get() !=
nullptr
; }
107
bool
operator!
()
const
{
return
!
m_ptr
; }
109
size_t
use_count
()
const
{
return
m_ptr
.use_count(); }
110
112
bool
operator<
(
const
TransientConstSharedPtr
& other)
const
{
113
return
get
() < other.get();
114
}
115
116
bool
operator ==
(
const
TransientConstSharedPtr
& other)
const
{
117
return
other.get() ==
get
();
118
}
119
bool
operator !=
(
const
TransientConstSharedPtr
& other)
const
{
120
return
other.get() !=
get
();
121
}
122
123
private
:
124
std::shared_ptr<Obj>
m_ptr
{};
125
};
126
}
// namespace GeoModel
127
#endif
GeoModel::TransientConstSharedPtr
The TransientConstSharedPtr allows non-const access if the pointer itself is non-const but in the con...
Definition
TransientConstSharedPtr.h:13
GeoModel::TransientConstSharedPtr::operator->
const Obj * operator->() const
Definition
TransientConstSharedPtr.h:23
GeoModel::TransientConstSharedPtr::operator<
bool operator<(const TransientConstSharedPtr &other) const
Smaller operator to insert the pointer into sets.
Definition
TransientConstSharedPtr.h:112
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
TransientConstSharedPtr(Obj *ptr)
Constructor from raw ptr.
Definition
TransientConstSharedPtr.h:37
GeoModel::TransientConstSharedPtr::operator=
TransientConstSharedPtr & operator=(const std::shared_ptr< DerivType > &other)
Definition
TransientConstSharedPtr.h:62
GeoModel::TransientConstSharedPtr::operator!
bool operator!() const
Definition
TransientConstSharedPtr.h:107
GeoModel::TransientConstSharedPtr::operator!=
bool operator!=(const TransientConstSharedPtr &other) const
Definition
TransientConstSharedPtr.h:119
GeoModel::TransientConstSharedPtr< DeltaMap >::m_ptr
std::shared_ptr< DeltaMap > m_ptr
Definition
TransientConstSharedPtr.h:124
GeoModel::TransientConstSharedPtr::operator=
TransientConstSharedPtr & operator=(const TransientConstSharedPtr< DerivType > &other)
Assignment operator.
Definition
TransientConstSharedPtr.h:54
GeoModel::TransientConstSharedPtr::reset
void reset()
Definition
TransientConstSharedPtr.h:102
GeoModel::TransientConstSharedPtr::reset
void reset(std::unique_ptr< DerivType > newObj)
Overload the pointer.
Definition
TransientConstSharedPtr.h:88
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
friend class GeoModel::TransientConstSharedPtr
Definition
TransientConstSharedPtr.h:15
GeoModel::TransientConstSharedPtr::operator*
Obj & operator*()
Definition
TransientConstSharedPtr.h:26
GeoModel::TransientConstSharedPtr< DeltaMap >::element_type
DeltaMap element_type
Definition
TransientConstSharedPtr.h:17
GeoModel::TransientConstSharedPtr::get
Obj * get()
Get (non-const) access to the underlying object.
Definition
TransientConstSharedPtr.h:19
GeoModel::TransientConstSharedPtr::reset
void reset(const std::shared_ptr< DerivType > &newObj)
Definition
TransientConstSharedPtr.h:98
GeoModel::TransientConstSharedPtr::operator=
TransientConstSharedPtr & operator=(TransientConstSharedPtr< DerivType > &&other)
Move assignment operator.
Definition
TransientConstSharedPtr.h:69
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
TransientConstSharedPtr()=default
Standard constructor.
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
TransientConstSharedPtr(std::unique_ptr< DerivType > ptr)
Constructor from a unique_ptr.
Definition
TransientConstSharedPtr.h:30
GeoModel::TransientConstSharedPtr::operator*
const Obj & operator*() const
Dereference operator.
Definition
TransientConstSharedPtr.h:25
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
TransientConstSharedPtr(TransientConstSharedPtr< DerivType > &&other)
Standard move constructor.
Definition
TransientConstSharedPtr.h:48
GeoModel::TransientConstSharedPtr::operator==
bool operator==(const TransientConstSharedPtr &other) const
Equal operator.
Definition
TransientConstSharedPtr.h:116
GeoModel::TransientConstSharedPtr::use_count
size_t use_count() const
How many clients does the pointer have.
Definition
TransientConstSharedPtr.h:109
GeoModel::TransientConstSharedPtr::operator->
Obj * operator->()
Definition
TransientConstSharedPtr.h:20
GeoModel::TransientConstSharedPtr::operator=
TransientConstSharedPtr & operator=(std::shared_ptr< DerivType > &&other)
Definition
TransientConstSharedPtr.h:81
GeoModel::TransientConstSharedPtr::release
std::shared_ptr< const Obj > release()
Release the memory.
Definition
TransientConstSharedPtr.h:104
GeoModel::TransientConstSharedPtr::operator=
TransientConstSharedPtr & operator=(std::unique_ptr< DerivType > &&other)
Definition
TransientConstSharedPtr.h:75
GeoModel::TransientConstSharedPtr::get
const Obj * get() const
Get const access to the underlying object.
Definition
TransientConstSharedPtr.h:22
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
TransientConstSharedPtr(std::shared_ptr< DerivType > ptr)
Constructor from shared_ptr.
Definition
TransientConstSharedPtr.h:34
GeoModel::TransientConstSharedPtr::reset
void reset(std::shared_ptr< DerivType > &&newObj)
Definition
TransientConstSharedPtr.h:93
GeoModel::TransientConstSharedPtr::TransientConstSharedPtr
TransientConstSharedPtr(const TransientConstSharedPtr< DerivType > &other)
Delete the copy constructor if the object is const.
Definition
TransientConstSharedPtr.h:43
GeoModel
Definition
IGeoDbTagSvc.h:16
std
STL namespace.
Generated on
for ATLAS Offline Software by
1.17.0