/** * 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." * * @file weakPointerTo.I * @author drose * @date 2004-09-27 */ /** * */ template INLINE WeakPointerTo:: WeakPointerTo(To *ptr) : WeakPointerToBase(ptr) { } /** * */ template INLINE WeakPointerTo:: WeakPointerTo(const PointerTo ©) : WeakPointerToBase(*(const PointerToBase *)©) { } /** * */ template INLINE WeakPointerTo:: WeakPointerTo(const WeakPointerTo ©) : WeakPointerToBase(*(const WeakPointerToBase *)©) { } /** * */ template INLINE WeakPointerTo:: WeakPointerTo(WeakPointerTo &&from) noexcept : WeakPointerToBase(std::move(from)) { } /** * */ template template ALWAYS_INLINE WeakPointerTo:: WeakPointerTo(const WeakPointerTo &r) noexcept : WeakPointerToBase(r) { } /** * */ template template ALWAYS_INLINE WeakPointerTo:: WeakPointerTo(const PointerTo &r) noexcept : WeakPointerToBase(r) { } /** * */ template template ALWAYS_INLINE WeakPointerTo:: WeakPointerTo(WeakPointerTo &&r) noexcept : WeakPointerToBase(std::move(r)) { } /** * */ template INLINE typename WeakPointerTo::To &WeakPointerTo:: operator *() const { assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); } /** * */ template INLINE typename WeakPointerTo::To *WeakPointerTo:: operator -> () const { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } /** * 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 { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } /** * A thread-safe way to access the underlying pointer; will silently return * null if the underlying pointer was deleted or null. * Note that this may return null even if was_deleted() still returns false, * which can occur if the object has reached reference count 0 and is about to * be destroyed. * * @since 1.10.0 */ template INLINE PointerTo WeakPointerTo:: lock() const { PointerTo ptr; this->lock_into(ptr); return ptr; } /** * 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 { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } /** * 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; } /** * */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (To *ptr) { ((WeakPointerTo *)this)->reassign(ptr); return *this; } /** * */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (const PointerTo ©) { ((WeakPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } /** * */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (const WeakPointerTo ©) { ((WeakPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } /** * */ template INLINE WeakPointerTo &WeakPointerTo:: operator = (WeakPointerTo &&from) noexcept { this->reassign(std::move(from)); return *this; } /** * */ template template ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: operator = (const WeakPointerTo &r) noexcept { this->reassign(r); return *this; } /** * */ template template ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: operator = (const PointerTo &r) noexcept { this->reassign(r); return *this; } /** * */ template template ALWAYS_INLINE WeakPointerTo &WeakPointerTo:: operator = (WeakPointerTo &&r) noexcept { this->reassign(std::move(r)); return *this; } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const To *ptr) : WeakPointerToBase((typename WeakConstPointerTo::To *)ptr) { } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const PointerTo ©) : WeakPointerToBase(*(const PointerToBase *)©) { } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const ConstPointerTo ©) : WeakPointerToBase(*(const PointerToBase *)©) { } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakPointerTo ©) : WeakPointerToBase(*(const WeakPointerToBase *)©) { } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakConstPointerTo ©) : WeakPointerToBase(*(const WeakPointerToBase *)©) { } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(WeakPointerTo &&from) noexcept : WeakPointerToBase(std::move(from)) { } /** * */ template INLINE WeakConstPointerTo:: WeakConstPointerTo(WeakConstPointerTo &&from) noexcept : WeakPointerToBase(std::move(from)) { } /** * */ template template ALWAYS_INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakPointerTo &r) noexcept : WeakPointerToBase(r) { } /** * */ template template ALWAYS_INLINE WeakConstPointerTo:: WeakConstPointerTo(const WeakConstPointerTo &r) noexcept : WeakPointerToBase(r) { } /** * */ template template ALWAYS_INLINE WeakConstPointerTo:: WeakConstPointerTo(const PointerTo &r) noexcept : WeakPointerToBase(r) { } /** * */ template template ALWAYS_INLINE WeakConstPointerTo:: WeakConstPointerTo(const ConstPointerTo &r) noexcept : WeakPointerToBase(r) { } /** * */ template template ALWAYS_INLINE WeakConstPointerTo:: WeakConstPointerTo(WeakPointerTo &&r) noexcept : WeakPointerToBase(std::move(r)) { } /** * */ template template ALWAYS_INLINE WeakConstPointerTo:: WeakConstPointerTo(WeakConstPointerTo &&r) noexcept : WeakPointerToBase(std::move(r)) { } /** * */ template INLINE const typename WeakConstPointerTo::To &WeakConstPointerTo:: operator *() const { assert(!this->was_deleted()); return *((To *)WeakPointerToBase::_void_ptr); } /** * */ template INLINE const typename WeakConstPointerTo::To *WeakConstPointerTo:: operator -> () const { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } /** * 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 { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } /** * A thread-safe way to access the underlying pointer; will silently return * null if the underlying pointer was deleted or null. * Note that this may return null even if was_deleted() still returns false, * which can occur if the object has reached reference count 0 and is about to * be destroyed. * * @since 1.10.0 */ template INLINE ConstPointerTo WeakConstPointerTo:: lock() const { ConstPointerTo ptr; this->lock_into(ptr); return ptr; } /** * 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 { assert(!this->was_deleted()); return (To *)WeakPointerToBase::_void_ptr; } /** * 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; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const To *ptr) { ((WeakConstPointerTo *)this)->reassign((To *)ptr); return *this; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const PointerTo ©) { ((WeakConstPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const ConstPointerTo ©) { ((WeakConstPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakPointerTo ©) { ((WeakConstPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakConstPointerTo ©) { ((WeakConstPointerTo *)this)->reassign(*(const PointerToBase *)©); return *this; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (WeakPointerTo &&from) noexcept { this->reassign(std::move(from)); return *this; } /** * */ template INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (WeakConstPointerTo &&from) noexcept { this->reassign(std::move(from)); return *this; } /** * */ template template ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakPointerTo &r) noexcept { this->reassign(r); return *this; } /** * */ template template ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const WeakConstPointerTo &r) noexcept { this->reassign(r); return *this; } /** * */ template template ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const PointerTo &r) noexcept { this->reassign(r); return *this; } /** * */ template template ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (const ConstPointerTo &r) noexcept { this->reassign(r); return *this; } /** * */ template template ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (WeakPointerTo &&r) noexcept { this->reassign(std::move(r)); return *this; } /** * */ template template ALWAYS_INLINE WeakConstPointerTo &WeakConstPointerTo:: operator = (WeakConstPointerTo &&r) noexcept { this->reassign(std::move(r)); return *this; }