]> git.saurik.com Git - wxWidgets.git/blame - interface/wx/ptr_shrd.h
Moved wxPGChoices m_choices member from various property classes to base wxPGProperty...
[wxWidgets.git] / interface / wx / ptr_shrd.h
CommitLineData
23324ae1
FM
1/////////////////////////////////////////////////////////////////////////////
2// Name: ptr_shrd.h
e54c96f1 3// Purpose: interface of wxSharedPtr<T>
23324ae1
FM
4// Author: wxWidgets team
5// RCS-ID: $Id$
6// Licence: wxWindows license
7/////////////////////////////////////////////////////////////////////////////
8
9/**
7c913512 10
9fa8c9bf 11 A smart pointer with non-intrusive reference counting. It is modeled after
b1b95a65
FM
12 @c boost::shared_ptr<> and can be used with STL containers and wxVector<T> -
13 unlike @c std::auto_ptr<> and wxScopedPtr<T>.
7c913512 14
23324ae1 15 @library{wxbase}
9fa8c9bf 16 @category{smartpointers}
7c913512 17
73473b3e 18 @see wxScopedPtr<T>, wxWeakRef<T>, wxObjectDataPtr<T>
23324ae1 19*/
b1b95a65 20
9fa8c9bf 21template<typename T>
7c913512 22class wxSharedPtr<T>
23324ae1
FM
23{
24public:
23324ae1 25 /**
9fa8c9bf
VS
26 Constructor.
27
28 Creates shared pointer from the raw pointer @a ptr and takes ownership
29 of it.
23324ae1 30 */
b1b95a65 31 wxEXPLICIT wxSharedPtr(T* ptr = NULL);
9fa8c9bf 32
b1b95a65
FM
33 /**
34 Copy constructor.
35 */
9fa8c9bf 36 wxSharedPtr(const wxSharedPtr<T>& tocopy);
23324ae1
FM
37
38 /**
39 Destructor.
40 */
5cb947fd 41 ~wxSharedPtr();
23324ae1
FM
42
43 /**
44 Returns pointer to its object or @NULL.
45 */
328f5751 46 T* get() const;
23324ae1
FM
47
48 /**
7c913512 49 Conversion to a boolean expression (in a variant which is not
b1b95a65
FM
50 convertable to anything but a boolean expression).
51
52 If this class contains a valid pointer it will return @true, if it contains
53 a @NULL pointer it will return @false.
23324ae1 54 */
328f5751 55 operator unspecified_bool_type() const;
23324ae1
FM
56
57 /**
b1b95a65
FM
58 Returns a reference to the object.
59
60 If the internal pointer is @NULL this method will cause an assert in debug mode.
23324ae1 61 */
328f5751 62 T operator*() const;
23324ae1
FM
63
64 /**
65 Returns pointer to its object or @NULL.
66 */
b1b95a65 67 T* operator->() const;
23324ae1
FM
68
69 /**
b1b95a65
FM
70 Assignment operator.
71
72 Releases any previously held pointer and creates a reference to @a ptr.
23324ae1 73 */
b1b95a65 74 wxSharedPtr<T>& operator=(T* ptr);
23324ae1
FM
75
76 /**
b1b95a65
FM
77 Assignment operator.
78
79 Releases any previously held pointer and creates a reference to the
80 same object as @a topcopy.
81 */
82 wxSharedPtr<T>& operator=(const wxSharedPtr<T>& tocopy)
83
84 /**
85 Reset pointer to @a ptr.
86
87 If the reference count of the previously owned pointer was 1 it will be deleted.
23324ae1 88 */
4cc4bfaf 89 void reset(T* ptr = NULL);
23324ae1
FM
90
91 /**
92 Returns @true if this is the only pointer pointing to its object.
93 */
328f5751 94 bool unique() const;
23324ae1
FM
95
96 /**
97 Returns the number of pointers pointing to its object.
98 */
328f5751 99 long use_count() const;
23324ae1 100};
e54c96f1 101