Panda3D

weakNodePath.h

00001 // Filename: weakNodePath.h
00002 // Created by:  drose (29Sep04)
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 WEAKNODEPATH_H
00016 #define WEAKNODEPATH_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "nodePath.h"
00021 #include "nodePathComponent.h"
00022 #include "weakPointerTo.h"
00023 
00024 ////////////////////////////////////////////////////////////////////
00025 //       Class : WeakNodePath
00026 // Description : This class is a wrapper around a NodePath that,
00027 //               unlike the actual NodePath class, doesn't hold a
00028 //               reference count to the node.  Thus the node may be
00029 //               detached from the scene graph and destructed at any
00030 //               time.
00031 //
00032 //               You can call is_valid() or was_deleted() at any time
00033 //               to determine whether the node is still around; if it
00034 //               is, get_node_path() will return the associated
00035 //               NodePath.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA_PGRAPH WeakNodePath {
00038 public:
00039   INLINE WeakNodePath(const NodePath &node_path);
00040   INLINE WeakNodePath(const WeakNodePath &copy);
00041   INLINE ~WeakNodePath();
00042 
00043   INLINE void operator = (const NodePath &node_path);
00044   INLINE void operator = (const WeakNodePath &copy);
00045 
00046   INLINE bool is_empty() const;
00047   INLINE bool was_deleted() const;
00048 
00049   INLINE NodePath get_node_path() const;
00050   INLINE PandaNode *node() const;
00051 
00052   INLINE bool operator == (const NodePath &other) const;
00053   INLINE bool operator != (const NodePath &other) const;
00054   INLINE bool operator < (const NodePath &other) const;
00055   INLINE int compare_to(const NodePath &other) const;
00056 
00057   INLINE bool operator == (const WeakNodePath &other) const;
00058   INLINE bool operator != (const WeakNodePath &other) const;
00059   INLINE bool operator < (const WeakNodePath &other) const;
00060   INLINE int compare_to(const WeakNodePath &other) const;
00061 
00062   INLINE int get_key() const;
00063 
00064   void output(ostream &out) const;
00065 
00066 private:
00067   WPT(NodePathComponent) _head;
00068   int _backup_key;
00069 };
00070 
00071 INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path);
00072 
00073 #include "weakNodePath.I"
00074 
00075 #endif
 All Classes Functions Variables Enumerations