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:

## 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 PointerToVoid &other) const
bool | operator< (const void *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...
Public Member Functions inherited from MemoryBase
void | operator delete (void *, void *)
void | operator delete (void *ptr)
void | operator delete[] (void *, void *)
void | operator delete[] (void *ptr)
void * | operator new (size_t size)
void * | operator new (size_t size, void *ptr)
void * | operator new[] (size_t size)
void * | operator new[] (size_t size, void *ptr)

## 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 21 of file weakPointerToVoid.I.

## ◆ 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 58 of file weakPointerToVoid.I.

## ◆ remove_callback()

void WeakPointerToVoid::remove_callback | ( | WeakPointerCallback * | callback | ) | const
| inline

Removes a previously added callback.

Definition at line 34 of file weakPointerToVoid.I.

## ◆ 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 49 of file weakPointerToVoid.I.

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

- panda/src/express/weakPointerToVoid.h
- panda/src/express/weakPointerToVoid.I