nodeAttributeWrapper.I 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. // Filename: nodeAttributeWrapper.I
  2. // Created by: drose (20Mar00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. ////////////////////////////////////////////////////////////////////
  6. // Function: NodeAttributeWrapper::Constructor
  7. // Access: Public
  8. // Description:
  9. ////////////////////////////////////////////////////////////////////
  10. INLINE_GRAPH NodeAttributeWrapper::
  11. NodeAttributeWrapper(TypeHandle handle) : _handle(handle) {
  12. nassertv(_handle != TypeHandle::none());
  13. }
  14. ////////////////////////////////////////////////////////////////////
  15. // Function: NodeAttributeWrapper::Copy Constructor
  16. // Access: Public
  17. // Description:
  18. ////////////////////////////////////////////////////////////////////
  19. INLINE_GRAPH NodeAttributeWrapper::
  20. NodeAttributeWrapper(const NodeAttributeWrapper &copy) :
  21. _handle(copy._handle),
  22. _attrib(copy._attrib)
  23. {
  24. }
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: NodeAttributeWrapper::Copy Assignment Operator
  27. // Access: Public
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. INLINE_GRAPH void NodeAttributeWrapper::
  31. operator = (const NodeAttributeWrapper &copy) {
  32. _handle = copy._handle;
  33. _attrib = copy._attrib;
  34. }
  35. ////////////////////////////////////////////////////////////////////
  36. // Function: NodeAttributeWrapper::get_handle
  37. // Access: Public
  38. // Description:
  39. ////////////////////////////////////////////////////////////////////
  40. INLINE_GRAPH TypeHandle NodeAttributeWrapper::
  41. get_handle() const {
  42. return _handle;
  43. }
  44. ////////////////////////////////////////////////////////////////////
  45. // Function: NodeAttributeWrapper::get_attrib
  46. // Access: Public
  47. // Description:
  48. ////////////////////////////////////////////////////////////////////
  49. INLINE_GRAPH NodeAttribute *NodeAttributeWrapper::
  50. get_attrib() const {
  51. return _attrib;
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: NodeAttributeWrapper::set_attrib
  55. // Access: Public
  56. // Description:
  57. ////////////////////////////////////////////////////////////////////
  58. INLINE_GRAPH void NodeAttributeWrapper::
  59. set_attrib(NodeAttribute *attrib) {
  60. _attrib = attrib;
  61. }
  62. ////////////////////////////////////////////////////////////////////
  63. // Function: NodeAttributeWrapper::is_initial
  64. // Access: Public
  65. // Description: Returns true if the wrapper represents an initial
  66. // attribute.
  67. ////////////////////////////////////////////////////////////////////
  68. INLINE_GRAPH bool NodeAttributeWrapper::
  69. is_initial() const {
  70. return (_attrib == (NodeAttribute *)NULL);
  71. // || _attrib->is_initial()
  72. }
  73. ////////////////////////////////////////////////////////////////////
  74. // Function: NodeAttributeWrapper::compare_to
  75. // Access: Public
  76. // Description:
  77. ////////////////////////////////////////////////////////////////////
  78. INLINE_GRAPH int NodeAttributeWrapper::
  79. compare_to(const NodeAttributeWrapper &other) const {
  80. nassertr(_handle == other._handle, false);
  81. if (_attrib == other._attrib) {
  82. return 0;
  83. }
  84. if (_attrib == (NodeAttribute *)NULL) {
  85. return -1;
  86. }
  87. if (other._attrib == (NodeAttribute *)NULL) {
  88. return 1;
  89. }
  90. return _attrib->compare_to(*other._attrib);
  91. }
  92. ////////////////////////////////////////////////////////////////////
  93. // Function: NodeAttributeWrapper::make_initial
  94. // Access: Public
  95. // Description: Resets the wrapper to the initial attribute.
  96. ////////////////////////////////////////////////////////////////////
  97. INLINE_GRAPH void NodeAttributeWrapper::
  98. make_initial() {
  99. _attrib.clear();
  100. }
  101. INLINE_GRAPH ostream &operator << (ostream &out, const NodeAttributeWrapper &naw) {
  102. naw.output(out);
  103. return out;
  104. }