Panda3D
 All Classes Functions Variables Enumerations
workingNodePath.I
1 // Filename: workingNodePath.I
2 // Created by: drose (16Mar02)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 
16 ////////////////////////////////////////////////////////////////////
17 // Function: WorkingNodePath::Constructor
18 // Access: Public
19 // Description: Creates a WorkingNodePath that is the same as the
20 // indicated NodePath. This is generally used to begin
21 // the traversal of a scene graph with the root
22 // NodePath.
23 ////////////////////////////////////////////////////////////////////
24 INLINE WorkingNodePath::
25 WorkingNodePath(const NodePath &start) {
26  nassertv(!start.is_empty());
27  _next = (WorkingNodePath *)NULL;
28  _start = start._head;
29  _node = start.node();
30 }
31 
32 ////////////////////////////////////////////////////////////////////
33 // Function: WorkingNodePath::Copy Constructor
34 // Access: Public
35 // Description:
36 ////////////////////////////////////////////////////////////////////
37 INLINE WorkingNodePath::
38 WorkingNodePath(const WorkingNodePath &copy) :
39  _next(copy._next),
40  _start(copy._start),
41  _node(copy._node)
42 {
43  nassertv(_next != (WorkingNodePath *)NULL ||
44  _start != (NodePathComponent *)NULL);
45 }
46 
47 ////////////////////////////////////////////////////////////////////
48 // Function: WorkingNodePath::Constructor
49 // Access: Public
50 // Description: Creates a WorkingNodePath that is the same as the
51 // indicated WorkingNodePath, plus one node. This is
52 // generally used to continue the traversal to the next
53 // node.
54 ////////////////////////////////////////////////////////////////////
55 INLINE WorkingNodePath::
56 WorkingNodePath(const WorkingNodePath &parent, PandaNode *child) {
57  _next = &parent;
58  _start = (NodePathComponent *)NULL;
59  _node = child;
60  nassertv(_node != _next->_node);
61 }
62 
63 ////////////////////////////////////////////////////////////////////
64 // Function: WorkingNodePath::Destructor
65 // Access: Public
66 // Description:
67 ////////////////////////////////////////////////////////////////////
68 INLINE WorkingNodePath::
69 ~WorkingNodePath() {
70 }
71 
72 ////////////////////////////////////////////////////////////////////
73 // Function: WorkingNodePath::Copy Assignment Operator
74 // Access: Public
75 // Description:
76 ////////////////////////////////////////////////////////////////////
77 INLINE void WorkingNodePath::
78 operator = (const WorkingNodePath &copy) {
79  _next = copy._next;
80  _start = copy._start;
81  _node = copy._node;
82 
83  nassertv(_next != (WorkingNodePath *)NULL ||
84  _start != (NodePathComponent *)NULL);
85 }
86 
87 ////////////////////////////////////////////////////////////////////
88 // Function: WorkingNodePath::get_node_path
89 // Access: Public
90 // Description: Constructs and returns an actual NodePath that
91 // represents the same path we have just traversed.
92 ////////////////////////////////////////////////////////////////////
94 get_node_path() const {
95  NodePath result;
96  result._head = r_get_node_path();
97  nassertr(result._head != (NodePathComponent *)NULL, NodePath::fail());
98  return result;
99 }
100 
101 ////////////////////////////////////////////////////////////////////
102 // Function: WorkingNodePath::node
103 // Access: Public
104 // Description: Returns the node traversed to so far.
105 ////////////////////////////////////////////////////////////////////
107 node() const {
108  return _node;
109 }
110 
111 INLINE ostream &
112 operator << (ostream &out, const WorkingNodePath &node_path) {
113  node_path.output(out);
114  return out;
115 }
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
WorkingNodePath(const NodePath &start)
Creates a WorkingNodePath that is the same as the indicated NodePath.
PandaNode * node() const
Returns the referenced node of the path.
Definition: nodePath.I:284
This is a class designed to support low-overhead traversals of the complete scene graph...
PandaNode * node() const
Returns the node traversed to so far.
static NodePath fail()
Creates a NodePath with the ET_fail error type set.
Definition: nodePath.I:185
NodePath get_node_path() const
Constructs and returns an actual NodePath that represents the same path we have just traversed...
bool is_empty() const
Returns true if the NodePath contains no nodes.
Definition: nodePath.I:236
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:165
This is one component of a NodePath.