nodePathComponent.I 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. // Filename: nodePathComponent.I
  2. // Created by: drose (25Feb02)
  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. ////////////////////////////////////////////////////////////////////
  19. // Function: NodePathComponent::CData::Constructor
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. INLINE NodePathComponent::CData::
  24. CData() {
  25. _length = 1;
  26. }
  27. ////////////////////////////////////////////////////////////////////
  28. // Function: NodePathComponent::CData::Copy Constructor
  29. // Access: Public
  30. // Description:
  31. ////////////////////////////////////////////////////////////////////
  32. INLINE NodePathComponent::CData::
  33. CData(const NodePathComponent::CData &copy) :
  34. _next(copy._next),
  35. _length(copy._length)
  36. {
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: NodePathComponent::Constructor
  40. // Access: Private
  41. // Description: Constructs a new NodePathComponent from the
  42. // indicated node. Don't try to call this directly; ask
  43. // the PandaNode to do it for you.
  44. ////////////////////////////////////////////////////////////////////
  45. INLINE NodePathComponent::
  46. NodePathComponent(PandaNode *node, NodePathComponent *next) :
  47. _node(node),
  48. _key(0)
  49. {
  50. #ifdef DO_MEMORY_USAGE
  51. MemoryUsage::update_type(this, get_class_type());
  52. #endif
  53. CDWriter cdata(_cycler);
  54. cdata->_next = next;
  55. if (next != (NodePathComponent *)NULL) {
  56. cdata->_length = next->get_length() + 1;
  57. }
  58. }
  59. ////////////////////////////////////////////////////////////////////
  60. // Function: NodePathComponent::Copy Constructor
  61. // Access: Private
  62. // Description: NodePathComponents should not be copied.
  63. ////////////////////////////////////////////////////////////////////
  64. INLINE NodePathComponent::
  65. NodePathComponent(const NodePathComponent &copy) {
  66. nassertv(false);
  67. }
  68. ////////////////////////////////////////////////////////////////////
  69. // Function: NodePathComponent::Copy Assignment Operator
  70. // Access: Private
  71. // Description: NodePathComponents should not be copied.
  72. ////////////////////////////////////////////////////////////////////
  73. INLINE void NodePathComponent::
  74. operator = (const NodePathComponent &copy) {
  75. nassertv(false);
  76. }
  77. ////////////////////////////////////////////////////////////////////
  78. // Function: NodePathComponent::Destructor
  79. // Access: Public
  80. // Description:
  81. ////////////////////////////////////////////////////////////////////
  82. INLINE NodePathComponent::
  83. ~NodePathComponent() {
  84. nassertv(_node != (PandaNode *)NULL);
  85. _node->delete_component(this);
  86. }
  87. ////////////////////////////////////////////////////////////////////
  88. // Function: NodePathComponent::get_node
  89. // Access: Public
  90. // Description: Returns the node referenced by this component.
  91. ////////////////////////////////////////////////////////////////////
  92. INLINE PandaNode *NodePathComponent::
  93. get_node() const {
  94. nassertr(_node != (PandaNode *)NULL, _node);
  95. return _node;
  96. }
  97. ////////////////////////////////////////////////////////////////////
  98. // Function: NodePathComponent::has_key
  99. // Access: Public
  100. // Description: Returns true if the key for this component has
  101. // already been generated, false otherwise. Even if
  102. // this returns false, calling get_key() will still
  103. // return a valid key; that will simply cause the key to
  104. // be generated on-the-fly.
  105. ////////////////////////////////////////////////////////////////////
  106. INLINE bool NodePathComponent::
  107. has_key() const {
  108. return (_key != 0);
  109. }
  110. INLINE ostream &operator << (ostream &out, const NodePathComponent &comp) {
  111. comp.output(out);
  112. return out;
  113. }