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