00001 // Filename: nodePathComponent.I 00002 // Created by: drose (25Feb02) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: NodePathComponent::CData::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 INLINE NodePathComponent::CData:: 00026 CData() { 00027 _length = 1; 00028 } 00029 00030 //////////////////////////////////////////////////////////////////// 00031 // Function: NodePathComponent::CData::Copy Constructor 00032 // Access: Public 00033 // Description: 00034 //////////////////////////////////////////////////////////////////// 00035 INLINE NodePathComponent::CData:: 00036 CData(const NodePathComponent::CData ©) : 00037 _next(copy._next), 00038 _length(copy._length) 00039 { 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: NodePathComponent::Constructor 00044 // Access: Private 00045 // Description: Constructs a new NodePathComponent from the 00046 // indicated node. Don't try to call this directly; ask 00047 // the PandaNode to do it for you. 00048 //////////////////////////////////////////////////////////////////// 00049 INLINE NodePathComponent:: 00050 NodePathComponent(PandaNode *node, NodePathComponent *next) : 00051 _node(node), 00052 _key(0) 00053 { 00054 #ifdef DO_MEMORY_USAGE 00055 MemoryUsage::update_type(this, get_class_type()); 00056 #endif 00057 CDWriter cdata(_cycler); 00058 cdata->_next = next; 00059 00060 if (next != (NodePathComponent *)NULL) { 00061 cdata->_length = next->get_length() + 1; 00062 } 00063 } 00064 00065 //////////////////////////////////////////////////////////////////// 00066 // Function: NodePathComponent::Copy Constructor 00067 // Access: Private 00068 // Description: NodePathComponents should not be copied. 00069 //////////////////////////////////////////////////////////////////// 00070 INLINE NodePathComponent:: 00071 NodePathComponent(const NodePathComponent ©) { 00072 nassertv(false); 00073 } 00074 00075 //////////////////////////////////////////////////////////////////// 00076 // Function: NodePathComponent::Copy Assignment Operator 00077 // Access: Private 00078 // Description: NodePathComponents should not be copied. 00079 //////////////////////////////////////////////////////////////////// 00080 INLINE void NodePathComponent:: 00081 operator = (const NodePathComponent ©) { 00082 nassertv(false); 00083 } 00084 00085 00086 //////////////////////////////////////////////////////////////////// 00087 // Function: NodePathComponent::Destructor 00088 // Access: Public 00089 // Description: 00090 //////////////////////////////////////////////////////////////////// 00091 INLINE NodePathComponent:: 00092 ~NodePathComponent() { 00093 nassertv(_node != (PandaNode *)NULL); 00094 _node->delete_component(this); 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: NodePathComponent::get_node 00099 // Access: Public 00100 // Description: Returns the node referenced by this component. 00101 //////////////////////////////////////////////////////////////////// 00102 INLINE PandaNode *NodePathComponent:: 00103 get_node() const { 00104 // We don't have to bother checking if the component has been 00105 // collapsed here, since the _node pointer will still be the same 00106 // even if it has. 00107 nassertr(_node != (PandaNode *)NULL, _node); 00108 return _node; 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: NodePathComponent::is_collapsed 00113 // Access: Public 00114 // Description: Returns true if this component has been collapsed 00115 // with another component. In this case, the component 00116 // itself is invalid, and the collapsed component should 00117 // be used instead. 00118 //////////////////////////////////////////////////////////////////// 00119 INLINE bool NodePathComponent:: 00120 is_collapsed() const { 00121 CDReader cdata(_cycler); 00122 return (cdata->_length == 0); 00123 } 00124 00125 //////////////////////////////////////////////////////////////////// 00126 // Function: NodePathComponent::get_collapsed 00127 // Access: Public 00128 // Description: If is_collapsed() returns true, this is the component 00129 // that this one has been collapsed with, and should be 00130 // replaced with. 00131 //////////////////////////////////////////////////////////////////// 00132 INLINE NodePathComponent *NodePathComponent:: 00133 get_collapsed() const { 00134 nassertr(is_collapsed(), (NodePathComponent *)NULL); 00135 CDReader cdata(_cycler); 00136 return cdata->_next; 00137 } 00138 00139 INLINE ostream &operator << (ostream &out, const NodePathComponent &comp) { 00140 comp.output(out); 00141 return out; 00142 } 00143