Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/pgraph/workingNodePath.h

Go to the documentation of this file.
00001 // Filename: workingNodePath.h
00002 // Created by:  drose (16Mar02)
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 #ifndef WORKINGNODEPATH_H
00020 #define WORKINGNODEPATH_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "nodePath.h"
00025 #include "nodePathComponent.h"
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //       Class : WorkingNodePath
00029 // Description : This is a class designed to support low-overhead
00030 //               traversals of the complete scene graph, with a memory
00031 //               of the complete path through the graph at any given
00032 //               point.
00033 //
00034 //               You could just use a regular NodePath to do this, but
00035 //               since the NodePath requires storing
00036 //               NodePathComponents on each node as it is constructed,
00037 //               and then removing them when it destructs, there is
00038 //               considerable overhead in that approach.
00039 //
00040 //               The WorkingNodePath eliminates this overhead (but
00041 //               does not guarantee consistency if the scene graph
00042 //               changes while the path is held).
00043 //
00044 //               At any given point, you may ask the WorkingNodePath
00045 //               for its actual NodePath, and it will construct and
00046 //               return a new NodePath representing the complete
00047 //               generated chain.
00048 ////////////////////////////////////////////////////////////////////
00049 class EXPCL_PANDA WorkingNodePath {
00050 public:
00051   INLINE WorkingNodePath(const NodePath &start);
00052   INLINE WorkingNodePath(const WorkingNodePath &copy);
00053   INLINE WorkingNodePath(const WorkingNodePath &parent, PandaNode *child);
00054   INLINE ~WorkingNodePath();
00055 
00056   INLINE void operator = (const WorkingNodePath &copy);
00057 
00058   bool is_valid() const;
00059 
00060   INLINE NodePath get_node_path() const;
00061   INLINE PandaNode *node() const;
00062 
00063   int get_num_nodes() const;
00064   PandaNode *get_node(int index) const;
00065 
00066   void output(ostream &out) const;
00067 
00068 private:
00069   PT(NodePathComponent) r_get_node_path() const;
00070 
00071   // Either one or the other of these pointers will be filled in, but
00072   // never both.  We maintain a linked list of WorkingNodePath
00073   // objects, with a NodePathComponent at the head of the list.
00074   const WorkingNodePath *_next;
00075   PT(NodePathComponent) _start;
00076 
00077   PandaNode *_node;
00078 };
00079 
00080 INLINE ostream &operator << (ostream &out, const WorkingNodePath &node_path);
00081 
00082 #include "workingNodePath.I"
00083 
00084 #endif

Generated on Fri May 2 00:42:33 2003 for Panda by doxygen1.3