X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/72636c1509db52918996658c17e5e948b64fa5dc..a9c98d7dd3a089e47a14369dcaf30a5e983079d5:/docs/latex/wx/weakref.tex diff --git a/docs/latex/wx/weakref.tex b/docs/latex/wx/weakref.tex index 16298ea5df..5464e81f6d 100644 --- a/docs/latex/wx/weakref.tex +++ b/docs/latex/wx/weakref.tex @@ -1,16 +1,17 @@ \section{\class{wxWeakRef}}\label{wxweakref} -{\bf wxWeakRef} is a template class for weak references to wxWidgets objects, -such as {\bf wxEvtHandler}, {\bf wxWindow} and {\bf wxObject}. A weak -reference behaves much like an ordinary pointer, but when the object pointed -is destroyed, the weak reference is automatically reset to a NULL pointer. - -wxWeakref can be used whenever one must keep a pointer to an object -that does not directly own, and that may be destroyed before the object +wxWeakRef is a template class for weak references to wxWidgets objects, +such as \helpref{wxEvtHandler}{wxevthandler}, \helpref{wxWindow}{wxwindow} and +\helpref{wxObject}{wxobject}. A weak reference behaves much like an ordinary +pointer, but when the object pointed is destroyed, the weak reference is +automatically reset to a NULL pointer. + +wxWeakRef can be used whenever one must keep a pointer to an object +that one does not directly own, and that may be destroyed before the object holding the reference. -wxWeakref is a small object and the mechanism behind it is fast -({\bf O(1)}). So the overall cost of using it is small. +wxWeakRef is a small object and the mechanism behind it is fast +(\textbf{O(1)}). So the overall cost of using it is small. \wxheading{Example} @@ -30,12 +31,11 @@ wxWeakref is a small object and the mechanism behind it is fast wxASSERT( wr==NULL ); \end{verbatim} -wxWeakref works for any objects that are derived from -\helpref{wxTrackableBase}{wxtrackablebase} or \helpref{wxTrackable}{wxtrackable}. -By default, wxEvtHandler and wxWindow derive from wxTrackableBase. However, -wxObject does not, so types like {\bf wxFont} and -{\bf wxColour} are not trackable. The example below shows how to create a -wxObject derived class that is trackable: +wxWeakRef works for any objects that are derived from \helpref{wxTrackable}{wxtrackable}. +By default, wxEvtHandler and wxWindow derive from wxTrackable. However, +wxObject does not, so types like \helpref{wxFont}{wxfont} and +\helpref{wxColour}{wxcolour} are not trackable. The example below shows how to +create a wxObject derived class that is trackable: \begin{verbatim} class wxMyTrackableObject : public wxObject, public wxTrackable { @@ -43,19 +43,11 @@ wxObject derived class that is trackable: }; \end{verbatim} -{\bf Note:} Custom trackable objects should derive from wxTrackable -if one wants to reference them from a {\bf wxWeakRef}. The -difference between the two base classes is that wxTrackableBase -has no virtual member functions (no VTable), and thus cannot be detected -through {\bf dynamic_cast<>}. - - \wxheading{Predefined types} The following types of weak references are predefined: \begin{verbatim} -typedef wxWeakRef wxObjectRef; typedef wxWeakRef wxEvtHandlerRef; typedef wxWeakRef wxWindowRef; \end{verbatim} @@ -69,6 +61,10 @@ wxTrackerNode +\wxheading{See also} + +\helpref{wxSharedPtr}{wxsharedptr}, \helpref{wxScopedPtr}{wxscopedptrtemplate} + \wxheading{Data structures} {\small% @@ -101,6 +97,15 @@ Destructor. Returns pointer to the tracked object or NULL. +\membersection{wxWeakRef::operator unspecified\_bool\_type}\label{wxweakrefoperatorbool} + +\constfunc{}{operator unspecified\_bool\_type}{\void} + +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 {\it true}, if it contains +a NULL pointer it will return {\it false}. + \membersection{wxWeakRef::operator*}\label{wxweakrefoperatorreft} @@ -121,7 +126,7 @@ method will cause an assert in debug mode. \membersection{wxWeakRef::operator=}\label{wxweakrefoperatorassign} -\func{T* operator}{operator=}{\param{T* }{pobj}} +\func{T*}{operator=}{\param{T* }{pobj}} Releases the currently tracked object and starts tracking {\it pobj}. A weak reference may be reset by passing {\it NULL} as {\it pobj}. @@ -129,12 +134,19 @@ A weak reference may be reset by passing {\it NULL} as {\it pobj}. \membersection{wxWeakRef::operator =}\label{wxweakrefoperatorassign2} -\func{T* operator}{operator =}{\param{wxWeakRef\& }{wr}} +\func{T*}{operator =}{\param{wxWeakRef\& }{wr}} Release currently tracked object and start tracking the same object as the wxWeakRef {\it wr}. +\membersection{wxWeakRef::Release}\label{wxweakrefrelease} + +\func{void}{Release}{\void} + +Release currently tracked object and rests object reference. + + \membersection{wxWeakRef::OnObjectDestroy}\label{wxweakrefonobjectdestroy} \func{virtual void}{OnObjectDestroy}{\void}