From 5d73bc8e192c694b4f983b265e7de4e6998f36b8 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 20 Jan 2009 03:17:59 +0000 Subject: [PATCH] operator bool() --- panda/src/pgraph/nodePath.I | 11 +++++++++++ panda/src/pgraph/nodePath.h | 2 ++ 2 files changed, 13 insertions(+) diff --git a/panda/src/pgraph/nodePath.I b/panda/src/pgraph/nodePath.I index bf9e92c0f9..40e20810d4 100644 --- a/panda/src/pgraph/nodePath.I +++ b/panda/src/pgraph/nodePath.I @@ -222,6 +222,17 @@ is_empty() const { return (_head == (NodePathComponent *)NULL); } +//////////////////////////////////////////////////////////////////// +// Function: NodePath::operator bool +// Access: Published +// Description: Returns true if the NodePath is valid (not empty), +// or false if it contains no nodes. +//////////////////////////////////////////////////////////////////// +INLINE NodePath:: +operator bool () const { + return !is_empty(); +} + //////////////////////////////////////////////////////////////////// // Function: NodePath::is_singleton // Access: Published diff --git a/panda/src/pgraph/nodePath.h b/panda/src/pgraph/nodePath.h index 17326e63ed..4f9a929c7f 100644 --- a/panda/src/pgraph/nodePath.h +++ b/panda/src/pgraph/nodePath.h @@ -177,6 +177,8 @@ PUBLISHED: // Methods to query a NodePath's contents. INLINE bool is_empty() const; + INLINE operator bool () const; + INLINE bool is_singleton(Thread *current_thread = Thread::get_current_thread()) const; int get_num_nodes(Thread *current_thread = Thread::get_current_thread()) const; PandaNode *get_node(int index, Thread *current_thread = Thread::get_current_thread()) const;