#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. More... | |
wxWindowPtr (T *ptr) | |
Constructor. More... | |
template<typename Deleter > | |
wxWindowPtr (T *ptr, Deleter d) | |
Constructor. More... | |
wxWindowPtr (const wxWindowPtr< T > &tocopy) | |
Copy constructor. More... | |
wxWindowPtr< T > & | operator= (T *ptr) |
Assignment operator. More... | |
wxWindowPtr< T > & | operator= (const wxWindowPtr< T > &tocopy) |
Assignment operator. More... | |
void | reset (T *ptr=NULL) |
Reset pointer to ptr. More... | |
Public Member Functions inherited from wxSharedPtr< T > | |
wxEXPLICIT | wxSharedPtr (T *ptr=NULL) |
Constructor. More... | |
template<typename Deleter > | |
wxEXPLICIT | wxSharedPtr (T *ptr, Deleter d) |
Constructor. More... | |
wxSharedPtr (const wxSharedPtr< T > &tocopy) | |
Copy constructor. More... | |
~wxSharedPtr () | |
Destructor. More... | |
T * | get () const |
Returns pointer to its object or NULL. More... | |
operator unspecified_bool_type () const | |
Conversion to a boolean expression (in a variant which is not convertible to anything but a boolean expression). More... | |
T | operator* () const |
Returns a reference to the object. More... | |
T * | operator-> () const |
Smart pointer member access. More... | |
wxSharedPtr< T > & | operator= (T *ptr) |
Assignment operator. More... | |
wxSharedPtr< T > & | operator= (const wxSharedPtr< T > &tocopy) |
Assignment operator. More... | |
void | reset (T *ptr=NULL) |
Reset pointer to ptr. More... | |
template<typename Deleter > | |
void | reset (T *ptr, Deleter d) |
Reset pointer to ptr. More... | |
bool | unique () const |
Returns true if this is the only pointer pointing to its object. More... | |
long | use_count () const |
Returns the number of pointers pointing to its object. More... | |
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.