weakNodePath.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. // Filename: weakNodePath.h
  2. // Created by: drose (29Sep04)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #ifndef WEAKNODEPATH_H
  19. #define WEAKNODEPATH_H
  20. #include "pandabase.h"
  21. #include "nodePath.h"
  22. #include "nodePathComponent.h"
  23. #include "weakPointerTo.h"
  24. ////////////////////////////////////////////////////////////////////
  25. // Class : WeakNodePath
  26. // Description : This class is a wrapper around a NodePath that,
  27. // unlike the actual NodePath class, doesn't hold a
  28. // reference count to the node. Thus the node may be
  29. // detached from the scene graph and destructed at any
  30. // time.
  31. //
  32. // You can call is_valid() or was_deleted() at any time
  33. // to determine whether the node is still around; if it
  34. // is, get_node_path() will return the associated
  35. // NodePath.
  36. ////////////////////////////////////////////////////////////////////
  37. class EXPCL_PANDA WeakNodePath {
  38. public:
  39. INLINE WeakNodePath(const NodePath &node_path);
  40. INLINE WeakNodePath(const WeakNodePath &copy);
  41. INLINE ~WeakNodePath();
  42. INLINE void operator = (const NodePath &node_path);
  43. INLINE void operator = (const WeakNodePath &copy);
  44. INLINE bool is_empty() const;
  45. INLINE bool was_deleted() const;
  46. INLINE NodePath get_node_path() const;
  47. INLINE PandaNode *node() const;
  48. INLINE bool operator == (const NodePath &other) const;
  49. INLINE bool operator != (const NodePath &other) const;
  50. INLINE bool operator < (const NodePath &other) const;
  51. INLINE int compare_to(const NodePath &other) const;
  52. INLINE bool operator == (const WeakNodePath &other) const;
  53. INLINE bool operator != (const WeakNodePath &other) const;
  54. INLINE bool operator < (const WeakNodePath &other) const;
  55. INLINE int compare_to(const WeakNodePath &other) const;
  56. INLINE int get_key() const;
  57. void output(ostream &out) const;
  58. private:
  59. WPT(NodePathComponent) _head;
  60. int _backup_key;
  61. };
  62. INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path);
  63. #include "weakNodePath.I"
  64. #endif