00001 // Filename: nodePointerTo.I 00002 // Created by: drose (07May05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 #ifndef CPPPARSER 00017 //////////////////////////////////////////////////////////////////// 00018 // Function: NodePointerTo::Constructor 00019 // Access: Public 00020 // Description: 00021 //////////////////////////////////////////////////////////////////// 00022 template<class T> 00023 INLINE NodePointerTo<T>:: 00024 NodePointerTo(To *ptr) : NodePointerToBase<T>(ptr) { 00025 } 00026 #endif // CPPPARSER 00027 00028 #ifndef CPPPARSER 00029 //////////////////////////////////////////////////////////////////// 00030 // Function: NodePointerTo::Copy Constructor 00031 // Access: Public 00032 // Description: 00033 //////////////////////////////////////////////////////////////////// 00034 template<class T> 00035 INLINE NodePointerTo<T>:: 00036 NodePointerTo(const NodePointerTo<T> ©) : 00037 NodePointerToBase<T>((const NodePointerToBase<T> &)copy) 00038 { 00039 } 00040 #endif // CPPPARSER 00041 00042 #ifndef CPPPARSER 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: NodePointerTo::Destructor 00045 // Access: Public 00046 // Description: 00047 //////////////////////////////////////////////////////////////////// 00048 template<class T> 00049 INLINE NodePointerTo<T>:: 00050 ~NodePointerTo() { 00051 } 00052 #endif // CPPPARSER 00053 00054 #ifndef CPPPARSER 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: NodePointerTo::Dereference operator 00057 // Access: Public 00058 // Description: 00059 //////////////////////////////////////////////////////////////////// 00060 template<class T> 00061 INLINE TYPENAME NodePointerTo<T>::To &NodePointerTo<T>:: 00062 operator *() const { 00063 return *((To *)(this->_void_ptr)); 00064 } 00065 #endif // CPPPARSER 00066 00067 #ifndef CPPPARSER 00068 //////////////////////////////////////////////////////////////////// 00069 // Function: NodePointerTo::Member access operator 00070 // Access: Public 00071 // Description: 00072 //////////////////////////////////////////////////////////////////// 00073 template<class T> 00074 INLINE TYPENAME NodePointerTo<T>::To *NodePointerTo<T>:: 00075 operator -> () const { 00076 return (To *)(this->_void_ptr); 00077 } 00078 #endif // CPPPARSER 00079 00080 #ifndef CPPPARSER 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: NodePointerTo::Typecast operator 00083 // Access: Public 00084 // Description: We also have the typecast operator to automatically 00085 // convert NodePointerTo's to the required kind of actual 00086 // pointer. This introduces ambiguities which the 00087 // compiler will resolve one way or the other, but we 00088 // don't care which way it goes because either will be 00089 // correct. 00090 //////////////////////////////////////////////////////////////////// 00091 template<class T> 00092 INLINE NodePointerTo<T>:: 00093 operator T *() const { 00094 return (To *)(this->_void_ptr); 00095 } 00096 #endif // CPPPARSER 00097 00098 #ifndef CPPPARSER 00099 //////////////////////////////////////////////////////////////////// 00100 // Function: NodePointerTo::p 00101 // Access: Public 00102 // Description: Returns an ordinary pointer instead of a NodePointerTo. 00103 // Useful to work around compiler problems, particularly 00104 // for implicit upcasts. 00105 //////////////////////////////////////////////////////////////////// 00106 template<class T> 00107 INLINE TYPENAME NodePointerTo<T>::To *NodePointerTo<T>:: 00108 p() const { 00109 return (To *)(this->_void_ptr); 00110 } 00111 #endif // CPPPARSER 00112 00113 #ifndef CPPPARSER 00114 //////////////////////////////////////////////////////////////////// 00115 // Function: NodePointerTo::Assignment operator 00116 // Access: Public 00117 // Description: 00118 //////////////////////////////////////////////////////////////////// 00119 template<class T> 00120 INLINE NodePointerTo<T> &NodePointerTo<T>:: 00121 operator = (To *ptr) { 00122 this->reassign(ptr); 00123 return *this; 00124 } 00125 #endif // CPPPARSER 00126 00127 #ifndef CPPPARSER 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: NodePointerTo::Assignment operator 00130 // Access: Public 00131 // Description: 00132 //////////////////////////////////////////////////////////////////// 00133 template<class T> 00134 INLINE NodePointerTo<T> &NodePointerTo<T>:: 00135 operator = (const NodePointerTo<T> ©) { 00136 this->reassign((const NodePointerToBase<T> &)copy); 00137 return *this; 00138 } 00139 #endif // CPPPARSER 00140 00141 #ifndef CPPPARSER 00142 //////////////////////////////////////////////////////////////////// 00143 // Function: NodeConstPointerTo::Constructor 00144 // Access: Public 00145 // Description: 00146 //////////////////////////////////////////////////////////////////// 00147 template<class T> 00148 INLINE NodeConstPointerTo<T>:: 00149 NodeConstPointerTo(const TYPENAME NodeConstPointerTo<T>::To *ptr) : 00150 NodePointerToBase<T>((TYPENAME NodeConstPointerTo<T>::To *)ptr) 00151 { 00152 } 00153 #endif // CPPPARSER 00154 00155 #ifndef CPPPARSER 00156 //////////////////////////////////////////////////////////////////// 00157 // Function: NodeConstPointerTo::Copy Constructor 00158 // Access: Public 00159 // Description: 00160 //////////////////////////////////////////////////////////////////// 00161 template<class T> 00162 INLINE NodeConstPointerTo<T>:: 00163 NodeConstPointerTo(const NodePointerTo<T> ©) : 00164 NodePointerToBase<T>((const NodePointerToBase<T> &)copy) 00165 { 00166 } 00167 #endif // CPPPARSER 00168 00169 #ifndef CPPPARSER 00170 //////////////////////////////////////////////////////////////////// 00171 // Function: NodeConstPointerTo::Copy Constructor 00172 // Access: Public 00173 // Description: 00174 //////////////////////////////////////////////////////////////////// 00175 template<class T> 00176 INLINE NodeConstPointerTo<T>:: 00177 NodeConstPointerTo(const NodeConstPointerTo<T> ©) : 00178 NodePointerToBase<T>((const NodePointerToBase<T> &)copy) 00179 { 00180 } 00181 #endif // CPPPARSER 00182 00183 #ifndef CPPPARSER 00184 //////////////////////////////////////////////////////////////////// 00185 // Function: NodeConstPointerTo::Destructor 00186 // Access: Public 00187 // Description: 00188 //////////////////////////////////////////////////////////////////// 00189 template<class T> 00190 INLINE NodeConstPointerTo<T>:: 00191 ~NodeConstPointerTo() { 00192 } 00193 #endif // CPPPARSER 00194 00195 #ifndef CPPPARSER 00196 //////////////////////////////////////////////////////////////////// 00197 // Function: NodeConstPointerTo::Dereference operator 00198 // Access: Public 00199 // Description: 00200 //////////////////////////////////////////////////////////////////// 00201 template<class T> 00202 INLINE const TYPENAME NodeConstPointerTo<T>::To &NodeConstPointerTo<T>:: 00203 operator *() const { 00204 return *((To *)(this->_void_ptr)); 00205 } 00206 #endif // CPPPARSER 00207 00208 #ifndef CPPPARSER 00209 //////////////////////////////////////////////////////////////////// 00210 // Function: NodeConstPointerTo::Member access operator 00211 // Access: Public 00212 // Description: 00213 //////////////////////////////////////////////////////////////////// 00214 template<class T> 00215 INLINE const TYPENAME NodeConstPointerTo<T>::To *NodeConstPointerTo<T>:: 00216 operator -> () const { 00217 return (To *)(this->_void_ptr); 00218 } 00219 #endif // CPPPARSER 00220 00221 #ifndef CPPPARSER 00222 //////////////////////////////////////////////////////////////////// 00223 // Function: NodeConstPointerTo::Typecast operator 00224 // Access: Public 00225 // Description: We also have the typecast operator to automatically 00226 // convert NodeConstPointerTo's to the required kind of actual 00227 // pointer. This introduces ambiguities which the 00228 // compiler will resolve one way or the other, but we 00229 // don't care which way it goes because either will be 00230 // correct. 00231 //////////////////////////////////////////////////////////////////// 00232 00233 template<class T> 00234 INLINE NodeConstPointerTo<T>:: 00235 operator const T * () const { 00236 return (To *)(this->_void_ptr); 00237 } 00238 #endif // CPPPARSER 00239 00240 #ifndef CPPPARSER 00241 //////////////////////////////////////////////////////////////////// 00242 // Function: NodeConstPointerTo::p 00243 // Access: Public 00244 // Description: Returns an ordinary pointer instead of a NodeConstPointerTo. 00245 // Useful to work around compiler problems, particularly 00246 // for implicit upcasts. 00247 //////////////////////////////////////////////////////////////////// 00248 template<class T> 00249 INLINE const TYPENAME NodeConstPointerTo<T>::To *NodeConstPointerTo<T>:: 00250 p() const { 00251 return (To *)(this->_void_ptr); 00252 } 00253 #endif // CPPPARSER 00254 00255 #ifndef CPPPARSER 00256 //////////////////////////////////////////////////////////////////// 00257 // Function: NodeConstPointerTo::Assignment operator 00258 // Access: Public 00259 // Description: 00260 //////////////////////////////////////////////////////////////////// 00261 template<class T> 00262 INLINE NodeConstPointerTo<T> &NodeConstPointerTo<T>:: 00263 operator = (const To *ptr) { 00264 this->reassign((To *)ptr); 00265 return *this; 00266 } 00267 #endif // CPPPARSER 00268 00269 #ifndef CPPPARSER 00270 //////////////////////////////////////////////////////////////////// 00271 // Function: NodeConstPointerTo::Assignment operator 00272 // Access: Public 00273 // Description: 00274 //////////////////////////////////////////////////////////////////// 00275 template<class T> 00276 INLINE NodeConstPointerTo<T> &NodeConstPointerTo<T>:: 00277 operator = (const NodePointerTo<T> ©) { 00278 this->reassign((const NodePointerToBase<T> &)copy); 00279 return *this; 00280 } 00281 #endif // CPPPARSER 00282 00283 #ifndef CPPPARSER 00284 //////////////////////////////////////////////////////////////////// 00285 // Function: NodeConstPointerTo::Assignment operator 00286 // Access: Public 00287 // Description: 00288 //////////////////////////////////////////////////////////////////// 00289 template<class T> 00290 INLINE NodeConstPointerTo<T> &NodeConstPointerTo<T>:: 00291 operator = (const NodeConstPointerTo<T> ©) { 00292 this->reassign((const NodePointerToBase<T> &)copy); 00293 return *this; 00294 } 00295 #endif // CPPPARSER