Panda3D
Public Types | Public Member Functions | List of all members
WeakPointerTo< T > Class Template Reference

WeakPointerTo is similar to PointerTo, except that it does not actually prevent the referenced pointer from deleting. More...

#include "weakPointerTo.h"

Inheritance diagram for WeakPointerTo< T >:
WeakPointerToBase< T > WeakPointerToVoid PointerToVoid MemoryBase

Public Types

typedef WeakPointerToBase< T >::To To
 
- Public Types inherited from WeakPointerToBase< T >
typedef T To
 

Public Member Functions

 WeakPointerTo (To *ptr=(To *) NULL)
 
 WeakPointerTo (const PointerTo< T > &copy)
 
 WeakPointerTo (const WeakPointerTo< T > &copy)
 
void clear ()
 
To * get_orig () const
 Returns the original pointer value, even if the object has since been deleted. More...
 
 operator T* () const
 We also have the typecast operator to automatically convert WeakPointerTo's to the required kind of actual pointer. More...
 
To & operator* () const
 
To * operator-> () const
 
WeakPointerTo< T > & operator= (To *ptr)
 
WeakPointerTo< T > & operator= (const PointerTo< T > &copy)
 
WeakPointerTo< T > & operator= (const WeakPointerTo< T > &copy)
 
To * p () const
 Returns an ordinary pointer instead of a WeakPointerTo. More...
 
- Public Member Functions inherited from WeakPointerToBase< T >
void clear ()
 A convenient way to set the PointerTo object to NULL. More...
 
bool operator!= (const To *other) const
 
bool operator!= (To *other) const
 
bool operator!= (const WeakPointerToBase< To > &other) const
 
bool operator!= (const PointerToBase< To > &other) const
 
bool operator< (const To *other) const
 
bool operator< (const WeakPointerToBase< To > &other) const
 
bool operator< (const PointerToBase< To > &other) const
 
bool operator<= (const To *other) const
 
bool operator<= (To *other) const
 
bool operator<= (const WeakPointerToBase< To > &other) const
 
bool operator<= (const PointerToBase< To > &other) const
 
bool operator== (const To *other) const
 
bool operator== (To *other) const
 
bool operator== (const WeakPointerToBase< To > &other) const
 
bool operator== (const PointerToBase< To > &other) const
 
bool operator> (const To *other) const
 
bool operator> (To *other) const
 
bool operator> (const WeakPointerToBase< To > &other) const
 
bool operator> (const PointerToBase< To > &other) const
 
bool operator>= (const To *other) const
 
bool operator>= (To *other) const
 
bool operator>= (const WeakPointerToBase< To > &other) const
 
bool operator>= (const PointerToBase< To > &other) const
 
void output (ostream &out) const
 A handy function to output PointerTo's as a hex pointer followed by a reference count. More...
 
void refresh () const
 Informs the WeakPointerTo object that its pointer is no longer deleted. More...
 
- Public Member Functions inherited from WeakPointerToVoid
WeakPointerCallbackget_callback () const
 Returns the callback that will be made when the pointer is deleted, or NULL if no callback has been set. More...
 
bool is_valid_pointer () const
 Returns true if the pointer is not null and the object has not been deleted. More...
 
void mark_deleted ()
 This is intended only to be called by the WeakPointerList destructor. More...
 
void set_callback (WeakPointerCallback *callback)
 Sets a callback that will be made when the pointer is deleted. More...
 
bool was_deleted () const
 Returns true if the object we are pointing to has been deleted, false otherwise. More...
 
- Public Member Functions inherited from PointerToVoid
size_t get_hash () const
 
bool is_null () const
 Returns true if the PointerTo is a NULL pointer, false otherwise. More...
 
bool operator!= (const PointerToVoid &other) const
 
bool operator< (const void *other) const
 
bool operator< (const PointerToVoid &other) const
 
bool operator== (const PointerToVoid &other) const
 
void swap (PointerToVoid &other) NOEXCEPT
 Swaps the contents of this PointerTo with the other, without touching the reference counts. More...
 

Detailed Description

template<class T>
class WeakPointerTo< T >

WeakPointerTo is similar to PointerTo, except that it does not actually prevent the referenced pointer from deleting.

Instead, the referenced pointer is allowed to delete, but if this happens then was_deleted() will return true, and it will be an assertion error to dereference the pointer thereafter.

Definition at line 32 of file weakPointerTo.h.

Member Function Documentation

◆ get_orig()

template<class T >
WeakPointerTo< T >::To * WeakPointerTo< T >::get_orig ( ) const
inline

Returns the original pointer value, even if the object has since been deleted.

Definition at line 113 of file weakPointerTo.I.

References WeakPointerToVoid::was_deleted().

Referenced by WeakPointerTo< T >::p().

◆ operator T*()

template<class T >
WeakPointerTo< T >::operator T* ( ) const
inline

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.

Definition at line 86 of file weakPointerTo.I.

References WeakPointerTo< T >::p(), and WeakPointerToVoid::was_deleted().

◆ p()

template<class T >
WeakPointerTo< T >::To * WeakPointerTo< T >::p ( ) const
inline

Returns an ordinary pointer instead of a WeakPointerTo.

Useful to work around compiler problems, particularly for implicit upcasts.

Definition at line 100 of file weakPointerTo.I.

References WeakPointerTo< T >::get_orig(), and WeakPointerToVoid::was_deleted().

Referenced by WeakPointerTo< T >::operator T*().


The documentation for this class was generated from the following files: