]>
git.saurik.com Git - wxWidgets.git/blob - interface/wx/windowptr.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: interface/wx/windowptr.h
3 // Purpose: wxWindowPtr<T> class documentation.
4 // Author: Vaclav Slavik
6 // Copyright: (c) 2013 Vaclav Slavik <vslavik@fastmail.fm>
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
11 A reference-counted smart pointer for holding wxWindow instances.
13 This specialization of wxSharedPtr<T> is useful for holding
14 wxWindow-derived objects. Unlike wxSharedPtr<T> or @c std::shared_ptr<>, it
15 doesn't use the delete operator to destroy the value when reference count
16 drops to zero, but calls wxWindow::Destroy() to safely destroy the window.
18 The template parameter T must be wxWindow or a class derived from it.
21 @category{smartpointers}
28 class wxWindowPtr
<T
> : public wxSharedPtr
<T
>
31 /// Default constructor.
37 Creates shared pointer from the raw pointer @a ptr and takes ownership
40 explicit wxWindowPtr(T
* ptr
);
45 Creates shared pointer from the raw pointer @a ptr and deleter @a d
46 and takes ownership of it.
48 @param ptr The raw pointer.
49 @param d Deleter - a functor that is called instead of delete to
50 free the @a ptr raw pointer when its reference count drops to
54 template<typename Deleter
>
55 explicit wxWindowPtr(T
* ptr
, Deleter d
);
58 wxWindowPtr(const wxWindowPtr
<T
>& tocopy
);
63 Releases any previously held pointer and creates a reference to @a ptr.
65 wxWindowPtr
<T
>& operator=(T
* ptr
);
70 Releases any previously held pointer and creates a reference to the
71 same object as @a topcopy.
73 wxWindowPtr
<T
>& operator=(const wxWindowPtr
<T
>& tocopy
);
76 Reset pointer to @a ptr.
78 If the reference count of the previously owned pointer was 1 it will be deleted.
80 void reset(T
* ptr
= NULL
);