Panda3D
 All Classes Functions Variables Enumerations
workingNodePath.h
1 // Filename: workingNodePath.h
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 #ifndef WORKINGNODEPATH_H
16 #define WORKINGNODEPATH_H
17 
18 #include "pandabase.h"
19 
20 #include "nodePath.h"
21 #include "nodePathComponent.h"
22 
23 ////////////////////////////////////////////////////////////////////
24 // Class : WorkingNodePath
25 // Description : This is a class designed to support low-overhead
26 // traversals of the complete scene graph, with a memory
27 // of the complete path through the graph at any given
28 // point.
29 //
30 // You could just use a regular NodePath to do this, but
31 // since the NodePath requires storing
32 // NodePathComponents on each node as it is constructed,
33 // and then removing them when it destructs, there is
34 // considerable overhead in that approach.
35 //
36 // The WorkingNodePath eliminates this overhead (but
37 // does not guarantee consistency if the scene graph
38 // changes while the path is held).
39 //
40 // At any given point, you may ask the WorkingNodePath
41 // for its actual NodePath, and it will construct and
42 // return a new NodePath representing the complete
43 // generated chain.
44 ////////////////////////////////////////////////////////////////////
45 class EXPCL_PANDA_PGRAPH WorkingNodePath {
46 public:
47  INLINE WorkingNodePath(const NodePath &start);
48  INLINE WorkingNodePath(const WorkingNodePath &copy);
49  INLINE WorkingNodePath(const WorkingNodePath &parent, PandaNode *child);
50  INLINE ~WorkingNodePath();
51 
52  INLINE void operator = (const WorkingNodePath &copy);
53 
54  bool is_valid() const;
55 
56  INLINE NodePath get_node_path() const;
57  INLINE PandaNode *node() const;
58 
59  int get_num_nodes() const;
60  PandaNode *get_node(int index) const;
61 
62  void output(ostream &out) const;
63 
64 private:
65  PT(NodePathComponent) r_get_node_path() const;
66 
67  // Either one or the other of these pointers will be filled in, but
68  // never both. We maintain a linked list of WorkingNodePath
69  // objects, with a NodePathComponent at the head of the list.
70  const WorkingNodePath *_next;
71  PT(NodePathComponent) _start;
72 
73  PT(PandaNode) _node;
74 };
75 
76 INLINE ostream &operator << (ostream &out, const WorkingNodePath &node_path);
77 
78 #include "workingNodePath.I"
79 
80 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:72
This is a class designed to support low-overhead traversals of the complete scene graph...
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.