// Filename: pointerTo.I // Created by: drose (10Feb99) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) Carnegie Mellon University. All rights reserved. // // All use of this software is subject to the terms of the revised BSD // license. You should have received a copy of this license along // with this source code in a file named "LICENSE." // //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// // 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 T * () 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) { this->reassign(ptr); return *this; } //////////////////////////////////////////////////////////////////// // Function: PointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE PointerTo &PointerTo:: operator = (const PointerTo ©) { this->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 T * () 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) { this->reassign((To *)ptr); return *this; } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo &ConstPointerTo:: operator = (const PointerTo ©) { this->reassign((const PointerToBase &)copy); return *this; } //////////////////////////////////////////////////////////////////// // Function: ConstPointerTo::Assignment operator // Access: Published // Description: //////////////////////////////////////////////////////////////////// template INLINE ConstPointerTo &ConstPointerTo:: operator = (const ConstPointerTo ©) { this->reassign((const PointerToBase &)copy); return *this; }