Panda3D
weakNodePath.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 weakNodePath.h
10  * @author drose
11  * @date 2004-09-29
12  */
13 
14 #ifndef WEAKNODEPATH_H
15 #define WEAKNODEPATH_H
16 
17 #include "pandabase.h"
18 
19 #include "nodePath.h"
20 #include "nodePathComponent.h"
21 #include "weakPointerTo.h"
22 
23 /**
24  * This class is a wrapper around a NodePath that, unlike the actual NodePath
25  * class, doesn't hold a reference count to the node. Thus the node may be
26  * detached from the scene graph and destructed at any time.
27  *
28  * You can call is_valid() or was_deleted() at any time to determine whether
29  * the node is still around; if it is, get_node_path() will return the
30  * associated NodePath.
31  */
32 class EXPCL_PANDA_PGRAPH WeakNodePath {
33 PUBLISHED:
34  INLINE WeakNodePath(const NodePath &node_path);
35  INLINE WeakNodePath(const WeakNodePath &copy);
36  INLINE ~WeakNodePath();
37 
38  INLINE void operator = (const NodePath &node_path);
39  INLINE void operator = (const WeakNodePath &copy);
40 
41  INLINE void clear();
42 
43  INLINE operator bool () const;
44  INLINE bool is_empty() const;
45  INLINE bool was_deleted() const;
46 
47  INLINE NodePath get_node_path() const;
48  INLINE PT(PandaNode) node() const;
49 
50  INLINE bool operator == (const NodePath &other) const;
51  INLINE bool operator != (const NodePath &other) const;
52  INLINE bool operator < (const NodePath &other) const;
53  INLINE int compare_to(const NodePath &other) const;
54 
55  INLINE bool operator == (const WeakNodePath &other) const;
56  INLINE bool operator != (const WeakNodePath &other) const;
57  INLINE bool operator < (const WeakNodePath &other) const;
58  INLINE int compare_to(const WeakNodePath &other) const;
59 
60  INLINE int get_key() const;
61 
62  void output(std::ostream &out) const;
63 
64 private:
65  WPT(NodePathComponent) _head;
66  mutable int _backup_key;
67 
68  friend class NodePath;
69 };
70 
71 INLINE std::ostream &operator << (std::ostream &out, const WeakNodePath &node_path);
72 
73 #include "weakNodePath.I"
74 
75 #endif
nodePath.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
pandabase.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
compare_to
An STL function object class, this is intended to be used on any ordered collection of class objects ...
Definition: stl_compares.h:73
nodePathComponent.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
Definition: nodePath.h:159
NodePathComponent
This is one component of a NodePath.
Definition: nodePathComponent.h:42
weakPointerTo.h
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
weakNodePath.I
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
WeakNodePath
This class is a wrapper around a NodePath that, unlike the actual NodePath class, doesn't hold a refe...
Definition: weakNodePath.h:32
PandaNode
A basic node of the scene graph or data graph.
Definition: pandaNode.h:64