Panda3D
Loading...
Searching...
No Matches
threadSafePointerTo.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file threadSafePointerTo.I
10 * @author drose
11 * @date 2006-04-28
12 */
13
14/**
15 *
16 */
17template<class T>
20}
21
22/**
23 *
24 */
25template<class T>
29{
30}
31
32/**
33 *
34 */
35template<class T>
38}
39
40/**
41 *
42 */
43template<class T>
44INLINE typename ThreadSafePointerTo<T>::To &ThreadSafePointerTo<T>::
45operator *() const {
46 return *((To *)AtomicAdjust::get_ptr(this->_void_ptr));
47}
48
49/**
50 *
51 */
52template<class T>
53INLINE typename ThreadSafePointerTo<T>::To *ThreadSafePointerTo<T>::
54operator -> () const {
55 return (To *)AtomicAdjust::get_ptr(this->_void_ptr);
56}
57
58/**
59 * We also have the typecast operator to automatically convert
60 * ThreadSafePointerTo's to the required kind of actual pointer. This
61 * introduces ambiguities which the compiler will resolve one way or the
62 * other, but we don't care which way it goes because either will be correct.
63 */
64template<class T>
66operator T * () const {
67 return (To *)AtomicAdjust::get_ptr(this->_void_ptr);
68}
69
70/**
71 * Returns an ordinary pointer instead of a ThreadSafePointerTo. Useful to
72 * work around compiler problems, particularly for implicit upcasts.
73 */
74template<class T>
75INLINE typename ThreadSafePointerTo<T>::To *ThreadSafePointerTo<T>::
76p() const {
77 return (To *)AtomicAdjust::get_ptr(this->_void_ptr);
78}
79
80/**
81 *
82 */
83template<class T>
85operator = (To *ptr) {
86 this->reassign(ptr);
87 return *this;
88}
89
90/**
91 *
92 */
93template<class T>
96 this->reassign((const ThreadSafePointerToBase<T> &)copy);
97 return *this;
98}
99
100/**
101 *
102 */
103template<class T>
105ThreadSafeConstPointerTo(const typename ThreadSafeConstPointerTo<T>::To *ptr) :
106 ThreadSafePointerToBase<T>((typename ThreadSafeConstPointerTo<T>::To *)ptr)
107{
108}
109
110/**
111 *
112 */
113template<class T>
117{
118}
119
120/**
121 *
122 */
123template<class T>
126}
127
128/**
129 *
130 */
131template<class T>
135{
136}
137
138/**
139 *
140 */
141template<class T>
142INLINE const typename ThreadSafeConstPointerTo<T>::To &ThreadSafeConstPointerTo<T>::
143operator *() const {
144 return *((To *)AtomicAdjust::get_ptr(this->_void_ptr));
145}
146
147/**
148 *
149 */
150template<class T>
151INLINE const typename ThreadSafeConstPointerTo<T>::To *ThreadSafeConstPointerTo<T>::
152operator -> () const {
153 return (To *)AtomicAdjust::get_ptr(this->_void_ptr);
154}
155
156/**
157 * We also have the typecast operator to automatically convert
158 * ThreadSafeConstPointerTo's to the required kind of actual pointer. This
159 * introduces ambiguities which the compiler will resolve one way or the
160 * other, but we don't care which way it goes because either will be correct.
161 */
162
163template<class T>
165operator const T * () const {
166 return (To *)AtomicAdjust::get_ptr(this->_void_ptr);
167}
168
169/**
170 * Returns an ordinary pointer instead of a ThreadSafeConstPointerTo. Useful
171 * to work around compiler problems, particularly for implicit upcasts.
172 */
173template<class T>
174INLINE const typename ThreadSafeConstPointerTo<T>::To *ThreadSafeConstPointerTo<T>::
175p() const {
176 return (To *)AtomicAdjust::get_ptr(this->_void_ptr);
177}
178
179/**
180 *
181 */
182template<class T>
184operator = (const To *ptr) {
185 this->reassign((To *)ptr);
186 return *this;
187}
188
189/**
190 *
191 */
192template<class T>
195 this->reassign((const ThreadSafePointerToBase<T> &)copy);
196 return *this;
197}
198
199/**
200 *
201 */
202template<class T>
205 this->reassign((const ThreadSafePointerToBase<T> &)copy);
206 return *this;
207}
static Pointer get_ptr(const Pointer &var)
Atomically retrieves the snapshot value of the indicated variable.
const To * p() const
Returns an ordinary pointer instead of a ThreadSafeConstPointerTo.
This is the base class for ThreadSafePointerTo and ThreadSafeConstPointerTo.
This works exactly like PointerTo, except that the object is designed to be thread-safe: it is genera...
To * p() const
Returns an ordinary pointer instead of a ThreadSafePointerTo.