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

This is the base class for PointerTo and ConstPointerTo. More...

#include "weakPointerToBase.h"

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

Public Types

typedef T To
 

Public Member Functions

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 != (std::nullptr_t) const
 
bool operator != (const WeakPointerToBase< To > &other) const
 
bool operator != (const PointerToBase< To > &other) const
 Returns false if both pointers point to the same object. More...
 
bool operator > (const To *other) const
 
bool operator > (To *other) const
 
bool operator > (std::nullptr_t) const
 
bool operator > (const WeakPointerToBase< To > &other) const
 Defines an ordering between WeakPointerTo based on their raw pointer value. More...
 
bool operator > (const PointerToBase< To > &other) const
 
bool operator >= (const To *other) const
 
bool operator >= (To *other) const
 
bool operator >= (std::nullptr_t) const
 
bool operator >= (const WeakPointerToBase< To > &other) const
 Defines an ordering between WeakPointerTo based on their raw pointer value. More...
 
bool operator >= (const PointerToBase< To > &other) const
 
bool operator< (const To *other) const
 
bool operator< (std::nullptr_t) const
 
bool operator< (const WeakPointerToBase< To > &other) const
 Defines an ordering between WeakPointerTo based on their raw pointer value. More...
 
bool operator< (const PointerToBase< To > &other) const
 
bool operator<= (const To *other) const
 
bool operator<= (To *other) const
 
bool operator<= (std::nullptr_t) const
 
bool operator<= (const WeakPointerToBase< To > &other) const
 Defines an ordering between WeakPointerTo based on their raw pointer value. More...
 
bool operator<= (const PointerToBase< To > &other) const
 
bool operator== (const To *other) const
 
bool operator== (To *other) const
 
bool operator== (std::nullptr_t) const
 
bool operator== (const WeakPointerToBase< To > &other) const
 Returns true if both pointers have the same raw pointer value. More...
 
bool operator== (const PointerToBase< To > &other) const
 Returns true if both pointers point to the same object. More...
 
void output (std::ostream &out) const
 A handy function to output PointerTo's as a hex pointer followed by a reference count. More...
 
template<class Y >
bool owner_before (const WeakPointerToBase< Y > &other) const noexcept
 Defines an ordering that is guaranteed to remain consistent even after the weak pointers have expired. More...
 
template<class Y >
bool owner_before (const PointerToBase< Y > &other) const noexcept
 Defines an ordering that is guaranteed to remain consistent even after this weak pointer has expired. More...
 
void refresh () const
 Informs the WeakPointerTo object that its pointer is no longer deleted. More...
 
- Public Member Functions inherited from WeakPointerToVoid
void add_callback (WeakPointerCallback *callback) const
 Sets a callback that will be made when the pointer is deleted. More...
 
bool is_valid_pointer () const
 Returns true if the pointer is not null and the object has not been deleted. More...
 
void remove_callback (WeakPointerCallback *callback) const
 Removes a previously added callback. 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
 
constexpr 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...
 

Friends

template<typename Y >
class WeakPointerToBase
 

Detailed Description

template<class T>
class WeakPointerToBase< T >

This is the base class for PointerTo and ConstPointerTo.

Don't try to use it directly; use either derived class instead.

Definition at line 26 of file weakPointerToBase.h.

Member Function Documentation

◆ clear()

template<class T >
void WeakPointerToBase< T >::clear ( )
inline

A convenient way to set the PointerTo object to NULL.

(Assignment to a NULL pointer also works, of course.)

Definition at line 623 of file weakPointerToBase.I.

References WeakReferenceList::unref().

◆ operator !=() [1/2]

template<class T >
bool WeakPointerToBase< T >::operator != ( const WeakPointerToBase< To > &  other) const
inline
See also
operator ==

Definition at line 470 of file weakPointerToBase.I.

◆ operator !=() [2/2]

template<class T >
bool WeakPointerToBase< T >::operator != ( const PointerToBase< To > &  other) const
inline

Returns false if both pointers point to the same object.

Definition at line 518 of file weakPointerToBase.I.

◆ operator >()

template<class T >
bool WeakPointerToBase< T >::operator > ( const WeakPointerToBase< To > &  other) const
inline

Defines an ordering between WeakPointerTo based on their raw pointer value.

Definition at line 480 of file weakPointerToBase.I.

◆ operator >=()

template<class T >
bool WeakPointerToBase< T >::operator >= ( const WeakPointerToBase< To > &  other) const
inline

Defines an ordering between WeakPointerTo based on their raw pointer value.

Definition at line 500 of file weakPointerToBase.I.

◆ operator<()

template<class T >
bool WeakPointerToBase< T >::operator< ( const WeakPointerToBase< To > &  other) const
inline

Defines an ordering between WeakPointerTo based on their raw pointer value.

Definition at line 573 of file weakPointerToBase.I.

◆ operator<=()

template<class T >
bool WeakPointerToBase< T >::operator<= ( const WeakPointerToBase< To > &  other) const
inline

Defines an ordering between WeakPointerTo based on their raw pointer value.

Definition at line 490 of file weakPointerToBase.I.

◆ operator==() [1/2]

template<class T >
bool WeakPointerToBase< T >::operator== ( const WeakPointerToBase< To > &  other) const
inline

Returns true if both pointers have the same raw pointer value.

For this to be meaningful, neither pointer may have expired, since if one has expired while the other was allocated at the expired pointer's memory address, this comparison will be true even though they didn't refer to the same object.

See also
owner_before

Definition at line 461 of file weakPointerToBase.I.

◆ operator==() [2/2]

template<class T >
bool WeakPointerToBase< T >::operator== ( const PointerToBase< To > &  other) const
inline

Returns true if both pointers point to the same object.

Definition at line 509 of file weakPointerToBase.I.

◆ output()

template<class T >
void WeakPointerToBase< T >::output ( std::ostream &  out) const
inline

A handy function to output PointerTo's as a hex pointer followed by a reference count.

Definition at line 656 of file weakPointerToBase.I.

References WeakReferenceList::was_deleted().

◆ owner_before() [1/2]

template<class T >
template<class Y >
bool WeakPointerToBase< T >::owner_before ( const WeakPointerToBase< Y > &  other) const
inlinenoexcept

Defines an ordering that is guaranteed to remain consistent even after the weak pointers have expired.

This may result in two pointers with the same get_orig() value comparing unequal if one of them is a new object that was allocated at the same memory address as the older, expired pointer.

Definition at line 597 of file weakPointerToBase.I.

◆ owner_before() [2/2]

template<class T >
template<class Y >
bool WeakPointerToBase< T >::owner_before ( const PointerToBase< Y > &  other) const
inlinenoexcept

Defines an ordering that is guaranteed to remain consistent even after this weak pointer has expired.

This may result in two pointers with the same get_orig() value comparing unequal if one of them is a new object that was allocated at the same memory address as the older, expired pointer.

Definition at line 610 of file weakPointerToBase.I.

◆ refresh()

template<class T >
void WeakPointerToBase< T >::refresh ( ) const
inline

Informs the WeakPointerTo object that its pointer is no longer deleted.

This may be used after a WeakPointerTo has deleted a deleted pointer, and then a new pointer has been reallocated. It's equivalent to simply reassigning the pointer to its new (i.e. original) value, but has the advantage that it is const, so can be used for WeakPointers used as keys in STL maps and sets.

Definition at line 644 of file weakPointerToBase.I.


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