Browse Source

pgraph: expose WeakNodePath to Python

rdb 7 years ago
parent
commit
14f118b672
2 changed files with 24 additions and 1 deletions
  1. 18 0
      panda/src/pgraph/weakNodePath.I
  2. 6 1
      panda/src/pgraph/weakNodePath.h

+ 18 - 0
panda/src/pgraph/weakNodePath.I

@@ -56,6 +56,24 @@ operator = (const WeakNodePath &copy) {
   _backup_key = copy._backup_key;
   _backup_key = copy._backup_key;
 }
 }
 
 
+/**
+ * Sets this NodePath to the empty NodePath.  It will no longer point to any
+ * node.
+ */
+INLINE void WeakNodePath::
+clear() {
+  _head.clear();
+  _backup_key = 0;
+}
+
+/**
+ * Returns true if this NodePath points to a valid, non-null node.
+ */
+INLINE WeakNodePath::
+operator bool () const {
+  return _head.is_valid_pointer();
+}
+
 /**
 /**
  * Returns true if the NodePath contains no nodes, or if it has been deleted.
  * Returns true if the NodePath contains no nodes, or if it has been deleted.
  */
  */

+ 6 - 1
panda/src/pgraph/weakNodePath.h

@@ -30,7 +30,7 @@
  * associated NodePath.
  * associated NodePath.
  */
  */
 class EXPCL_PANDA_PGRAPH WeakNodePath {
 class EXPCL_PANDA_PGRAPH WeakNodePath {
-public:
+PUBLISHED:
   INLINE WeakNodePath(const NodePath &node_path);
   INLINE WeakNodePath(const NodePath &node_path);
   INLINE WeakNodePath(const WeakNodePath &copy);
   INLINE WeakNodePath(const WeakNodePath &copy);
   INLINE ~WeakNodePath();
   INLINE ~WeakNodePath();
@@ -38,6 +38,9 @@ public:
   INLINE void operator = (const NodePath &node_path);
   INLINE void operator = (const NodePath &node_path);
   INLINE void operator = (const WeakNodePath &copy);
   INLINE void operator = (const WeakNodePath &copy);
 
 
+  INLINE void clear();
+
+  INLINE operator bool () const;
   INLINE bool is_empty() const;
   INLINE bool is_empty() const;
   INLINE bool was_deleted() const;
   INLINE bool was_deleted() const;
 
 
@@ -61,6 +64,8 @@ public:
 private:
 private:
   WPT(NodePathComponent) _head;
   WPT(NodePathComponent) _head;
   mutable int _backup_key;
   mutable int _backup_key;
+
+  friend class NodePath;
 };
 };
 
 
 INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path);
 INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path);