]> git.saurik.com Git - wxWidgets.git/blob - interface/ptr_shrd.h
Switch on build breakage email notifications.
[wxWidgets.git] / interface / ptr_shrd.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: ptr_shrd.h
3 // Purpose: interface of wxSharedPtr<T>
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 @see wxScopedPtr, wxWeakRef, wxObjectDataPtr
22 */
23 class wxSharedPtr<T>
24 {
25 public:
26 //@{
27 /**
28 Constructors.
29 */
30 wxSharedPtrT(T* ptr = NULL);
31 wxSharedPtrT(const wxSharedPtr<T>& tocopy);
32 //@}
33
34 /**
35 Destructor.
36 */
37 ~wxSharedPtrT();
38
39 /**
40 Returns pointer to its object or @NULL.
41 */
42 T* get() const;
43
44 /**
45 Conversion to a boolean expression (in a variant which is not
46 convertable to anything but a boolean expression). If this class
47 contains a valid pointer it will return @e @true, if it contains
48 a @NULL pointer it will return @e @false.
49 */
50 operator unspecified_bool_type() const;
51
52 /**
53 Returns a reference to the object. If the internal pointer is @NULL this
54 method will cause an assert in debug mode.
55 */
56 T operator*() const;
57
58 /**
59 Returns pointer to its object or @NULL.
60 */
61 T* operator-() const;
62
63 /**
64 Assignment operator. Releases any previously held pointer
65 and creates a reference to @e ptr.
66 */
67 wxSharedPtrT& operator operator=(T* ptr);
68
69 /**
70 Reset pointer to @e ptr. If the reference count of the
71 previously owned pointer was 1 it will be deleted.
72 */
73 void reset(T* ptr = NULL);
74
75 /**
76 Returns @true if this is the only pointer pointing to its object.
77 */
78 bool unique() const;
79
80 /**
81 Returns the number of pointers pointing to its object.
82 */
83 long use_count() const;
84 };
85