]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: ptr_shrd.h | |
3 | // Purpose: documentation for wxSharedPtr<T> class | |
4 | // Author: wxWidgets team | |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxSharedPtrT | |
11 | @wxheader{ptr_shrd.h} | |
7c913512 | 12 | |
23324ae1 | 13 | A smart pointer with non-intrusive reference counting. It is modeled |
7c913512 | 14 | after @b boost::shared_ptr and can be used with STL containers |
23324ae1 FM |
15 | and wxVector - unlike @b std::auto_ptr |
16 | and wxScopedPtr. | |
7c913512 | 17 | |
23324ae1 FM |
18 | @library{wxbase} |
19 | @category{FIXME} | |
7c913512 | 20 | |
23324ae1 FM |
21 | @seealso |
22 | wxScopedPtr, wxWeakRef, wxObjectDataPtr | |
23 | */ | |
7c913512 | 24 | class wxSharedPtr<T> |
23324ae1 FM |
25 | { |
26 | public: | |
27 | //@{ | |
28 | /** | |
29 | Constructors. | |
30 | */ | |
31 | wxSharedPtrT(T* ptr = @NULL); | |
7c913512 | 32 | wxSharedPtrT(const wxSharedPtr<T>& tocopy); |
23324ae1 FM |
33 | //@} |
34 | ||
35 | /** | |
36 | Destructor. | |
37 | */ | |
38 | ~wxSharedPtrT(); | |
39 | ||
40 | /** | |
41 | Returns pointer to its object or @NULL. | |
42 | */ | |
43 | T* get(); | |
44 | ||
45 | /** | |
7c913512 | 46 | Conversion to a boolean expression (in a variant which is not |
23324ae1 FM |
47 | convertable to anything but a boolean expression). If this class |
48 | contains a valid pointer it will return @e @true, if it contains | |
49 | a @NULL pointer it will return @e @false. | |
50 | */ | |
7c913512 | 51 | operator unspecified_bool_type(); |
23324ae1 FM |
52 | |
53 | /** | |
54 | Returns a reference to the object. If the internal pointer is @NULL this | |
55 | method will cause an assert in debug mode. | |
56 | */ | |
57 | T operator*(); | |
58 | ||
59 | /** | |
60 | Returns pointer to its object or @NULL. | |
61 | */ | |
62 | T* operator-(); | |
63 | ||
64 | /** | |
65 | Assignment operator. Releases any previously held pointer | |
66 | and creates a reference to @e ptr. | |
67 | */ | |
68 | wxSharedPtrT& operator operator=(T * ptr); | |
69 | ||
70 | /** | |
71 | Reset pointer to @e ptr. If the reference count of the | |
72 | previously owned pointer was 1 it will be deleted. | |
73 | */ | |
74 | void reset(T * ptr = @NULL); | |
75 | ||
76 | /** | |
77 | Returns @true if this is the only pointer pointing to its object. | |
78 | */ | |
79 | bool unique(); | |
80 | ||
81 | /** | |
82 | Returns the number of pointers pointing to its object. | |
83 | */ | |
84 | long use_count(); | |
85 | }; |