nodePointerTo.I 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. // Filename: nodePointerTo.I
  2. // Created by: drose (07May05)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: NodePointerTo::Constructor
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. template<class T>
  24. INLINE NodePointerTo<T>::
  25. NodePointerTo(To *ptr) : NodePointerToBase<T>(ptr) {
  26. }
  27. ////////////////////////////////////////////////////////////////////
  28. // Function: NodePointerTo::Copy Constructor
  29. // Access: Public
  30. // Description:
  31. ////////////////////////////////////////////////////////////////////
  32. template<class T>
  33. INLINE NodePointerTo<T>::
  34. NodePointerTo(const NodePointerTo<T> &copy) :
  35. NodePointerToBase<T>((const NodePointerToBase<T> &)copy)
  36. {
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: NodePointerTo::Dereference operator
  40. // Access: Public
  41. // Description:
  42. ////////////////////////////////////////////////////////////////////
  43. template<class T>
  44. INLINE TYPENAME NodePointerTo<T>::To &NodePointerTo<T>::
  45. operator *() const {
  46. return *((To *)(this->_void_ptr));
  47. }
  48. ////////////////////////////////////////////////////////////////////
  49. // Function: NodePointerTo::Member access operator
  50. // Access: Public
  51. // Description:
  52. ////////////////////////////////////////////////////////////////////
  53. template<class T>
  54. INLINE TYPENAME NodePointerTo<T>::To *NodePointerTo<T>::
  55. operator -> () const {
  56. return (To *)(this->_void_ptr);
  57. }
  58. ////////////////////////////////////////////////////////////////////
  59. // Function: NodePointerTo::Typecast operator
  60. // Access: Public
  61. // Description: We also have the typecast operator to automatically
  62. // convert NodePointerTo's to the required kind of actual
  63. // pointer. This introduces ambiguities which the
  64. // compiler will resolve one way or the other, but we
  65. // don't care which way it goes because either will be
  66. // correct.
  67. ////////////////////////////////////////////////////////////////////
  68. template<class T>
  69. INLINE NodePointerTo<T>::
  70. operator TYPENAME NodePointerToBase<T>::To *() const {
  71. return (To *)(this->_void_ptr);
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: NodePointerTo::p
  75. // Access: Public
  76. // Description: Returns an ordinary pointer instead of a NodePointerTo.
  77. // Useful to work around compiler problems, particularly
  78. // for implicit upcasts.
  79. ////////////////////////////////////////////////////////////////////
  80. template<class T>
  81. INLINE TYPENAME NodePointerTo<T>::To *NodePointerTo<T>::
  82. p() const {
  83. return (To *)(this->_void_ptr);
  84. }
  85. ////////////////////////////////////////////////////////////////////
  86. // Function: NodePointerTo::Assignment operator
  87. // Access: Public
  88. // Description:
  89. ////////////////////////////////////////////////////////////////////
  90. template<class T>
  91. INLINE NodePointerTo<T> &NodePointerTo<T>::
  92. operator = (To *ptr) {
  93. reassign(ptr);
  94. return *this;
  95. }
  96. ////////////////////////////////////////////////////////////////////
  97. // Function: NodePointerTo::Assignment operator
  98. // Access: Public
  99. // Description:
  100. ////////////////////////////////////////////////////////////////////
  101. template<class T>
  102. INLINE NodePointerTo<T> &NodePointerTo<T>::
  103. operator = (const NodePointerTo<T> &copy) {
  104. reassign((const NodePointerToBase<T> &)copy);
  105. return *this;
  106. }
  107. ////////////////////////////////////////////////////////////////////
  108. // Function: NodeConstPointerTo::Constructor
  109. // Access: Public
  110. // Description:
  111. ////////////////////////////////////////////////////////////////////
  112. template<class T>
  113. INLINE NodeConstPointerTo<T>::
  114. NodeConstPointerTo(const TYPENAME NodeConstPointerTo<T>::To *ptr) :
  115. NodePointerToBase<T>((TYPENAME NodeConstPointerTo<T>::To *)ptr)
  116. {
  117. }
  118. ////////////////////////////////////////////////////////////////////
  119. // Function: NodeConstPointerTo::Copy Constructor
  120. // Access: Public
  121. // Description:
  122. ////////////////////////////////////////////////////////////////////
  123. template<class T>
  124. INLINE NodeConstPointerTo<T>::
  125. NodeConstPointerTo(const NodePointerTo<T> &copy) :
  126. NodePointerToBase<T>((const NodePointerToBase<T> &)copy)
  127. {
  128. }
  129. ////////////////////////////////////////////////////////////////////
  130. // Function: NodeConstPointerTo::Copy Constructor
  131. // Access: Public
  132. // Description:
  133. ////////////////////////////////////////////////////////////////////
  134. template<class T>
  135. INLINE NodeConstPointerTo<T>::
  136. NodeConstPointerTo(const NodeConstPointerTo<T> &copy) :
  137. NodePointerToBase<T>((const NodePointerToBase<T> &)copy)
  138. {
  139. }
  140. ////////////////////////////////////////////////////////////////////
  141. // Function: NodeConstPointerTo::Dereference operator
  142. // Access: Public
  143. // Description:
  144. ////////////////////////////////////////////////////////////////////
  145. template<class T>
  146. INLINE const TYPENAME NodeConstPointerTo<T>::To &NodeConstPointerTo<T>::
  147. operator *() const {
  148. return *((To *)(this->_void_ptr));
  149. }
  150. ////////////////////////////////////////////////////////////////////
  151. // Function: NodeConstPointerTo::Member access operator
  152. // Access: Public
  153. // Description:
  154. ////////////////////////////////////////////////////////////////////
  155. template<class T>
  156. INLINE const TYPENAME NodeConstPointerTo<T>::To *NodeConstPointerTo<T>::
  157. operator -> () const {
  158. return (To *)(this->_void_ptr);
  159. }
  160. ////////////////////////////////////////////////////////////////////
  161. // Function: NodeConstPointerTo::Typecast operator
  162. // Access: Public
  163. // Description: We also have the typecast operator to automatically
  164. // convert NodeConstPointerTo's to the required kind of actual
  165. // pointer. This introduces ambiguities which the
  166. // compiler will resolve one way or the other, but we
  167. // don't care which way it goes because either will be
  168. // correct.
  169. ////////////////////////////////////////////////////////////////////
  170. template<class T>
  171. INLINE NodeConstPointerTo<T>::
  172. operator const TYPENAME NodePointerToBase<T>::To *() const {
  173. return (To *)(this->_void_ptr);
  174. }
  175. ////////////////////////////////////////////////////////////////////
  176. // Function: NodeConstPointerTo::p
  177. // Access: Public
  178. // Description: Returns an ordinary pointer instead of a NodeConstPointerTo.
  179. // Useful to work around compiler problems, particularly
  180. // for implicit upcasts.
  181. ////////////////////////////////////////////////////////////////////
  182. template<class T>
  183. INLINE const TYPENAME NodeConstPointerTo<T>::To *NodeConstPointerTo<T>::
  184. p() const {
  185. return (To *)(this->_void_ptr);
  186. }
  187. ////////////////////////////////////////////////////////////////////
  188. // Function: NodeConstPointerTo::Assignment operator
  189. // Access: Public
  190. // Description:
  191. ////////////////////////////////////////////////////////////////////
  192. template<class T>
  193. INLINE NodeConstPointerTo<T> &NodeConstPointerTo<T>::
  194. operator = (const To *ptr) {
  195. reassign((To *)ptr);
  196. return *this;
  197. }
  198. ////////////////////////////////////////////////////////////////////
  199. // Function: NodeConstPointerTo::Assignment operator
  200. // Access: Public
  201. // Description:
  202. ////////////////////////////////////////////////////////////////////
  203. template<class T>
  204. INLINE NodeConstPointerTo<T> &NodeConstPointerTo<T>::
  205. operator = (const NodePointerTo<T> &copy) {
  206. reassign((const NodePointerToBase<T> &)copy);
  207. return *this;
  208. }
  209. ////////////////////////////////////////////////////////////////////
  210. // Function: NodeConstPointerTo::Assignment operator
  211. // Access: Public
  212. // Description:
  213. ////////////////////////////////////////////////////////////////////
  214. template<class T>
  215. INLINE NodeConstPointerTo<T> &NodeConstPointerTo<T>::
  216. operator = (const NodeConstPointerTo<T> &copy) {
  217. reassign((const NodePointerToBase<T> &)copy);
  218. return *this;
  219. }