#include <wx/windowptr.h>
A reference-counted smart pointer for holding wxWindow instances.
This specialization of wxSharedPtr<T> is useful for holding wxWindow-derived objects. Unlike wxSharedPtr<T> or std::shared_ptr<>
, it doesn't use the delete operator to destroy the value when reference count drops to zero, but calls wxWindow::Destroy() to safely destroy the window.
The template parameter T must be wxWindow or a class derived from it.
Public Member Functions | |
wxWindowPtr () | |
Default constructor. | |
wxWindowPtr (T *ptr) | |
Constructor. | |
template<typename Deleter > | |
wxWindowPtr (T *ptr, Deleter d) | |
Constructor. | |
wxWindowPtr (const wxWindowPtr< T > &tocopy) | |
Copy constructor. | |
wxWindowPtr< T > & | operator= (T *ptr) |
Assignment operator. | |
wxWindowPtr< T > & | operator= (const wxWindowPtr< T > &tocopy) |
Assignment operator. | |
void | reset (T *ptr=NULL) |
Reset pointer to ptr. | |
Public Member Functions inherited from wxSharedPtr< T > | |
wxEXPLICIT | wxSharedPtr (T *ptr=NULL) |
Constructor. | |
template<typename Deleter > | |
wxEXPLICIT | wxSharedPtr (T *ptr, Deleter d) |
Constructor. | |
wxSharedPtr (const wxSharedPtr< T > &tocopy) | |
Copy constructor. | |
~wxSharedPtr () | |
Destructor. | |
T * | get () const |
Returns pointer to its object or NULL. | |
operator unspecified_bool_type () const | |
Conversion to a boolean expression (in a variant which is not convertible to anything but a boolean expression). | |
T | operator* () const |
Returns a reference to the object. | |
T * | operator-> () const |
Smart pointer member access. | |
wxSharedPtr< T > & | operator= (T *ptr) |
Assignment operator. | |
wxSharedPtr< T > & | operator= (const wxSharedPtr< T > &tocopy) |
Assignment operator. | |
void | reset (T *ptr=NULL) |
Reset pointer to ptr. | |
template<typename Deleter > | |
void | reset (T *ptr, Deleter d) |
Reset pointer to ptr. | |
bool | unique () const |
Returns true if this is the only pointer pointing to its object. | |
long | use_count () const |
Returns the number of pointers pointing to its object. | |
wxWindowPtr< T >::wxWindowPtr | ( | ) |
Default constructor.
|
explicit |
Constructor.
Creates shared pointer from the raw pointer ptr and takes ownership of it.
|
explicit |
Constructor.
Creates shared pointer from the raw pointer ptr and deleter d and takes ownership of it.
ptr | The raw pointer. |
d | Deleter - a functor that is called instead of delete to free the ptr raw pointer when its reference count drops to zero. |
wxWindowPtr< T >::wxWindowPtr | ( | const wxWindowPtr< T > & | tocopy | ) |
Copy constructor.
wxWindowPtr<T>& wxWindowPtr< T >::operator= | ( | T * | ptr | ) |
Assignment operator.
Releases any previously held pointer and creates a reference to ptr.
wxWindowPtr<T>& wxWindowPtr< T >::operator= | ( | const wxWindowPtr< T > & | tocopy | ) |
Assignment operator.
Releases any previously held pointer and creates a reference to the same object as topcopy.
void wxWindowPtr< T >::reset | ( | T * | ptr = NULL | ) |
Reset pointer to ptr.
If the reference count of the previously owned pointer was 1 it will be deleted.