Panda3D
Public Member Functions | List of all members
WeakPointerToVoid Class Reference

This is the specialization of PointerToVoid for weak pointers. More...

#include "weakPointerToVoid.h"

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

Public Member Functions

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...
 

Detailed Description

This is the specialization of PointerToVoid for weak pointers.

It needs an additional flag to indicate that the pointer has been deleted.

Definition at line 26 of file weakPointerToVoid.h.

Member Function Documentation

◆ add_callback()

void WeakPointerToVoid::add_callback ( WeakPointerCallback callback) const
inline

Sets a callback that will be made when the pointer is deleted.

Does nothing if this is a null pointer.

If the pointer has already been deleted, the callback will be made immediately.

Definition at line 22 of file weakPointerToVoid.I.

References WeakReferenceList::add_callback(), and WeakReferenceList::was_deleted().

◆ is_valid_pointer()

bool WeakPointerToVoid::is_valid_pointer ( ) const
inline

Returns true if the pointer is not null and the object has not been deleted.

See was_deleted() for caveats.

Definition at line 59 of file weakPointerToVoid.I.

References WeakReferenceList::was_deleted().

◆ remove_callback()

void WeakPointerToVoid::remove_callback ( WeakPointerCallback callback) const
inline

Removes a previously added callback.

Definition at line 35 of file weakPointerToVoid.I.

References WeakReferenceList::remove_callback().

◆ was_deleted()

bool WeakPointerToVoid::was_deleted ( ) const
inline

Returns true if the object we are pointing to has been deleted, false otherwise.

If this returns true, it means that the pointer can not yet be reused, but it does not guarantee that it can be safely accessed. See the lock() method for a safe way to access the underlying pointer.

This will always return true for a null pointer, unlike is_valid_pointer().

Definition at line 50 of file weakPointerToVoid.I.

References WeakReferenceList::was_deleted().


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