// Filename: weakPointerTo.I // Created by: drose (27Sep04) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of // the license at http://etc.cmu.edu/panda3d/docs/license/ . // // To contact the maintainers of this program write to // panda3d-general@lists.sourceforge.net . // //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo:: WeakPointerTo(To *ptr) : WeakPointerToBase(ptr) { } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo:: WeakPointerTo(const PointerTo ©) : WeakPointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo:: WeakPointerTo(const WeakPointerTo ©) : WeakPointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Dereference operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME WeakPointerTo::To &WeakPointerTo:: operator *() const { nassertr(!this->was_deleted(), *((To *)NULL)); return *((To *)WeakPointerToBase::_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Member access operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: operator -> () const { nassertr(!this->was_deleted(), (To *)NULL); return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Typecast operator // Access: Public // Description: We also have the typecast operator to automatically // convert WeakPointerTo's to the required kind of actual // pointer. This introduces ambiguities which the // compiler will resolve one way or the other, but we // don't care which way it goes because either will be // correct. //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo:: operator T * () const { nassertr(!this->was_deleted(), (To *)NULL); return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::p // Access: Public // Description: Returns an ordinary pointer instead of a WeakPointerTo. // Useful to work around compiler problems, particularly // for implicit upcasts. //////////////////////////////////////////////////////////////////// template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: p() const { nassertr(!this->was_deleted(), (To *)NULL); return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::get_orig // Access: Public // Description: Returns the original pointer value, even if the // object has since been deleted. //////////////////////////////////////////////////////////////////// template INLINE TYPENAME WeakPointerTo::To *WeakPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo &WeakPointerTo:: operator = (To *ptr) { reassign(ptr); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo &WeakPointerTo:: operator = (const PointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakPointerTo &WeakPointerTo:: operator = (const WeakPointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo:: WeakConstPointerTo(const To *ptr) : WeakPointerToBase((TYPENAME WeakConstPointerTo::To *)ptr) { } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo:: WeakConstPointerTo(const PointerTo ©) : WeakPointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo:: WeakConstPointerTo(const ConstPointerTo ©) : WeakPointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakPointerTo ©) : WeakPointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakConstPointerTo ©) : WeakPointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Dereference operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME WeakConstPointerTo::To &WeakConstPointerTo:: operator *() const { nassertr(!this->was_deleted(), *((To *)NULL)); return *((To *)WeakPointerToBase::_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Member access operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: operator -> () const { nassertr(!this->was_deleted(), (To *)NULL); return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Typecast operator // Access: Public // Description: We also have the typecast operator to automatically // convert WeakConstPointerTo's to the required kind of actual // pointer. This introduces ambiguities which the // compiler will resolve one way or the other, but we // don't care which way it goes because either will be // correct. //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo:: operator const T * () const { nassertr(!this->was_deleted(), (To *)NULL); return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::p // Access: Public // Description: Returns an ordinary pointer instead of a WeakConstPointerTo. // Useful to work around compiler problems, particularly // for implicit upcasts. //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: p() const { nassertr(!this->was_deleted(), (To *)NULL); return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::get_orig // Access: Public // Description: Returns the original pointer value, even if the // object has since been deleted. //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME WeakConstPointerTo::To *WeakConstPointerTo:: get_orig() const { return (To *)WeakPointerToBase::_void_ptr; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const To *ptr) { reassign((To *)ptr); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const PointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const ConstPointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakPointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: WeakConstPointerTo::Assignment operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakConstPointerTo ©) { reassign((const PointerToBase &)copy); return *this; }