Panda3D
 All Classes Functions Variables Enumerations
pointerTo.I
00001 // Filename: pointerTo.I
00002 // Created by:  drose (10Feb99)
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 ////////////////////////////////////////////////////////////////////
00017 //     Function: PointerTo::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 template<class T>
00022 INLINE PointerTo<T>::
00023 PointerTo(To *ptr) : PointerToBase<T>(ptr) {
00024 }
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: PointerTo::Copy Constructor
00028 //       Access: Public
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 template<class T>
00032 INLINE PointerTo<T>::
00033 PointerTo(const PointerTo<T> &copy) :
00034   PointerToBase<T>((const PointerToBase<T> &)copy)
00035 {
00036 }
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: PointerTo::Destructor
00040 //       Access: Public
00041 //  Description:
00042 ////////////////////////////////////////////////////////////////////
00043 template<class T>
00044 INLINE PointerTo<T>::
00045 ~PointerTo() {
00046 }
00047 
00048 ////////////////////////////////////////////////////////////////////
00049 //     Function: PointerTo::Dereference operator
00050 //       Access: Public
00051 //  Description:
00052 ////////////////////////////////////////////////////////////////////
00053 template<class T>
00054 INLINE TYPENAME PointerTo<T>::To &PointerTo<T>::
00055 operator *() const {
00056   return *((To *)(this->_void_ptr));
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: PointerTo::Member access operator
00061 //       Access: Public
00062 //  Description:
00063 ////////////////////////////////////////////////////////////////////
00064 template<class T>
00065 INLINE TYPENAME PointerTo<T>::To *PointerTo<T>::
00066 operator -> () const {
00067   return (To *)(this->_void_ptr);
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: PointerTo::Typecast operator
00072 //       Access: Public
00073 //  Description: We also have the typecast operator to automatically
00074 //               convert PointerTo's to the required kind of actual
00075 //               pointer.  This introduces ambiguities which the
00076 //               compiler will resolve one way or the other, but we
00077 //               don't care which way it goes because either will be
00078 //               correct.
00079 ////////////////////////////////////////////////////////////////////
00080 template<class T>
00081 INLINE PointerTo<T>::
00082 operator T * () const {
00083   return (To *)(this->_void_ptr);
00084 }
00085 
00086 ////////////////////////////////////////////////////////////////////
00087 //     Function: PointerTo::p
00088 //       Access: Published
00089 //  Description: Returns an ordinary pointer instead of a PointerTo.
00090 //               Useful to work around compiler problems, particularly
00091 //               for implicit upcasts.
00092 ////////////////////////////////////////////////////////////////////
00093 template<class T>
00094 INLINE TYPENAME PointerTo<T>::To *PointerTo<T>::
00095 p() const {
00096   return (To *)(this->_void_ptr);
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: PointerTo::Assignment operator
00101 //       Access: Published
00102 //  Description:
00103 ////////////////////////////////////////////////////////////////////
00104 template<class T>
00105 INLINE PointerTo<T> &PointerTo<T>::
00106 operator = (To *ptr) {
00107   this->reassign(ptr);
00108   return *this;
00109 }
00110 
00111 ////////////////////////////////////////////////////////////////////
00112 //     Function: PointerTo::Assignment operator
00113 //       Access: Published
00114 //  Description:
00115 ////////////////////////////////////////////////////////////////////
00116 template<class T>
00117 INLINE PointerTo<T> &PointerTo<T>::
00118 operator = (const PointerTo<T> &copy) {
00119   this->reassign((const PointerToBase<T> &)copy);
00120   return *this;
00121 }
00122 
00123 ////////////////////////////////////////////////////////////////////
00124 //     Function: ConstPointerTo::Constructor
00125 //       Access: Public
00126 //  Description:
00127 ////////////////////////////////////////////////////////////////////
00128 template<class T>
00129 INLINE ConstPointerTo<T>::
00130 ConstPointerTo(const TYPENAME ConstPointerTo<T>::To *ptr) :
00131   PointerToBase<T>((TYPENAME ConstPointerTo<T>::To *)ptr)
00132 {
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: ConstPointerTo::Copy Constructor
00137 //       Access: Public
00138 //  Description:
00139 ////////////////////////////////////////////////////////////////////
00140 template<class T>
00141 INLINE ConstPointerTo<T>::
00142 ConstPointerTo(const PointerTo<T> &copy) :
00143   PointerToBase<T>((const PointerToBase<T> &)copy)
00144 {
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: ConstPointerTo::Destructor
00149 //       Access: Public
00150 //  Description:
00151 ////////////////////////////////////////////////////////////////////
00152 template<class T>
00153 INLINE ConstPointerTo<T>::
00154 ~ConstPointerTo() {
00155 }
00156 
00157 ////////////////////////////////////////////////////////////////////
00158 //     Function: ConstPointerTo::Copy Constructor
00159 //       Access: Public
00160 //  Description:
00161 ////////////////////////////////////////////////////////////////////
00162 template<class T>
00163 INLINE ConstPointerTo<T>::
00164 ConstPointerTo(const ConstPointerTo<T> &copy) :
00165   PointerToBase<T>((const PointerToBase<T> &)copy)
00166 {
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: ConstPointerTo::Dereference operator
00171 //       Access: Public
00172 //  Description:
00173 ////////////////////////////////////////////////////////////////////
00174 template<class T>
00175 INLINE const TYPENAME ConstPointerTo<T>::To &ConstPointerTo<T>::
00176 operator *() const {
00177   return *((To *)(this->_void_ptr));
00178 }
00179 
00180 ////////////////////////////////////////////////////////////////////
00181 //     Function: ConstPointerTo::Member access operator
00182 //       Access: Public
00183 //  Description:
00184 ////////////////////////////////////////////////////////////////////
00185 template<class T>
00186 INLINE const TYPENAME ConstPointerTo<T>::To *ConstPointerTo<T>::
00187 operator -> () const {
00188   return (To *)(this->_void_ptr);
00189 }
00190 
00191 ////////////////////////////////////////////////////////////////////
00192 //     Function: ConstPointerTo::Typecast operator
00193 //       Access: Public
00194 //  Description: We also have the typecast operator to automatically
00195 //               convert ConstPointerTo's to the required kind of actual
00196 //               pointer.  This introduces ambiguities which the
00197 //               compiler will resolve one way or the other, but we
00198 //               don't care which way it goes because either will be
00199 //               correct.
00200 ////////////////////////////////////////////////////////////////////
00201 
00202 template<class T>
00203 INLINE ConstPointerTo<T>::
00204 operator const T * () const {
00205 return (To *)(this->_void_ptr);
00206 }
00207 
00208 ////////////////////////////////////////////////////////////////////
00209 //     Function: ConstPointerTo::p
00210 //       Access: Published
00211 //  Description: Returns an ordinary pointer instead of a ConstPointerTo.
00212 //               Useful to work around compiler problems, particularly
00213 //               for implicit upcasts.
00214 ////////////////////////////////////////////////////////////////////
00215 template<class T>
00216 INLINE const TYPENAME ConstPointerTo<T>::To *ConstPointerTo<T>::
00217 p() const {
00218   return (To *)(this->_void_ptr);
00219 }
00220 
00221 ////////////////////////////////////////////////////////////////////
00222 //     Function: ConstPointerTo::Assignment operator
00223 //       Access: Published
00224 //  Description:
00225 ////////////////////////////////////////////////////////////////////
00226 template<class T>
00227 INLINE ConstPointerTo<T> &ConstPointerTo<T>::
00228 operator = (const To *ptr) {
00229   this->reassign((To *)ptr);
00230   return *this;
00231 }
00232 
00233 ////////////////////////////////////////////////////////////////////
00234 //     Function: ConstPointerTo::Assignment operator
00235 //       Access: Published
00236 //  Description:
00237 ////////////////////////////////////////////////////////////////////
00238 template<class T>
00239 INLINE ConstPointerTo<T> &ConstPointerTo<T>::
00240 operator = (const PointerTo<T> &copy) {
00241   this->reassign((const PointerToBase<T> &)copy);
00242   return *this;
00243 }
00244 
00245 ////////////////////////////////////////////////////////////////////
00246 //     Function: ConstPointerTo::Assignment operator
00247 //       Access: Published
00248 //  Description:
00249 ////////////////////////////////////////////////////////////////////
00250 template<class T>
00251 INLINE ConstPointerTo<T> &ConstPointerTo<T>::
00252 operator = (const ConstPointerTo<T> &copy) {
00253   this->reassign((const PointerToBase<T> &)copy);
00254   return *this;
00255 }
 All Classes Functions Variables Enumerations