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:
@@ -99,11 +99,12 @@ will result in an assert failure in debug builds.
|
|||||||
|
|
||||||
@section overview_refcount_object Making Your Own Reference Counted Class
|
@section overview_refcount_object Making Your Own Reference Counted Class
|
||||||
|
|
||||||
Reference counting can be implemented easily using wxObject and wxObjectRefData
|
Reference counting can be implemented easily using wxObject or using
|
||||||
classes. Alternatively, you can also use the wxObjectDataPtr<T> template.
|
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
|
First, derive a new class from wxRefCounter (or wxObjectRefData when
|
||||||
memory-consuming data.
|
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
|
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
|
which will be seen by the user of your class. You'll probably want to add a
|
||||||
|
@@ -1,15 +1,14 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: object.h
|
// Name: object.h
|
||||||
// Purpose: interface of wxObjectRefData
|
// Purpose: interface of wxRefCounter
|
||||||
// Author: wxWidgets team
|
// Author: wxWidgets team
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Licence: wxWindows license
|
// 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
|
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.
|
from a wxObject's reference data, you will need to cast to your own derived class.
|
||||||
@@ -131,32 +130,45 @@
|
|||||||
}
|
}
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
|
|
||||||
@library{wxbase}
|
@library{wxbase}
|
||||||
@category{rtti}
|
@category{rtti}
|
||||||
|
|
||||||
@see wxObject, wxObjectDataPtr<T>, @ref overview_refcount
|
@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:
|
protected:
|
||||||
/**
|
/**
|
||||||
Destructor.
|
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.
|
will never be destroyed directly but only as result of a DecRef() call.
|
||||||
*/
|
*/
|
||||||
virtual ~wxObjectRefData();
|
virtual ~wxRefCounter();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
Default constructor. Initialises the internal reference count to 1.
|
Default constructor. Initialises the internal reference count to 1.
|
||||||
*/
|
*/
|
||||||
wxObjectRefData();
|
wxRefCounter();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Decrements the reference count associated with this shared data and, if
|
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.
|
memory.
|
||||||
|
|
||||||
Please note that after calling this function, the caller should
|
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"
|
wxObject can be used to implement @ref overview_refcount "reference counted"
|
||||||
objects, such as wxPen, wxBitmap and others
|
objects, such as wxPen, wxBitmap and others
|
||||||
(see @ref overview_refcount_list "this list").
|
(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.
|
reference counting.
|
||||||
|
|
||||||
@library{wxbase}
|
@library{wxbase}
|
||||||
@category{rtti}
|
@category{rtti}
|
||||||
|
|
||||||
@see wxClassInfo, @ref overview_debugging, @ref overview_refcount,
|
@see wxClassInfo, @ref overview_debugging, @ref overview_refcount,
|
||||||
wxObjectRefData, wxObjectDataPtr<T>
|
wxObjectDataRef, wxObjectDataPtr<T>
|
||||||
*/
|
*/
|
||||||
class wxObject
|
class wxObject
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user