Panda3D
workingNodePath.h
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file workingNodePath.h
10  * @author drose
11  * @date 2002-03-16
12  */
13 
14 #ifndef WORKINGNODEPATH_H
15 #define WORKINGNODEPATH_H
16 
17 #include "pandabase.h"
18 
19 #include "nodePath.h"
20 #include "nodePathComponent.h"
21 
22 /**
23  * This is a class designed to support low-overhead traversals of the complete
24  * scene graph, with a memory of the complete path through the graph at any
25  * given point.
26  *
27  * You could just use a regular NodePath to do this, but since the NodePath
28  * requires storing NodePathComponents on each node as it is constructed, and
29  * then removing them when it destructs, there is considerable overhead in
30  * that approach.
31  *
32  * The WorkingNodePath eliminates this overhead (but does not guarantee
33  * consistency if the scene graph changes while the path is held).
34  *
35  * At any given point, you may ask the WorkingNodePath for its actual
36  * NodePath, and it will construct and return a new NodePath representing the
37  * complete generated chain.
38  */
39 class EXPCL_PANDA_PGRAPH WorkingNodePath {
40 public:
41  INLINE WorkingNodePath(const NodePath &start);
42  INLINE WorkingNodePath(const WorkingNodePath &copy);
43  INLINE WorkingNodePath(const WorkingNodePath &parent, PandaNode *child);
44  INLINE ~WorkingNodePath();
45 
46  INLINE void operator = (const WorkingNodePath &copy);
47 
48  bool is_valid() const;
49 
50  INLINE NodePath get_node_path() const;
51  INLINE PandaNode *node() const;
52 
53  int get_num_nodes() const;
54  PandaNode *get_node(int index) const;
55 
56  void output(std::ostream &out) const;
57 
58 PUBLISHED:
59  MAKE_PROPERTY(valid, is_valid);
60  MAKE_PROPERTY(node_path, get_node_path);
61 
62 private:
63  PT(NodePathComponent) r_get_node_path() const;
64 
65  // Either one or the other of these pointers will be filled in, but never
66  // both. We maintain a linked list of WorkingNodePath objects, with a
67  // NodePathComponent at the head of the list.
68  const WorkingNodePath *_next;
69  PT(NodePathComponent) _start;
70 
71  PT(PandaNode) _node;
72 };
73 
74 INLINE std::ostream &operator << (std::ostream &out, const WorkingNodePath &node_path);
75 
76 #include "workingNodePath.I"
77 
78 #endif
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This is a class designed to support low-overhead traversals of the complete scene graph,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:161
This is one component of a NodePath.