ATLAS Offline Software
Loading...
Searching...
No Matches
SamplePtr.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5//
6// Distributed under the Boost Software License, Version 1.0.
7// (See accompanying file LICENSE_1_0.txt or copy at
8// http://www.boost.org/LICENSE_1_0.txt)
9
10// Please feel free to contact me (krumnack@iastate.edu) for bug
11// reports, feature suggestions, praise and complaints.
12
13
14//
15// includes
16//
17
19
22
23//
24// method implementations
25//
26
27namespace SH
28{
29 void SamplePtr ::
30 testInvariant () const
31 {
32 }
33
34
35
36 SamplePtr ::
37 SamplePtr ()
38 : m_sample (0)
39 {
40 RCU_NEW_INVARIANT (this);
41 }
42
43
44
45 SamplePtr ::
46 SamplePtr (Sample *val_sample)
47 : m_sample (val_sample)
48 {
49 if (m_sample)
50 m_sample->alloc ();
51
52 RCU_NEW_INVARIANT (this);
53 }
54
55
56
57 SamplePtr ::
58 SamplePtr (std::unique_ptr<Sample> val_sample)
59 : SamplePtr (val_sample.release())
60 {
61 // no invariant used
62 }
63
64
65
66 SamplePtr ::
67 SamplePtr (const SamplePtr& that)
68 : m_sample (that.m_sample)
69 {
70 if (m_sample)
71 m_sample->alloc ();
72
73 RCU_NEW_INVARIANT (this);
74 }
75
76
77
78 SamplePtr ::
79 SamplePtr (SamplePtr&& that)
80 : m_sample (that.m_sample)
81 {
82 that.m_sample = nullptr;
83
84 RCU_NEW_INVARIANT (this);
85 }
86
87
88
89 SamplePtr ::
90 ~SamplePtr ()
91 {
93
94 if (m_sample)
95 m_sample->release ();
96 }
97
98
99
100 SamplePtr& SamplePtr ::
101 operator = (const SamplePtr& that)
102 {
104 RCU_READ_INVARIANT (&that);
105
106 if (that.m_sample)
107 that.m_sample->alloc ();
108 if (m_sample)
109 m_sample->release ();
110 m_sample = that.m_sample;
111 return *this;
112 }
113
114
115
116 SamplePtr& SamplePtr ::
117 operator = (SamplePtr&& that)
118 {
120 RCU_READ_INVARIANT (&that);
121
122 if (m_sample)
123 m_sample->release ();
124 m_sample = that.m_sample;
125 that.m_sample = nullptr;
126 return *this;
127 }
128
129
130
131 bool SamplePtr ::
132 empty () const
133 {
134 RCU_READ_INVARIANT (this);
135 return m_sample == 0;
136 }
137
138
139
140 Sample *SamplePtr ::
141 get ()
142 {
143 RCU_READ_INVARIANT (this);
144 return m_sample;
145 }
146
147
148 const Sample *SamplePtr ::
149 get () const
150 {
151 RCU_READ_INVARIANT (this);
152 return m_sample;
153 }
154
155
156
157 Sample *SamplePtr ::
158 operator -> ()
159 {
160 RCU_READ_INVARIANT (this);
162 return m_sample;
163 }
164
165
166
167 const Sample *SamplePtr ::
168 operator -> () const
169 {
170 RCU_READ_INVARIANT (this);
172 return m_sample;
173 }
174
175
176
177 Sample& SamplePtr ::
178 operator * ()
179 {
180 RCU_READ_INVARIANT (this);
182 return *m_sample;
183 }
184
185
186
187 const Sample& SamplePtr ::
188 operator * () const
189 {
190 RCU_READ_INVARIANT (this);
192 return *m_sample;
193 }
194}
#define RCU_DESTROY_INVARIANT(x)
Definition Assert.h:235
#define RCU_CHANGE_INVARIANT(x)
Definition Assert.h:231
#define RCU_NEW_INVARIANT(x)
Definition Assert.h:233
#define RCU_REQUIRE_SOFT(x)
Definition Assert.h:153
#define RCU_READ_INVARIANT(x)
Definition Assert.h:229
static const Attributes_t empty
SamplePtr()
standard constructor
Definition SamplePtr.cxx:37
Sample * m_sample
the sample contained
Definition SamplePtr.h:186
a base class that manages a set of files belonging to a particular data set and the associated meta-d...
Definition Sample.h:54
void alloc() const
increase the reference count by one
static std::string release
Definition computils.h:50
This module provides a lot of global definitions, forward declarations and includes that are used by ...
Definition PrunDriver.h:15