Update docs to mention wxRefCounter class
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61036 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
b42d5f7556
commit
0e497a9db6
@ -99,11 +99,12 @@ will result in an assert failure in debug builds.
|
||||
|
||||
@section overview_refcount_object Making Your Own Reference Counted Class
|
||||
|
||||
Reference counting can be implemented easily using wxObject and wxObjectRefData
|
||||
classes. Alternatively, you can also use the wxObjectDataPtr<T> template.
|
||||
Reference counting can be implemented easily using wxObject or using
|
||||
the intermediate wxRefCounter class directly.
|
||||
Alternatively, you can also use the wxObjectDataPtr<T> template.
|
||||
|
||||
First, derive a new class from wxObjectRefData and put there the
|
||||
memory-consuming data.
|
||||
First, derive a new class from wxRefCounter (or wxObjectRefData when
|
||||
using a wxObject derived class) and put the memory-consuming data in it.
|
||||
|
||||
Then derive a new class from wxObject and implement there the public interface
|
||||
which will be seen by the user of your class. You'll probably want to add a
|
||||
|
@ -1,15 +1,14 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: object.h
|
||||
// Purpose: interface of wxObjectRefData
|
||||
// Purpose: interface of wxRefCounter
|
||||
// Author: wxWidgets team
|
||||
// RCS-ID: $Id$
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
@class wxObjectRefData
|
||||
/** @class wxObjectRefData
|
||||
|
||||
This class is used to store reference-counted data.
|
||||
This class is just a typedef to wxRefCounter and is used by wxObject.
|
||||
|
||||
Derive classes from this to store your own data. When retrieving information
|
||||
from a wxObject's reference data, you will need to cast to your own derived class.
|
||||
@ -137,26 +136,39 @@
|
||||
|
||||
@see wxObject, wxObjectDataPtr<T>, @ref overview_refcount
|
||||
*/
|
||||
class wxObjectRefData
|
||||
typedef wxRefCounter wxObjectRefData;
|
||||
|
||||
|
||||
/**
|
||||
@class wxRefCounter
|
||||
|
||||
This class is used to manage reference-counting.
|
||||
|
||||
@library{wxbase}
|
||||
@category{rtti}
|
||||
|
||||
@see wxObject, wxObjectRefData, wxObjectDataPtr<T>, @ref overview_refcount
|
||||
*/
|
||||
class wxRefCounter
|
||||
{
|
||||
protected:
|
||||
/**
|
||||
Destructor.
|
||||
|
||||
It's declared @c protected so that wxObjectRefData instances
|
||||
It's declared @c protected so that wxRefCounter instances
|
||||
will never be destroyed directly but only as result of a DecRef() call.
|
||||
*/
|
||||
virtual ~wxObjectRefData();
|
||||
virtual ~wxRefCounter();
|
||||
|
||||
public:
|
||||
/**
|
||||
Default constructor. Initialises the internal reference count to 1.
|
||||
*/
|
||||
wxObjectRefData();
|
||||
wxRefCounter();
|
||||
|
||||
/**
|
||||
Decrements the reference count associated with this shared data and, if
|
||||
it reaches zero, destroys this instance of wxObjectRefData releasing its
|
||||
it reaches zero, destroys this instance of wxRefCounter releasing its
|
||||
memory.
|
||||
|
||||
Please note that after calling this function, the caller should
|
||||
@ -198,14 +210,14 @@ public:
|
||||
wxObject can be used to implement @ref overview_refcount "reference counted"
|
||||
objects, such as wxPen, wxBitmap and others
|
||||
(see @ref overview_refcount_list "this list").
|
||||
See wxObjectRefData and @ref overview_refcount for more info about
|
||||
See wxRefCounter and @ref overview_refcount for more info about
|
||||
reference counting.
|
||||
|
||||
@library{wxbase}
|
||||
@category{rtti}
|
||||
|
||||
@see wxClassInfo, @ref overview_debugging, @ref overview_refcount,
|
||||
wxObjectRefData, wxObjectDataPtr<T>
|
||||
wxObjectDataRef, wxObjectDataPtr<T>
|
||||
*/
|
||||
class wxObject
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user