pointerDataTransition.I 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // Filename: pointerDataTransition.I
  2. // Created by: jason (07Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, 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://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. /* okcircular */
  19. #include "pointerDataAttribute.h"
  20. template<class PtrType>
  21. TypeHandle PointerDataTransition<PtrType>::_type_handle;
  22. ////////////////////////////////////////////////////////////////////
  23. // Function: PointerDataTransition::Constructor
  24. // Access: Public
  25. // Description:
  26. ////////////////////////////////////////////////////////////////////
  27. template<class PtrType>
  28. INLINE PointerDataTransition<PtrType>::
  29. PointerDataTransition() :
  30. _ptr(PointerDataAttribute<PtrType>::_null_ptr)
  31. {
  32. }
  33. ////////////////////////////////////////////////////////////////////
  34. // Function: PointerDataTransition::Constructor
  35. // Access: Public
  36. // Description:
  37. ////////////////////////////////////////////////////////////////////
  38. template<class PtrType>
  39. INLINE PointerDataTransition<PtrType>::
  40. PointerDataTransition(PtrType* ptr) :
  41. _ptr(ptr)
  42. {
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: PointerDataTransition::Copy Constructor
  46. // Access: Public
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. template<class PtrType>
  50. INLINE PointerDataTransition<PtrType>::
  51. PointerDataTransition(const PointerDataTransition<PtrType> &copy) :
  52. NodeTransition(copy), _ptr(copy._ptr)
  53. {
  54. }
  55. ////////////////////////////////////////////////////////////////////
  56. // Function: PointerDataTransition::Copy Assignment Operator
  57. // Access: Public
  58. // Description:
  59. ////////////////////////////////////////////////////////////////////
  60. template<class PtrType>
  61. INLINE void PointerDataTransition<PtrType>::
  62. operator = (const PointerDataTransition<PtrType> &copy) {
  63. NodeTransition::operator = (copy);
  64. _ptr = copy._ptr;
  65. }
  66. ////////////////////////////////////////////////////////////////////
  67. // Function: PointerDataTransition::set_value
  68. // Access: Public, Virtual
  69. // Description:
  70. ////////////////////////////////////////////////////////////////////
  71. template<class PtrType>
  72. void PointerDataTransition<PtrType>::
  73. set_value(PtrType* ptr) {
  74. _ptr = ptr;
  75. state_changed();
  76. }
  77. ////////////////////////////////////////////////////////////////////
  78. // Function: PointerDataTransition::get_value
  79. // Access: Public, Virtual
  80. // Description:
  81. ////////////////////////////////////////////////////////////////////
  82. template<class PtrType>
  83. PtrType* PointerDataTransition<PtrType>::
  84. get_value() const {
  85. return _ptr;
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: PointerDataTransition::compose
  89. // Access: Public, Virtual
  90. // Description: Returns a new transition that corresponds to the
  91. // composition of this transition with the second
  92. // transition (which must be of an equivalent type).
  93. // This may return the same pointer as either source
  94. // transition. Applying the transition returned from
  95. // this function to an attribute attribute will produce
  96. // the same effect as applying each transition
  97. // separately.
  98. ////////////////////////////////////////////////////////////////////
  99. template<class PtrType>
  100. NodeTransition *PointerDataTransition<PtrType>::
  101. compose(const NodeTransition *other) const {
  102. const PointerDataTransition<PtrType> *ot;
  103. DCAST_INTO_R(ot, other, NULL);
  104. return (NodeTransition*)other;
  105. }
  106. ////////////////////////////////////////////////////////////////////
  107. // Function: PointerDataTransition::invert
  108. // Access: Public, Virtual
  109. // Description:
  110. ////////////////////////////////////////////////////////////////////
  111. template<class PtrType>
  112. NodeTransition *PointerDataTransition<PtrType>::
  113. invert() const {
  114. return (NodeTransition*)this;
  115. }
  116. ////////////////////////////////////////////////////////////////////
  117. // Function: PointerDataTransition::apply
  118. // Access: Public, Virtual
  119. // Description: Returns a new attribute (or possibly the same
  120. // attribute) that represents the effect of applying this
  121. // indicated transition to the indicated attribute. The
  122. // source attribute may be NULL, indicating the initial
  123. // attribute.
  124. ////////////////////////////////////////////////////////////////////
  125. template<class PtrType>
  126. NodeAttribute *PointerDataTransition<PtrType>::
  127. apply(const NodeAttribute *attrib) const {
  128. const PointerDataAttribute<PtrType> *at;
  129. DCAST_INTO_R(at, attrib, NULL);
  130. return (NodeAttribute*)attrib;
  131. }
  132. ////////////////////////////////////////////////////////////////////
  133. // Function: PointerDataTransition::output
  134. // Access: Public, Virtual
  135. // Description:
  136. ////////////////////////////////////////////////////////////////////
  137. template<class PtrType>
  138. void PointerDataTransition<PtrType>::
  139. output(ostream &out) const {
  140. out << (void*)_ptr << endl;
  141. }
  142. ////////////////////////////////////////////////////////////////////
  143. // Function: PointerDataTransition::write
  144. // Access: Public, Virtual
  145. // Description:
  146. ////////////////////////////////////////////////////////////////////
  147. template<class PtrType>
  148. void PointerDataTransition<PtrType>::
  149. write(ostream &out, int indent_level) const {
  150. indent(out, indent_level) << (void*)_ptr << endl;
  151. }
  152. ///////////////////////////////////////////////////////////////////
  153. // Function: PointerDataTransition::internal_compare_to
  154. // Access: Protected, Virtual
  155. // Description:
  156. ////////////////////////////////////////////////////////////////////
  157. template<class PtrType>
  158. int PointerDataTransition<PtrType>::
  159. internal_compare_to(const NodeTransition *other) const {
  160. const PointerDataTransition<PtrType> *ot;
  161. DCAST_INTO_R(ot, other, false);
  162. if (_ptr != ot->_ptr) {
  163. return (_ptr > ot->_ptr) ? 1 : -1;
  164. }
  165. return 0;
  166. }