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