Panda3D
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes

WeakConstPointerTo< T > Class Template Reference

A WeakConstPointerTo is similar to a WeakPointerTo, except it keeps a const pointer to the thing, that will be cleared to NULL when the thing deleted. More...

#include "weakPointerTo.h"

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

List of all members.

Public Types

typedef WeakPointerToBase< T >::To To

Public Member Functions

 WeakConstPointerTo (const To *ptr=(const To *) NULL)
 WeakConstPointerTo (const PointerTo< T > &copy)
 WeakConstPointerTo (const WeakPointerTo< T > &copy)
 WeakConstPointerTo (const WeakConstPointerTo< T > &copy)
 WeakConstPointerTo (const ConstPointerTo< T > &copy)
void clear ()
 A convenient way to set the PointerTo object to NULL.
WeakPointerCallbackget_callback () const
 Returns the callback that will be made when the pointer is deleted, or NULL if no callback has been set.
size_t get_hash () const
const To * get_orig () const
 Returns the original pointer value, even if the object has since been deleted.
bool is_null () const
 Returns true if the PointerTo is a NULL pointer, false otherwise.
bool is_valid_pointer () const
 Returns true if the pointer is not null and the object has not been deleted.
void mark_deleted ()
 This is intended only to be called by the WeakPointerList destructor.
 operator const T * () const
 We also have the typecast operator to automatically convert WeakConstPointerTo's to the required kind of actual pointer.
void operator delete (void *ptr)
void operator delete (void *ptr, void *)
void operator delete[] (void *ptr)
void operator delete[] (void *, void *)
void * operator new (size_t size)
void * operator new (size_t size, void *ptr)
void * operator new[] (size_t size, void *ptr)
void * operator new[] (size_t size)
bool operator!= (const PointerToBase< To > &other) const
bool operator!= (const To *other) const
bool operator!= (const WeakPointerToBase< To > &other) const
bool operator!= (To *other) const
bool operator!= (const PointerToVoid &other) const
const To & operator* () const
const To * operator-> () const
bool operator< (const To *other) const
bool operator< (const WeakPointerToBase< To > &other) const
bool operator< (const PointerToBase< To > &other) const
bool operator< (const PointerToVoid &other) const
bool operator< (const void *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
WeakConstPointerTo< T > & operator= (const PointerTo< T > &copy)
WeakConstPointerTo< T > & operator= (const To *ptr)
WeakConstPointerTo< T > & operator= (const ConstPointerTo< T > &copy)
WeakConstPointerTo< T > & operator= (const WeakPointerTo< T > &copy)
WeakConstPointerTo< T > & operator= (const WeakConstPointerTo< T > &copy)
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 PointerToVoid &other) const
bool operator> (const To *other) const
bool operator> (const PointerToBase< To > &other) const
bool operator> (To *other) const
bool operator> (const WeakPointerToBase< To > &other) const
bool operator>= (const To *other) const
bool operator>= (const PointerToBase< To > &other) const
bool operator>= (const WeakPointerToBase< To > &other) const
bool operator>= (To *other) const
void output (ostream &out) const
 A handy function to output PointerTo's as a hex pointer followed by a reference count.
const To * p () const
 Returns an ordinary pointer instead of a WeakConstPointerTo.
void refresh () const
 Informs the WeakPointerTo object that its pointer is no longer deleted.
void set_callback (WeakPointerCallback *callback)
 Sets a callback that will be made when the pointer is deleted.
bool was_deleted () const
 Returns true if the object we are pointing to has been deleted, false otherwise.

Protected Member Functions

void reassign (To *ptr)
 This is the main work of the PointerTo family.
void reassign (const WeakPointerToBase< To > &copy)
void reassign (const PointerToBase< To > &copy)

Protected Attributes

WeakPointerCallback_callback
bool _ptr_was_deleted
void * _void_ptr

Detailed Description

template<class T>
class WeakConstPointerTo< T >

A WeakConstPointerTo is similar to a WeakPointerTo, except it keeps a const pointer to the thing, that will be cleared to NULL when the thing deleted.

Definition at line 69 of file weakPointerTo.h.


Member Function Documentation

template<class T>
void WeakConstPointerTo< T >::clear ( ) [inline]

A convenient way to set the PointerTo object to NULL.

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

Reimplemented from WeakPointerToBase< T >.

Definition at line 99 of file weakPointerTo.h.

WeakPointerCallback * WeakPointerToVoid::get_callback ( ) const [inline, inherited]

Returns the callback that will be made when the pointer is deleted, or NULL if no callback has been set.

Definition at line 79 of file weakPointerToVoid.I.

template<class T >
const WeakConstPointerTo< T >::To * WeakConstPointerTo< T >::get_orig ( ) const [inline]

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

Definition at line 277 of file weakPointerTo.I.

template<class T>
bool WeakConstPointerTo< T >::is_null ( ) const [inline]

Returns true if the PointerTo is a NULL pointer, false otherwise.

(Direct comparison to a NULL pointer also works.)

Reimplemented from PointerToVoid.

Definition at line 98 of file weakPointerTo.h.

bool WeakPointerToVoid::is_valid_pointer ( ) const [inline, inherited]

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

Definition at line 101 of file weakPointerToVoid.I.

void WeakPointerToVoid::mark_deleted ( ) [inline, inherited]

This is intended only to be called by the WeakPointerList destructor.

It indicates that the object that we were pointing to has just been deleted.

Definition at line 45 of file weakPointerToVoid.I.

template<class T >
WeakConstPointerTo< T >::operator const T * ( ) const [inline]

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.

Definition at line 250 of file weakPointerTo.I.

template<class T >
void WeakPointerToBase< T >::output ( ostream &  out) const [inline, inherited]

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

Definition at line 424 of file weakPointerToBase.I.

template<class T >
const WeakConstPointerTo< T >::To * WeakConstPointerTo< T >::p ( ) const [inline]

Returns an ordinary pointer instead of a WeakConstPointerTo.

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

Definition at line 264 of file weakPointerTo.I.

template<class T >
void WeakPointerToBase< T >::reassign ( To *  ptr) [protected, inherited]

This is the main work of the PointerTo family.

When the pointer is reassigned, decrement the old reference count and increment the new one.

Definition at line 69 of file weakPointerToBase.I.

References TypeHandle::none().

template<class T >
void WeakPointerToBase< T >::refresh ( ) const [inline, inherited]

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 412 of file weakPointerToBase.I.

void WeakPointerToVoid::set_callback ( WeakPointerCallback callback) [inline, inherited]

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

If a previous callback has already been set, it will be replaced.

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

Definition at line 64 of file weakPointerToVoid.I.

bool WeakPointerToVoid::was_deleted ( ) const [inline, inherited]

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

Definition at line 90 of file weakPointerToVoid.I.


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations