// Filename: pointerTo.I // Created by: drose (10Feb99) // //////////////////////////////////////////////////////////////////// // // 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: PointerTo::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerTo:: PointerTo(To *ptr) : PointerToBase(ptr) { } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerTo:: PointerTo(const PointerTo ©) : PointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Destructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerTo:: ~PointerTo() { } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Dereference operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME PointerTo::To &PointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Member access operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE TYPENAME PointerTo::To *PointerTo:: operator -> () const { return (To *)(this->_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Typecast operator // Access: Public // Description: We also have the typecast operator to automatically // convert PointerTo'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 PointerTo:: operator TYPENAME PointerToBase::To *() const { return (To *)(this->_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: PointerTo::p // Access: Published // Description: Returns an ordinary pointer instead of a PointerTo. // Useful to work around compiler problems, particularly // for implicit upcasts. //////////////////////////////////////////////////////////////////// template INLINE TYPENAME PointerTo::To *PointerTo:: p() const { return (To *)(this->_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerTo &PointerTo:: operator = (To *ptr) { reassign(ptr); return *this; } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerTo &PointerTo:: operator = (const PointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo:: ConstPointerTo(const TYPENAME ConstPointerTo::To *ptr) : PointerToBase((TYPENAME ConstPointerTo::To *)ptr) { } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo:: ConstPointerTo(const PointerTo ©) : PointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Destructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo:: ~ConstPointerTo() { } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Copy Constructor // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo:: ConstPointerTo(const ConstPointerTo ©) : PointerToBase((const PointerToBase &)copy) { } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Dereference operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME ConstPointerTo::To &ConstPointerTo:: operator *() const { return *((To *)(this->_void_ptr)); } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Member access operator // Access: Public // Description: //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME ConstPointerTo::To *ConstPointerTo:: operator -> () const { return (To *)(this->_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Typecast operator // Access: Public // Description: We also have the typecast operator to automatically // convert ConstPointerTo'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 ConstPointerTo:: operator const TYPENAME PointerToBase::To *() const { return (To *)(this->_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::p // Access: Published // Description: Returns an ordinary pointer instead of a ConstPointerTo. // Useful to work around compiler problems, particularly // for implicit upcasts. //////////////////////////////////////////////////////////////////// template INLINE const TYPENAME ConstPointerTo::To *ConstPointerTo:: p() const { return (To *)(this->_void_ptr); } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo &ConstPointerTo:: operator = (const To *ptr) { reassign((To *)ptr); return *this; } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo &ConstPointerTo:: operator = (const PointerTo ©) { reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo &ConstPointerTo:: operator = (const ConstPointerTo ©) { reassign((const PointerToBase &)copy); return *this; }