From 14f118b672809a78a971acdc75e2e2dec915d6e9 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 20 May 2018 15:56:58 +0200 Subject: [PATCH] pgraph: expose WeakNodePath to Python --- panda/src/pgraph/weakNodePath.I | 18 ++++++++++++++++++ panda/src/pgraph/weakNodePath.h | 7 ++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/panda/src/pgraph/weakNodePath.I b/panda/src/pgraph/weakNodePath.I index 5e323bc3c1..613afe0800 100644 --- a/panda/src/pgraph/weakNodePath.I +++ b/panda/src/pgraph/weakNodePath.I @@ -56,6 +56,24 @@ operator = (const WeakNodePath ©) { _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. */ diff --git a/panda/src/pgraph/weakNodePath.h b/panda/src/pgraph/weakNodePath.h index 763df494ac..dc82431023 100644 --- a/panda/src/pgraph/weakNodePath.h +++ b/panda/src/pgraph/weakNodePath.h @@ -30,7 +30,7 @@ * associated NodePath. */ class EXPCL_PANDA_PGRAPH WeakNodePath { -public: +PUBLISHED: INLINE WeakNodePath(const NodePath &node_path); INLINE WeakNodePath(const WeakNodePath ©); INLINE ~WeakNodePath(); @@ -38,6 +38,9 @@ public: INLINE void operator = (const NodePath &node_path); INLINE void operator = (const WeakNodePath ©); + INLINE void clear(); + + INLINE operator bool () const; INLINE bool is_empty() const; INLINE bool was_deleted() const; @@ -61,6 +64,8 @@ public: private: WPT(NodePathComponent) _head; mutable int _backup_key; + + friend class NodePath; }; INLINE ostream &operator << (ostream &out, const WeakNodePath &node_path);