File: windowptr.h

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (82 lines) | stat: -rw-r--r-- 2,321 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
///////////////////////////////////////////////////////////////////////////////
// Name:        interface/wx/windowptr.h
// Purpose:     wxWindowPtr<T> class documentation.
// Author:      Vaclav Slavik
// Created:     2013-09-02
// Copyright:   (c) 2013 Vaclav Slavik <vslavik@fastmail.fm>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

/**
    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 @c 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.

    @library{wxcore}
    @category{smartpointers}

    @since 3.0

    @see wxSharedPtr<T>
*/
template<typename T>
class wxWindowPtr<T> : public wxSharedPtr<T>
{
public:
    /// Default constructor.
    wxWindowPtr();

    /**
        Constructor.

        Creates shared pointer from the raw pointer @a ptr and takes ownership
        of it.
    */
    explicit wxWindowPtr(T* ptr);

    /**
        Constructor.

        Creates shared pointer from the raw pointer @a ptr and deleter @a d
        and takes ownership of it.

        @param ptr  The raw pointer.
        @param d    Deleter - a functor that is called instead of delete to
                    free the @a ptr raw pointer when its reference count drops to
                    zero.

    */
    template<typename Deleter>
    explicit wxWindowPtr(T* ptr, Deleter d);

    /// Copy constructor.
    wxWindowPtr(const wxWindowPtr<T>& tocopy);

    /**
        Assignment operator.

        Releases any previously held pointer and creates a reference to @a ptr.
    */
    wxWindowPtr<T>& operator=(T* ptr);

    /**
        Assignment operator.

        Releases any previously held pointer and creates a reference to the
        same object as @a topcopy.
    */
    wxWindowPtr<T>& operator=(const wxWindowPtr<T>& tocopy);

    /**
        Reset pointer to @a ptr.

        If the reference count of the previously owned pointer was 1 it will be deleted.
    */
    void reset(T* ptr = NULL);
};