Panda3D
 All Classes Functions Variables Enumerations
workingNodePath.h
00001 // Filename: workingNodePath.h
00002 // Created by:  drose (16Mar02)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef WORKINGNODEPATH_H
00016 #define WORKINGNODEPATH_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "nodePath.h"
00021 #include "nodePathComponent.h"
00022 
00023 ////////////////////////////////////////////////////////////////////
00024 //       Class : WorkingNodePath
00025 // Description : This is a class designed to support low-overhead
00026 //               traversals of the complete scene graph, with a memory
00027 //               of the complete path through the graph at any given
00028 //               point.
00029 //
00030 //               You could just use a regular NodePath to do this, but
00031 //               since the NodePath requires storing
00032 //               NodePathComponents on each node as it is constructed,
00033 //               and then removing them when it destructs, there is
00034 //               considerable overhead in that approach.
00035 //
00036 //               The WorkingNodePath eliminates this overhead (but
00037 //               does not guarantee consistency if the scene graph
00038 //               changes while the path is held).
00039 //
00040 //               At any given point, you may ask the WorkingNodePath
00041 //               for its actual NodePath, and it will construct and
00042 //               return a new NodePath representing the complete
00043 //               generated chain.
00044 ////////////////////////////////////////////////////////////////////
00045 class EXPCL_PANDA_PGRAPH WorkingNodePath {
00046 public:
00047   INLINE WorkingNodePath(const NodePath &start);
00048   INLINE WorkingNodePath(const WorkingNodePath &copy);
00049   INLINE WorkingNodePath(const WorkingNodePath &parent, PandaNode *child);
00050   INLINE ~WorkingNodePath();
00051 
00052   INLINE void operator = (const WorkingNodePath &copy);
00053 
00054   bool is_valid() const;
00055 
00056   INLINE NodePath get_node_path() const;
00057   INLINE PandaNode *node() const;
00058 
00059   int get_num_nodes() const;
00060   PandaNode *get_node(int index) const;
00061 
00062   void output(ostream &out) const;
00063 
00064 private:
00065   PT(NodePathComponent) r_get_node_path() const;
00066 
00067   // Either one or the other of these pointers will be filled in, but
00068   // never both.  We maintain a linked list of WorkingNodePath
00069   // objects, with a NodePathComponent at the head of the list.
00070   const WorkingNodePath *_next;
00071   PT(NodePathComponent) _start;
00072 
00073   PT(PandaNode) _node;
00074 };
00075 
00076 INLINE ostream &operator << (ostream &out, const WorkingNodePath &node_path);
00077 
00078 #include "workingNodePath.I"
00079 
00080 #endif
 All Classes Functions Variables Enumerations