X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/7c913512a4c9f36e11e07ea707002fab1608d324..6656b711088fbddc0ee8086c42d46969806d9417:/interface/ptr_shrd.h diff --git a/interface/ptr_shrd.h b/interface/ptr_shrd.h index d527784cff..ab24ca063f 100644 --- a/interface/ptr_shrd.h +++ b/interface/ptr_shrd.h @@ -1,85 +1,102 @@ ///////////////////////////////////////////////////////////////////////////// // Name: ptr_shrd.h -// Purpose: documentation for wxSharedPtr class +// Purpose: interface of wxSharedPtr // Author: wxWidgets team // RCS-ID: $Id$ // Licence: wxWindows license ///////////////////////////////////////////////////////////////////////////// /** - @class wxSharedPtrT @wxheader{ptr_shrd.h} - A smart pointer with non-intrusive reference counting. It is modeled - after @b boost::shared_ptr and can be used with STL containers - and wxVector - unlike @b std::auto_ptr - and wxScopedPtr. + A smart pointer with non-intrusive reference counting. It is modeled after + @c boost::shared_ptr<> and can be used with STL containers and wxVector - + unlike @c std::auto_ptr<> and wxScopedPtr. @library{wxbase} - @category{FIXME} + @category{smartpointers} - @seealso - wxScopedPtr, wxWeakRef, wxObjectDataPtr + @see wxScopedPtr, wxWeakRef, wxObjectDataPtr */ + +template class wxSharedPtr { public: - //@{ /** - Constructors. + Constructor. + + Creates shared pointer from the raw pointer @a ptr and takes ownership + of it. */ - wxSharedPtrT(T* ptr = @NULL); - wxSharedPtrT(const wxSharedPtr& tocopy); - //@} + wxEXPLICIT wxSharedPtr(T* ptr = NULL); + + /** + Copy constructor. + */ + wxSharedPtr(const wxSharedPtr& tocopy); /** Destructor. */ - ~wxSharedPtrT(); + ~wxSharedPtr(); /** Returns pointer to its object or @NULL. */ - T* get(); + T* get() const; /** Conversion to a boolean expression (in a variant which is not - convertable to anything but a boolean expression). If this class - contains a valid pointer it will return @e @true, if it contains - a @NULL pointer it will return @e @false. + convertable to anything but a boolean expression). + + If this class contains a valid pointer it will return @true, if it contains + a @NULL pointer it will return @false. */ - operator unspecified_bool_type(); + operator unspecified_bool_type() const; /** - Returns a reference to the object. If the internal pointer is @NULL this - method will cause an assert in debug mode. + Returns a reference to the object. + + If the internal pointer is @NULL this method will cause an assert in debug mode. */ - T operator*(); + T operator*() const; /** Returns pointer to its object or @NULL. */ - T* operator-(); + T* operator->() const; /** - Assignment operator. Releases any previously held pointer - and creates a reference to @e ptr. + Assignment operator. + + Releases any previously held pointer and creates a reference to @a ptr. */ - wxSharedPtrT& operator operator=(T * ptr); + wxSharedPtr& operator=(T* ptr); /** - Reset pointer to @e ptr. If the reference count of the - previously owned pointer was 1 it will be deleted. + Assignment operator. + + Releases any previously held pointer and creates a reference to the + same object as @a topcopy. */ - void reset(T * ptr = @NULL); + wxSharedPtr& operator=(const wxSharedPtr& tocopy) + + /** + Reset pointer to @a ptr. + + If the reference count of the previously owned pointer was 1 it will be deleted. + */ + void reset(T* ptr = NULL); /** Returns @true if this is the only pointer pointing to its object. */ - bool unique(); + bool unique() const; /** Returns the number of pointers pointing to its object. */ - long use_count(); + long use_count() const; }; +