nodeAttribute.I 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. // Filename: nodeAttribute.I
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. ////////////////////////////////////////////////////////////////////
  6. // Function: NodeAttribute::Constructor
  7. // Access: Public
  8. // Description:
  9. ////////////////////////////////////////////////////////////////////
  10. INLINE NodeAttribute::
  11. NodeAttribute() {
  12. _priority = 0;
  13. }
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: NodeAttribute::Copy Constructor
  16. // Access: Public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE NodeAttribute::
  20. NodeAttribute(const NodeAttribute &copy) :
  21. TypedReferenceCount(copy),
  22. _priority(copy._priority)
  23. {
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: NodeAttribute::Copy Assignment Operator
  27. // Access: Public
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE void NodeAttribute::
  31. operator = (const NodeAttribute &copy) {
  32. TypedReferenceCount::operator = (copy);
  33. _priority = copy._priority;
  34. }
  35. ////////////////////////////////////////////////////////////////////
  36. // Function: NodeAttribute::Equality Operator
  37. // Access: Public
  38. // Description:
  39. ////////////////////////////////////////////////////////////////////
  40. INLINE bool NodeAttribute::
  41. operator == (const NodeAttribute &other) const {
  42. return compare_to(other) == 0;
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: NodeAttribute::Inequality Operator
  46. // Access: Public
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. INLINE bool NodeAttribute::
  50. operator != (const NodeAttribute &other) const {
  51. return compare_to(other) != 0;
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: NodeAttribute::Inequality Operator
  55. // Access: Public
  56. // Description:
  57. ////////////////////////////////////////////////////////////////////
  58. INLINE bool NodeAttribute::
  59. operator < (const NodeAttribute &other) const {
  60. return compare_to(other) < 0;
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: NodeAttribute::Inequality Operator
  64. // Access: Public
  65. // Description:
  66. ////////////////////////////////////////////////////////////////////
  67. INLINE bool NodeAttribute::
  68. operator <= (const NodeAttribute &other) const {
  69. return compare_to(other) <= 0;
  70. }
  71. ////////////////////////////////////////////////////////////////////
  72. // Function: NodeAttribute::Inequality Operator
  73. // Access: Public
  74. // Description:
  75. ////////////////////////////////////////////////////////////////////
  76. INLINE bool NodeAttribute::
  77. operator > (const NodeAttribute &other) const {
  78. return compare_to(other) > 0;
  79. }
  80. ////////////////////////////////////////////////////////////////////
  81. // Function: NodeAttribute::Inequality Operator
  82. // Access: Public
  83. // Description:
  84. ////////////////////////////////////////////////////////////////////
  85. INLINE bool NodeAttribute::
  86. operator >= (const NodeAttribute &other) const {
  87. return compare_to(other) >= 0;
  88. }
  89. ////////////////////////////////////////////////////////////////////
  90. // Function: NodeAttribute::compare_to
  91. // Access: Public
  92. // Description: This function works like strcmp(): it compares the
  93. // two attributes and returns a number less than zero
  94. // if this attribute sorts before the other one, equal
  95. // to zero if they are equivalent, or greater than zero
  96. // if this attribute sorts after the other one.
  97. //
  98. // This imposes an arbitrary sorting order across all
  99. // attributes, whose sole purpose is to allow grouping
  100. // of equivalent attributes together in STL structures
  101. // like maps and sets.
  102. ////////////////////////////////////////////////////////////////////
  103. INLINE int NodeAttribute::
  104. compare_to(const NodeAttribute &other) const {
  105. TypeHandle my_handle = get_handle();
  106. TypeHandle other_handle = other.get_handle();
  107. if (my_handle == other_handle) {
  108. return internal_compare_to(&other);
  109. } else {
  110. return
  111. (my_handle < other_handle) ? -1 : 1;
  112. }
  113. }
  114. ////////////////////////////////////////////////////////////////////
  115. // Function: NodeAttribute::set_priority
  116. // Access: Public
  117. // Description: Changes the priority associated with this attribute.
  118. // The attribute will not be affected by transitions
  119. // with a lower priority.
  120. ////////////////////////////////////////////////////////////////////
  121. INLINE void NodeAttribute::
  122. set_priority(int priority) {
  123. _priority = priority;
  124. }
  125. ////////////////////////////////////////////////////////////////////
  126. // Function: NodeAttribute::get_priority
  127. // Access: Public
  128. // Description: Returns the priority associated with this attribute.
  129. // Normally this is of limited value; the priority is
  130. // meaningful primarily on the transitions.
  131. ////////////////////////////////////////////////////////////////////
  132. INLINE int NodeAttribute::
  133. get_priority() const {
  134. return _priority;
  135. }