Panda3D
 All Classes Functions Variables Enumerations
nodePointerTo.I
1 // Filename: nodePointerTo.I
2 // Created by: drose (07May05)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 #ifndef CPPPARSER
17 ////////////////////////////////////////////////////////////////////
18 // Function: NodePointerTo::Constructor
19 // Access: Public
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 template<class T>
23 INLINE NodePointerTo<T>::
24 NodePointerTo(To *ptr) : NodePointerToBase<T>(ptr) {
25 }
26 #endif // CPPPARSER
27 
28 #ifndef CPPPARSER
29 ////////////////////////////////////////////////////////////////////
30 // Function: NodePointerTo::Copy Constructor
31 // Access: Public
32 // Description:
33 ////////////////////////////////////////////////////////////////////
34 template<class T>
35 INLINE NodePointerTo<T>::
36 NodePointerTo(const NodePointerTo<T> &copy) :
37  NodePointerToBase<T>((const NodePointerToBase<T> &)copy)
38 {
39 }
40 #endif // CPPPARSER
41 
42 #ifndef CPPPARSER
43 ////////////////////////////////////////////////////////////////////
44 // Function: NodePointerTo::Destructor
45 // Access: Public
46 // Description:
47 ////////////////////////////////////////////////////////////////////
48 template<class T>
49 INLINE NodePointerTo<T>::
51 }
52 #endif // CPPPARSER
53 
54 #ifdef USE_MOVE_SEMANTICS
55 #ifndef CPPPARSER
56 ////////////////////////////////////////////////////////////////////
57 // Function: NodePointerTo::Move Constructor
58 // Access: Public
59 // Description:
60 ////////////////////////////////////////////////////////////////////
61 template<class T>
62 INLINE NodePointerTo<T>::
63 NodePointerTo(NodePointerTo<T> &&from) NOEXCEPT :
64  NodePointerToBase<T>((NodePointerToBase<T> &&)from)
65 {
66 }
67 #endif // CPPPARSER
68 
69 #ifndef CPPPARSER
70 ////////////////////////////////////////////////////////////////////
71 // Function: NodePointerTo::Move Assignment Operator
72 // Access: Public
73 // Description:
74 ////////////////////////////////////////////////////////////////////
75 template<class T>
77 operator = (NodePointerTo<T> &&from) NOEXCEPT {
78  this->reassign(move(from));
79  return *this;
80 }
81 #endif // CPPPARSER
82 #endif // USE_MOVE_SEMANTICS
83 
84 #ifndef CPPPARSER
85 ////////////////////////////////////////////////////////////////////
86 // Function: NodePointerTo::Dereference operator
87 // Access: Public
88 // Description:
89 ////////////////////////////////////////////////////////////////////
90 template<class T>
91 INLINE TYPENAME NodePointerTo<T>::To &NodePointerTo<T>::
92 operator *() const {
93  return *((To *)(this->_void_ptr));
94 }
95 #endif // CPPPARSER
96 
97 #ifndef CPPPARSER
98 ////////////////////////////////////////////////////////////////////
99 // Function: NodePointerTo::Member access operator
100 // Access: Public
101 // Description:
102 ////////////////////////////////////////////////////////////////////
103 template<class T>
104 INLINE TYPENAME NodePointerTo<T>::To *NodePointerTo<T>::
105 operator -> () const {
106  return (To *)(this->_void_ptr);
107 }
108 #endif // CPPPARSER
109 
110 #ifndef CPPPARSER
111 ////////////////////////////////////////////////////////////////////
112 // Function: NodePointerTo::Typecast operator
113 // Access: Public
114 // Description: We also have the typecast operator to automatically
115 // convert NodePointerTo's to the required kind of actual
116 // pointer. This introduces ambiguities which the
117 // compiler will resolve one way or the other, but we
118 // don't care which way it goes because either will be
119 // correct.
120 ////////////////////////////////////////////////////////////////////
121 template<class T>
122 INLINE NodePointerTo<T>::
123 operator T *() const {
124  return (To *)(this->_void_ptr);
125 }
126 #endif // CPPPARSER
127 
128 #ifndef CPPPARSER
129 ////////////////////////////////////////////////////////////////////
130 // Function: NodePointerTo::p
131 // Access: Public
132 // Description: Returns an ordinary pointer instead of a NodePointerTo.
133 // Useful to work around compiler problems, particularly
134 // for implicit upcasts.
135 ////////////////////////////////////////////////////////////////////
136 template<class T>
137 INLINE TYPENAME NodePointerTo<T>::To *NodePointerTo<T>::
138 p() const {
139  return (To *)(this->_void_ptr);
140 }
141 #endif // CPPPARSER
142 
143 #ifndef CPPPARSER
144 ////////////////////////////////////////////////////////////////////
145 // Function: NodePointerTo::Assignment operator
146 // Access: Public
147 // Description:
148 ////////////////////////////////////////////////////////////////////
149 template<class T>
151 operator = (To *ptr) {
152  this->reassign(ptr);
153  return *this;
154 }
155 #endif // CPPPARSER
156 
157 #ifndef CPPPARSER
158 ////////////////////////////////////////////////////////////////////
159 // Function: NodePointerTo::Assignment operator
160 // Access: Public
161 // Description:
162 ////////////////////////////////////////////////////////////////////
163 template<class T>
165 operator = (const NodePointerTo<T> &copy) {
166  this->reassign((const NodePointerToBase<T> &)copy);
167  return *this;
168 }
169 #endif // CPPPARSER
170 
171 #ifndef CPPPARSER
172 ////////////////////////////////////////////////////////////////////
173 // Function: NodeConstPointerTo::Constructor
174 // Access: Public
175 // Description:
176 ////////////////////////////////////////////////////////////////////
177 template<class T>
179 NodeConstPointerTo(const TYPENAME NodeConstPointerTo<T>::To *ptr) :
180  NodePointerToBase<T>((TYPENAME NodeConstPointerTo<T>::To *)ptr)
181 {
182 }
183 #endif // CPPPARSER
184 
185 #ifndef CPPPARSER
186 ////////////////////////////////////////////////////////////////////
187 // Function: NodeConstPointerTo::Copy Constructor
188 // Access: Public
189 // Description:
190 ////////////////////////////////////////////////////////////////////
191 template<class T>
194  NodePointerToBase<T>((const NodePointerToBase<T> &)copy)
195 {
196 }
197 #endif // CPPPARSER
198 
199 #ifndef CPPPARSER
200 ////////////////////////////////////////////////////////////////////
201 // Function: NodeConstPointerTo::Copy Constructor
202 // Access: Public
203 // Description:
204 ////////////////////////////////////////////////////////////////////
205 template<class T>
208  NodePointerToBase<T>((const NodePointerToBase<T> &)copy)
209 {
210 }
211 #endif // CPPPARSER
212 
213 #ifndef CPPPARSER
214 ////////////////////////////////////////////////////////////////////
215 // Function: NodeConstPointerTo::Destructor
216 // Access: Public
217 // Description:
218 ////////////////////////////////////////////////////////////////////
219 template<class T>
222 }
223 #endif // CPPPARSER
224 
225 #ifdef USE_MOVE_SEMANTICS
226 #ifndef CPPPARSER
227 ////////////////////////////////////////////////////////////////////
228 // Function: NodeConstPointerTo::Move Constructor
229 // Access: Public
230 // Description:
231 ////////////////////////////////////////////////////////////////////
232 template<class T>
234 NodeConstPointerTo(NodePointerTo<T> &&from) NOEXCEPT :
235  NodePointerToBase<T>((NodePointerToBase<T> &&)from)
236 {
237 }
238 #endif // CPPPARSER
239 
240 #ifndef CPPPARSER
241 ////////////////////////////////////////////////////////////////////
242 // Function: NodeConstPointerTo::Move Constructor
243 // Access: Public
244 // Description:
245 ////////////////////////////////////////////////////////////////////
246 template<class T>
248 NodeConstPointerTo(NodeConstPointerTo<T> &&from) NOEXCEPT :
249  NodePointerToBase<T>((NodePointerToBase<T> &&)from)
250 {
251 }
252 #endif // CPPPARSER
253 
254 #ifndef CPPPARSER
255 ////////////////////////////////////////////////////////////////////
256 // Function: NodeConstPointerTo::Move Assignment Operator
257 // Access: Public
258 // Description:
259 ////////////////////////////////////////////////////////////////////
260 template<class T>
262 operator = (NodePointerTo<T> &&from) NOEXCEPT {
263  this->reassign(move(from));
264  return *this;
265 }
266 #endif // CPPPARSER
267 
268 #ifndef CPPPARSER
269 ////////////////////////////////////////////////////////////////////
270 // Function: NodeConstPointerTo::Move Assignment Operator
271 // Access: Public
272 // Description:
273 ////////////////////////////////////////////////////////////////////
274 template<class T>
276 operator = (NodeConstPointerTo<T> &&from) NOEXCEPT {
277  this->reassign(move(from));
278  return *this;
279 }
280 #endif // CPPPARSER
281 #endif // USE_MOVE_SEMANTICS
282 
283 #ifndef CPPPARSER
284 ////////////////////////////////////////////////////////////////////
285 // Function: NodeConstPointerTo::Dereference operator
286 // Access: Public
287 // Description:
288 ////////////////////////////////////////////////////////////////////
289 template<class T>
290 INLINE const TYPENAME NodeConstPointerTo<T>::To &NodeConstPointerTo<T>::
291 operator *() const {
292  return *((To *)(this->_void_ptr));
293 }
294 #endif // CPPPARSER
295 
296 #ifndef CPPPARSER
297 ////////////////////////////////////////////////////////////////////
298 // Function: NodeConstPointerTo::Member access operator
299 // Access: Public
300 // Description:
301 ////////////////////////////////////////////////////////////////////
302 template<class T>
303 INLINE const TYPENAME NodeConstPointerTo<T>::To *NodeConstPointerTo<T>::
304 operator -> () const {
305  return (To *)(this->_void_ptr);
306 }
307 #endif // CPPPARSER
308 
309 #ifndef CPPPARSER
310 ////////////////////////////////////////////////////////////////////
311 // Function: NodeConstPointerTo::Typecast operator
312 // Access: Public
313 // Description: We also have the typecast operator to automatically
314 // convert NodeConstPointerTo's to the required kind of actual
315 // pointer. This introduces ambiguities which the
316 // compiler will resolve one way or the other, but we
317 // don't care which way it goes because either will be
318 // correct.
319 ////////////////////////////////////////////////////////////////////
320 
321 template<class T>
322 INLINE NodeConstPointerTo<T>::
323 operator const T * () const {
324  return (To *)(this->_void_ptr);
325 }
326 #endif // CPPPARSER
327 
328 #ifndef CPPPARSER
329 ////////////////////////////////////////////////////////////////////
330 // Function: NodeConstPointerTo::p
331 // Access: Public
332 // Description: Returns an ordinary pointer instead of a NodeConstPointerTo.
333 // Useful to work around compiler problems, particularly
334 // for implicit upcasts.
335 ////////////////////////////////////////////////////////////////////
336 template<class T>
337 INLINE const TYPENAME NodeConstPointerTo<T>::To *NodeConstPointerTo<T>::
338 p() const {
339  return (To *)(this->_void_ptr);
340 }
341 #endif // CPPPARSER
342 
343 #ifndef CPPPARSER
344 ////////////////////////////////////////////////////////////////////
345 // Function: NodeConstPointerTo::Assignment operator
346 // Access: Public
347 // Description:
348 ////////////////////////////////////////////////////////////////////
349 template<class T>
351 operator = (const To *ptr) {
352  this->reassign((To *)ptr);
353  return *this;
354 }
355 #endif // CPPPARSER
356 
357 #ifndef CPPPARSER
358 ////////////////////////////////////////////////////////////////////
359 // Function: NodeConstPointerTo::Assignment operator
360 // Access: Public
361 // Description:
362 ////////////////////////////////////////////////////////////////////
363 template<class T>
365 operator = (const NodePointerTo<T> &copy) {
366  this->reassign((const NodePointerToBase<T> &)copy);
367  return *this;
368 }
369 #endif // CPPPARSER
370 
371 #ifndef CPPPARSER
372 ////////////////////////////////////////////////////////////////////
373 // Function: NodeConstPointerTo::Assignment operator
374 // Access: Public
375 // Description:
376 ////////////////////////////////////////////////////////////////////
377 template<class T>
379 operator = (const NodeConstPointerTo<T> &copy) {
380  this->reassign((const NodePointerToBase<T> &)copy);
381  return *this;
382 }
383 #endif // CPPPARSER
This is similar to PointerToBase, but it manages objects of type NodeReferenceCount or NodeCachedRefe...
const To * p() const
Returns an ordinary pointer instead of a NodeConstPointerTo.
To * p() const
Returns an ordinary pointer instead of a NodePointerTo.
A NodeConstPointerTo is similar to a NodePointerTo, except it keeps a const pointer to the thing...
Definition: nodePointerTo.h:64
This implements the special NodePointerTo template class, which works just like PointerTo except it m...
Definition: nodePointerTo.h:29