]> git.saurik.com Git - wxWidgets.git/blob - interface/ptr_shrd.h
added interface headers with latest discussed changes
[wxWidgets.git] / interface / ptr_shrd.h
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}
12
13 A smart pointer with non-intrusive reference counting. It is modeled
14 after @b boost::shared_ptr and can be used with STL containers
15 and wxVector - unlike @b std::auto_ptr
16 and wxScopedPtr.
17
18 @library{wxbase}
19 @category{FIXME}
20
21 @seealso
22 wxScopedPtr, wxWeakRef, wxObjectDataPtr
23 */
24 class wxSharedPtr<T>
25 {
26 public:
27 //@{
28 /**
29 Constructors.
30 */
31 wxSharedPtrT(T* ptr = @NULL);
32 wxSharedPtrT(const wxSharedPtr<T>& tocopy);
33 //@}
34
35 /**
36 Destructor.
37 */
38 ~wxSharedPtrT();
39
40 /**
41 Returns pointer to its object or @NULL.
42 */
43 T* get();
44
45 /**
46 Conversion to a boolean expression (in a variant which is not
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 */
51 operator unspecified_bool_type();
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 };